bpo-43510: PEP 597: Accept encoding="locale" in binary mode (GH-25103)

It make `encoding="locale"` usable everywhere `encoding=None` is
allowed.
This commit is contained in:
Inada Naoki 2021-03-31 14:26:08 +09:00 committed by GitHub
parent 1b4a9c7956
commit ff3c9739bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View file

@ -346,7 +346,8 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
goto error;
}
if (binary && encoding != NULL) {
if (binary && encoding != NULL
&& strcmp(encoding, "locale") != 0) {
PyErr_SetString(PyExc_ValueError,
"binary mode doesn't take an encoding argument");
goto error;