[Python-checkins] r69629 - in python/branches/io-c/Modules: _bufferedio.c _iobase.c _iomodule.h _textio.c io.c

benjamin.peterson python-checkins at python.org
Sun Feb 15 05:15:29 CET 2009


Author: benjamin.peterson
Date: Sun Feb 15 05:15:29 2009
New Revision: 69629

Log:
put UnsupportedOperation in the module state

Modified:
   python/branches/io-c/Modules/_bufferedio.c
   python/branches/io-c/Modules/_iobase.c
   python/branches/io-c/Modules/_iomodule.h
   python/branches/io-c/Modules/_textio.c
   python/branches/io-c/Modules/io.c

Modified: python/branches/io-c/Modules/_bufferedio.c
==============================================================================
--- python/branches/io-c/Modules/_bufferedio.c	(original)
+++ python/branches/io-c/Modules/_bufferedio.c	Sun Feb 15 05:15:29 2009
@@ -69,7 +69,7 @@
 static PyObject *
 BufferedIOBase_unsupported(const char *message)
 {
-    PyErr_SetString(PyIOExc_UnsupportedOperation, message);
+    PyErr_SetString(IO_STATE->unsupported_operation, message);
     return NULL;
 }
 

Modified: python/branches/io-c/Modules/_iobase.c
==============================================================================
--- python/branches/io-c/Modules/_iobase.c	(original)
+++ python/branches/io-c/Modules/_iobase.c	Sun Feb 15 05:15:29 2009
@@ -58,7 +58,7 @@
 static PyObject *
 IOBase_unsupported(const char *message)
 {
-    PyErr_SetString(PyIOExc_UnsupportedOperation, message);
+    PyErr_SetString(IO_STATE->unsupported_operation, message);
     return NULL;
 }
 

Modified: python/branches/io-c/Modules/_iomodule.h
==============================================================================
--- python/branches/io-c/Modules/_iomodule.h	(original)
+++ python/branches/io-c/Modules/_iomodule.h	Sun Feb 15 05:15:29 2009
@@ -27,8 +27,6 @@
 extern PyObject* _PyIOBase_checkSeekable(PyObject *self, PyObject *args);
 extern PyObject* _PyIOBase_checkClosed(PyObject *self, PyObject *args);
 
-extern PyObject* PyIOExc_UnsupportedOperation;
-
 /* Helper for finalization.
    This function will revive an object ready to be deallocated and try to
    close() it. It returns 0 if the object can be destroyed, or -1 if it
@@ -101,6 +99,8 @@
     PyObject *os_module;
     PyObject *locale_module;
 
+    PyObject *unsupported_operation;
+
     /* various interned strings */
     PyObject *str_close;
     PyObject *str_closed;

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 05:15:29 2009
@@ -24,7 +24,7 @@
 static PyObject *
 _unsupported(const char *message)
 {
-    PyErr_SetString(PyIOExc_UnsupportedOperation, message);
+    PyErr_SetString(IO_STATE->unsupported_operation, message);
     return NULL;
 }
 
@@ -754,7 +754,7 @@
         /* Ignore only AttributeError and UnsupportedOperation */
         if (fileno == NULL) {
             if (PyErr_ExceptionMatches(PyExc_AttributeError) ||
-                PyErr_ExceptionMatches(PyIOExc_UnsupportedOperation)) {
+                PyErr_ExceptionMatches(state->unsupported_operation)) {
                 PyErr_Clear();
             }
             else {

Modified: python/branches/io-c/Modules/io.c
==============================================================================
--- python/branches/io-c/Modules/io.c	(original)
+++ python/branches/io-c/Modules/io.c	Sun Feb 15 05:15:29 2009
@@ -20,7 +20,6 @@
 #include <sys/stat.h>
 #endif /* HAVE_SYS_STAT_H */
 
-PyObject *PyIOExc_UnsupportedOperation;
 
 
 PyDoc_STRVAR(module_doc,
@@ -612,13 +611,13 @@
         goto fail;
 
     /* UnsupportedOperation inherits from ValueError and IOError */
-    PyIOExc_UnsupportedOperation = PyObject_CallFunction(
+    state->unsupported_operation = PyObject_CallFunction(
         (PyObject *)&PyType_Type, "s(OO){}",
         "UnsupportedOperation", PyExc_ValueError, PyExc_IOError);
-    if (PyIOExc_UnsupportedOperation == NULL)
+    if (state->unsupported_operation == NULL)
         goto fail;
     PyModule_AddObject(m, "UnsupportedOperation",
-                       PyIOExc_UnsupportedOperation);
+                       state->unsupported_operation);
 
     /* BlockingIOError */
     base = (PyTypeObject *)PyExc_IOError;


More information about the Python-checkins mailing list