diff options
author | Inada Naoki <songofacandy@gmail.com> | 2022-04-09 00:54:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-09 00:54:54 (GMT) |
commit | 677320348728ce058fa3579017e985af74a236d4 (patch) | |
tree | 944297b71196964eab27a3336918c5a8f1e6a17d /Modules/_io | |
parent | cd29bd13ef1fe18970c5d43b66c545dd03117cb9 (diff) | |
download | cpython-677320348728ce058fa3579017e985af74a236d4.zip cpython-677320348728ce058fa3579017e985af74a236d4.tar.gz cpython-677320348728ce058fa3579017e985af74a236d4.tar.bz2 |
bpo-47000: Add `locale.getencoding()` (GH-32068)
Diffstat (limited to 'Modules/_io')
-rw-r--r-- | Modules/_io/textio.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index d9d1c88..0e20741 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -1145,7 +1145,13 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer, } } if (encoding == NULL && self->encoding == NULL) { - self->encoding = _Py_GetLocaleEncodingObject(); + if (_PyRuntime.preconfig.utf8_mode) { + _Py_DECLARE_STR(utf_8, "utf-8"); + self->encoding = Py_NewRef(&_Py_STR(utf_8)); + } + else { + self->encoding = _Py_GetLocaleEncodingObject(); + } if (self->encoding == NULL) { goto error; } |