]> granicus.if.org Git - python/commitdiff
Issue #15784: Modify OSError.__str__() to better distinguish between
authorRichard Oudkerk <shibturn@gmail.com>
Tue, 28 Aug 2012 18:33:26 +0000 (19:33 +0100)
committerRichard Oudkerk <shibturn@gmail.com>
Tue, 28 Aug 2012 18:33:26 +0000 (19:33 +0100)
errno error numbers and Windows error numbers.

Lib/test/test_exceptions.py
Misc/NEWS
Objects/exceptions.c

index 55e9db37803cbb38ad20fea02f513fff71e4e63e..413f4dd62bc6024b1d6d70013af11c93f12f80dd 100644 (file)
@@ -216,14 +216,14 @@ class ExceptionTests(unittest.TestCase):
             self.assertEqual(w.winerror, 3)
             self.assertEqual(w.strerror, 'foo')
             self.assertEqual(w.filename, 'bar')
-            self.assertEqual(str(w), "[Error 3] foo: 'bar'")
+            self.assertEqual(str(w), "[WinError 3] foo: 'bar'")
             # Unknown win error becomes EINVAL (22)
             w = OSError(0, 'foo', None, 1001)
             self.assertEqual(w.errno, 22)
             self.assertEqual(w.winerror, 1001)
             self.assertEqual(w.strerror, 'foo')
             self.assertEqual(w.filename, None)
-            self.assertEqual(str(w), "[Error 1001] foo")
+            self.assertEqual(str(w), "[WinError 1001] foo")
             # Non-numeric "errno"
             w = OSError('bar', 'foo')
             self.assertEqual(w.errno, 'bar')
index bc091f12c8fce2ba6480465f1b2289926723e5e9..50baf865506d551ee50cc01fcf4973c330d296fe 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Release Candidate 2?
 Core and Builtins
 -----------------
 
+- Issue #15784: Modify OSError.__str__() to better distinguish between
+  errno error numbers and Windows error numbers.
+
 Library
 -------
 
index 74bb26285ef2b86c503fd54b78d669bc07f6a6b1..6b04700621109bbe1825726d6b4ae0d4d2f214b1 100644 (file)
@@ -1016,12 +1016,12 @@ OSError_str(PyOSErrorObject *self)
 #ifdef MS_WINDOWS
     /* If available, winerror has the priority over myerrno */
     if (self->winerror && self->filename)
-        return PyUnicode_FromFormat("[Error %S] %S: %R",
+        return PyUnicode_FromFormat("[WinError %S] %S: %R",
                                     self->winerror ? self->winerror: Py_None,
                                     self->strerror ? self->strerror: Py_None,
                                     self->filename);
     if (self->winerror && self->strerror)
-        return PyUnicode_FromFormat("[Error %S] %S",
+        return PyUnicode_FromFormat("[WinError %S] %S",
                                     self->winerror ? self->winerror: Py_None,
                                     self->strerror ? self->strerror: Py_None);
 #endif