Skip to content

Commit 68debc9

Browse files
author
Michael W. Hudson
committed
Fix refcounting and cut & paste error (?) in last checkin.
This should go onto release23-maint, too.
1 parent 0fd54d8 commit 68debc9

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

‎Python/pythonrun.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,14 @@ Py_Initialize(void)
252252
setlocale(LC_CTYPE, saved_locale);
253253

254254
if (codeset) {
255-
sys_stream = PySys_GetObject("stdout");
255+
sys_stream = PySys_GetObject("stdin");
256256
sys_isatty = PyObject_CallMethod(sys_stream, "isatty", "");
257257
if (!sys_isatty)
258258
PyErr_Clear();
259259
if(sys_isatty && PyObject_IsTrue(sys_isatty)) {
260260
if (!PyFile_SetEncoding(sys_stream, codeset))
261261
Py_FatalError("Cannot set codeset of stdin");
262262
}
263-
Py_XDECREF(sys_stream);
264263
Py_XDECREF(sys_isatty);
265264

266265
sys_stream = PySys_GetObject("stdout");
@@ -271,7 +270,6 @@ Py_Initialize(void)
271270
if (!PyFile_SetEncoding(sys_stream, codeset))
272271
Py_FatalError("Cannot set codeset of stdout");
273272
}
274-
Py_XDECREF(sys_stream);
275273
Py_XDECREF(sys_isatty);
276274

277275
if (!Py_FileSystemDefaultEncoding)

0 commit comments

Comments
 (0)