@@ -800,7 +800,7 @@ _Py_InitializeMainInterpreter(PyInterpreterState *interp,
800800 return _Py_INIT_ERR ("can't initialize time" );
801801 }
802802
803- if (_PySys_EndInit (interp -> sysdict , & interp -> config ) < 0 ) {
803+ if (_PySys_EndInit (interp -> sysdict , interp ) < 0 ) {
804804 return _Py_INIT_ERR ("can't finish initializing sys" );
805805 }
806806
@@ -1285,7 +1285,7 @@ new_interpreter(PyThreadState **tstate_p)
12851285 goto handle_error ;
12861286 Py_INCREF (interp -> sysdict );
12871287 PyDict_SetItemString (interp -> sysdict , "modules" , modules );
1288- _PySys_EndInit (interp -> sysdict , & interp -> config );
1288+ _PySys_EndInit (interp -> sysdict , interp );
12891289 }
12901290
12911291 bimod = _PyImport_FindBuiltin ("builtins" , modules );
@@ -1543,7 +1543,7 @@ is_valid_fd(int fd)
15431543
15441544/* returns Py_None if the fd is not valid */
15451545static PyObject *
1546- create_stdio (PyObject * io ,
1546+ create_stdio (const _PyCoreConfig * config , PyObject * io ,
15471547 int fd , int write_mode , const char * name ,
15481548 const char * encoding , const char * errors )
15491549{
@@ -1556,6 +1556,7 @@ create_stdio(PyObject* io,
15561556 _Py_IDENTIFIER (isatty );
15571557 _Py_IDENTIFIER (TextIOWrapper );
15581558 _Py_IDENTIFIER (mode );
1559+ const int buffered_stdio = config -> buffered_stdio ;
15591560
15601561 if (!is_valid_fd (fd ))
15611562 Py_RETURN_NONE ;
@@ -1565,7 +1566,7 @@ create_stdio(PyObject* io,
15651566 depends on the presence of a read1() method which only exists on
15661567 buffered streams.
15671568 */
1568- if (Py_UnbufferedStdioFlag && write_mode )
1569+ if (! buffered_stdio && write_mode )
15691570 buffering = 0 ;
15701571 else
15711572 buffering = -1 ;
@@ -1607,11 +1608,11 @@ create_stdio(PyObject* io,
16071608 Py_DECREF (res );
16081609 if (isatty == -1 )
16091610 goto error ;
1610- if (Py_UnbufferedStdioFlag )
1611+ if (! buffered_stdio )
16111612 write_through = Py_True ;
16121613 else
16131614 write_through = Py_False ;
1614- if (isatty && ! Py_UnbufferedStdioFlag )
1615+ if (isatty && buffered_stdio )
16151616 line_buffering = Py_True ;
16161617 else
16171618 line_buffering = Py_False ;
@@ -1720,7 +1721,7 @@ init_sys_streams(PyInterpreterState *interp)
17201721 * and fileno() may point to an invalid file descriptor. For example
17211722 * GUI apps don't have valid standard streams by default.
17221723 */
1723- std = create_stdio (iomod , fd , 0 , "<stdin>" ,
1724+ std = create_stdio (config , iomod , fd , 0 , "<stdin>" ,
17241725 config -> stdio_encoding ,
17251726 config -> stdio_errors );
17261727 if (std == NULL )
@@ -1731,7 +1732,7 @@ init_sys_streams(PyInterpreterState *interp)
17311732
17321733 /* Set sys.stdout */
17331734 fd = fileno (stdout );
1734- std = create_stdio (iomod , fd , 1 , "<stdout>" ,
1735+ std = create_stdio (config , iomod , fd , 1 , "<stdout>" ,
17351736 config -> stdio_encoding ,
17361737 config -> stdio_errors );
17371738 if (std == NULL )
@@ -1743,7 +1744,7 @@ init_sys_streams(PyInterpreterState *interp)
17431744#if 1 /* Disable this if you have trouble debugging bootstrap stuff */
17441745 /* Set sys.stderr, replaces the preliminary stderr */
17451746 fd = fileno (stderr );
1746- std = create_stdio (iomod , fd , 1 , "<stderr>" ,
1747+ std = create_stdio (config , iomod , fd , 1 , "<stderr>" ,
17471748 config -> stdio_encoding ,
17481749 "backslashreplace" );
17491750 if (std == NULL )
0 commit comments