Skip to content

Commit

Permalink
bpo-41006: Remove init_sys_streams() hack (GH-20954)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vstinner authored Jun 17, 2020
1 parent 4c18fc8 commit 1bf7959
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
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.
13 changes: 0 additions & 13 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,6 @@ static PyStatus
init_sys_streams(PyThreadState *tstate)
{
PyObject *iomod = NULL;
PyObject *m;
PyObject *std = NULL;
int fd;
PyObject * encoding_attr;
Expand All @@ -1959,18 +1958,6 @@ init_sys_streams(PyThreadState *tstate)
}
#endif

/* Hack to avoid a nasty recursion issue when Python is invoked
in verbose mode: pre-import the Latin-1 and UTF-8 codecs */
if ((m = PyImport_ImportModule("encodings.utf_8")) == NULL) {
goto error;
}
Py_DECREF(m);

if (!(m = PyImport_ImportModule("encodings.latin_1"))) {
goto error;
}
Py_DECREF(m);

if (!(iomod = PyImport_ImportModule("io"))) {
goto error;
}
Expand Down

0 comments on commit 1bf7959

Please sign in to comment.