Author pitrou
Recipients gvanrossum, ncoghlan, pitrou, skrah, vstinner
Date 2013-12-21.12:19:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1387628393.03.0.667977483615.issue20037@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-12-21 12:19:53pitrousetrecipients: + pitrou, gvanrossum, ncoghlan, vstinner, skrah
2013-12-21 12:19:53pitrousetmessageid: <1387628393.03.0.667977483615.issue20037@psf.upfronthosting.co.za>
2013-12-21 12:19:53pitroulinkissue20037 messages
2013-12-21 12:19:52pitroucreate