summaryrefslogtreecommitdiffstats
path: root/Modules/_io/textio.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_io/textio.c')
-rw-r--r--Modules/_io/textio.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 79c64ba..833a527 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -14,7 +14,6 @@
_Py_IDENTIFIER(close);
_Py_IDENTIFIER(_dealloc_warn);
_Py_IDENTIFIER(decode);
-_Py_IDENTIFIER(device_encoding);
_Py_IDENTIFIER(fileno);
_Py_IDENTIFIER(flush);
_Py_IDENTIFIER(getpreferredencoding);
@@ -875,9 +874,13 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
}
}
else {
- self->encoding = _PyObject_CallMethodId(state->os_module,
- &PyId_device_encoding,
- "N", fileno);
+ int fd = (int) PyLong_AsLong(fileno);
+ Py_DECREF(fileno);
+ if (fd == -1 && PyErr_Occurred()) {
+ goto error;
+ }
+
+ self->encoding = _Py_device_encoding(fd);
if (self->encoding == NULL)
goto error;
else if (!PyUnicode_Check(self->encoding))