diff --git a/Lib/_pyio.py b/Lib/_pyio.py index a5d6135..00fd900 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -1462,7 +1462,7 @@ class TextIOWrapper(TextIOBase): # Importing locale may fail if Python is being built encoding = "ascii" else: - encoding = locale.getpreferredencoding() + encoding = locale.getpreferredencoding(False) if not isinstance(encoding, str): raise ValueError("invalid encoding: %r" % encoding) diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 73d83a1..62dadd6 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -886,7 +886,7 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds) else { use_locale: self->encoding = PyObject_CallMethod( - state->locale_module, "getpreferredencoding", NULL); + state->locale_module, "getpreferredencoding", "O", Py_False); if (self->encoding == NULL) { catch_ImportError: /*