Message206730
Note that the module state is only used when no explicit encoding is given to TextIOWrapper(), so the following patch fixes this particular issue:
$ hg di
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -852,7 +852,7 @@ textiowrapper_init(textio *self, PyObjec
char *errors = NULL;
char *newline = NULL;
int line_buffering = 0, write_through = 0;
- _PyIO_State *state = IO_STATE;
+ _PyIO_State *state = NULL;
PyObject *res;
int r;
@@ -891,6 +891,7 @@ textiowrapper_init(textio *self, PyObjec
if (encoding == NULL) {
/* Try os.device_encoding(fileno) */
PyObject *fileno;
+ state = IO_STATE;
fileno = _PyObject_CallMethodId(buffer, &PyId_fileno, NULL);
/* Ignore only AttributeError and UnsupportedOperation */
if (fileno == NULL) {
However, since doing I/O at shutdown is not a particularly uncommon operation, we should still fix the general case to at least raise a proper exception. |
|
Date |
User |
Action |
Args |
2013-12-21 12:19:53 | pitrou | set | recipients:
+ pitrou, gvanrossum, ncoghlan, vstinner, skrah |
2013-12-21 12:19:53 | pitrou | set | messageid: <1387628393.03.0.667977483615.issue20037@psf.upfronthosting.co.za> |
2013-12-21 12:19:53 | pitrou | link | issue20037 messages |
2013-12-21 12:19:52 | pitrou | create | |
|