Skip to content

Commit 1bf7959

Browse files
authored
bpo-41006: Remove init_sys_streams() hack (GH-20954)
The encodings.latin_1 module is no longer imported at startup. Now it is only imported when it is the filesystem encoding or the stdio encoding.
1 parent 4c18fc8 commit 1bf7959

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The ``encodings.latin_1`` module is no longer imported at startup. Now it is
2+
only imported when it is the filesystem encoding or the stdio encoding.

Python/pylifecycle.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,6 @@ static PyStatus
19391939
init_sys_streams(PyThreadState *tstate)
19401940
{
19411941
PyObject *iomod = NULL;
1942-
PyObject *m;
19431942
PyObject *std = NULL;
19441943
int fd;
19451944
PyObject * encoding_attr;
@@ -1959,18 +1958,6 @@ init_sys_streams(PyThreadState *tstate)
19591958
}
19601959
#endif
19611960

1962-
/* Hack to avoid a nasty recursion issue when Python is invoked
1963-
in verbose mode: pre-import the Latin-1 and UTF-8 codecs */
1964-
if ((m = PyImport_ImportModule("encodings.utf_8")) == NULL) {
1965-
goto error;
1966-
}
1967-
Py_DECREF(m);
1968-
1969-
if (!(m = PyImport_ImportModule("encodings.latin_1"))) {
1970-
goto error;
1971-
}
1972-
Py_DECREF(m);
1973-
19741961
if (!(iomod = PyImport_ImportModule("io"))) {
19751962
goto error;
19761963
}

0 commit comments

Comments
 (0)