[Python-checkins] r52485 - in python/trunk: Lib/test/test_exceptions.py Misc/NEWS Objects/exceptions.c

thomas.heller python-checkins at python.org
Fri Oct 27 20:31:37 CEST 2006


Author: thomas.heller
Date: Fri Oct 27 20:31:36 2006
New Revision: 52485

Modified:
   python/trunk/Lib/test/test_exceptions.py
   python/trunk/Misc/NEWS
   python/trunk/Objects/exceptions.c
Log:
WindowsError.str should display the windows error code,
not the posix error code; with test.
Fixes #1576174.

Will backport to release25-maint.

Modified: python/trunk/Lib/test/test_exceptions.py
==============================================================================
--- python/trunk/Lib/test/test_exceptions.py	(original)
+++ python/trunk/Lib/test/test_exceptions.py	Fri Oct 27 20:31:36 2006
@@ -183,6 +183,19 @@
             test_capi1()
             test_capi2()
 
+    def test_WindowsError(self):
+        try:
+            WindowsError
+        except NameError:
+            pass
+        else:
+            self.failUnlessEqual(str(WindowsError(1001)),
+                                 "1001")
+            self.failUnlessEqual(str(WindowsError(1001, "message")),
+                                 "[Error 1001] message")
+            self.failUnlessEqual(WindowsError(1001, "message").errno, 22)
+            self.failUnlessEqual(WindowsError(1001, "message").winerror, 1001)
+
     def testAttributes(self):
         # test that exception attributes are happy
 

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Fri Oct 27 20:31:36 2006
@@ -12,6 +12,9 @@
 Core and builtins
 -----------------
 
+- Bug #1576174: WindowsError now displays the windows error code
+  again, no longer the posix error code.
+
 - Patch #1549049: Support long values in structmember, issue warnings
   if the assigned value for structmember fields gets truncated.
 

Modified: python/trunk/Objects/exceptions.c
==============================================================================
--- python/trunk/Objects/exceptions.c	(original)
+++ python/trunk/Objects/exceptions.c	Fri Oct 27 20:31:36 2006
@@ -828,9 +828,9 @@
             return NULL;
         }
 
-        if (self->myerrno) {
-            Py_INCREF(self->myerrno);
-            PyTuple_SET_ITEM(tuple, 0, self->myerrno);
+        if (self->winerror) {
+            Py_INCREF(self->winerror);
+            PyTuple_SET_ITEM(tuple, 0, self->winerror);
         }
         else {
             Py_INCREF(Py_None);
@@ -852,7 +852,7 @@
         Py_DECREF(fmt);
         Py_DECREF(tuple);
     }
-    else if (self->myerrno && self->strerror) {
+    else if (self->winerror && self->strerror) {
         PyObject *fmt;
         PyObject *tuple;
 
@@ -866,9 +866,9 @@
             return NULL;
         }
 
-        if (self->myerrno) {
-            Py_INCREF(self->myerrno);
-            PyTuple_SET_ITEM(tuple, 0, self->myerrno);
+        if (self->winerror) {
+            Py_INCREF(self->winerror);
+            PyTuple_SET_ITEM(tuple, 0, self->winerror);
         }
         else {
             Py_INCREF(Py_None);


More information about the Python-checkins mailing list