Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-47000: Add locale.getencoding() #32068

Merged
merged 13 commits into from
Apr 9, 2022
Prev Previous commit
Next Next commit
fix TextIOWrapper.__init__
methane committed Apr 4, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 104206a17ca897533da83e85634970a79a82f51b
9 changes: 8 additions & 1 deletion Modules/_io/textio.c
Original file line number Diff line number Diff line change
@@ -1145,7 +1145,14 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
}
}
if (encoding == NULL && self->encoding == NULL) {
self->encoding = _Py_GetLocaleEncodingObject();
const PyPreConfig *preconfig = &_PyRuntime.preconfig;
if (preconfig->utf8_mode) {
// TODO: Use _Py_STR
self->encoding = PyUnicode_FromString("utf-8");
}
else {
self->encoding = _Py_GetLocaleEncodingObject();
}
if (self->encoding == NULL) {
goto error;
}