[Python-checkins] r69626 - python/branches/io-c/Modules/_textio.c

benjamin.peterson python-checkins at python.org
Sun Feb 15 00:33:34 CET 2009


Author: benjamin.peterson
Date: Sun Feb 15 00:33:34 2009
New Revision: 69626

Log:
only catch AttributeError and UnsupportedOperation

Modified:
   python/branches/io-c/Modules/_textio.c

Modified: python/branches/io-c/Modules/_textio.c
==============================================================================
--- python/branches/io-c/Modules/_textio.c	(original)
+++ python/branches/io-c/Modules/_textio.c	Sun Feb 15 00:33:34 2009
@@ -750,10 +750,16 @@
         /* Try os.device_encoding(fileno) */
         PyObject *fileno, *os;;
         fileno = PyObject_CallMethod(buffer, "fileno", NULL);
-        /* Ignore any error */
-        /* XXX only AttributeError and UnsupportedOperation */
-        if (fileno == NULL)
-            PyErr_Clear();
+        /* Ignore only AttributeError and UnsupportedOperation */
+        if (fileno == NULL) {
+            if (PyErr_ExceptionMatches(PyExc_AttributeError) ||
+                PyErr_ExceptionMatches(PyIOExc_UnsupportedOperation)) {
+                PyErr_Clear();
+            }
+            else {
+                goto error;
+            }
+        }
         else {
             os = PyImport_ImportModule("os");
             if (os == NULL) {


More information about the Python-checkins mailing list