[Python-checkins] cpython: Issue #15784: Modify OSError.__str__() to better distinguish between
georg.brandl
python-checkins at python.org
Sun Sep 9 11:19:01 CEST 2012
http://hg.python.org/cpython/rev/4e941113e4fa
changeset: 78899:4e941113e4fa
user: Richard Oudkerk <shibturn at gmail.com>
date: Tue Aug 28 19:33:26 2012 +0100
summary:
Issue #15784: Modify OSError.__str__() to better distinguish between
errno error numbers and Windows error numbers.
files:
Lib/test/test_exceptions.py | 4 ++--
Misc/NEWS | 3 +++
Objects/exceptions.c | 4 ++--
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -216,14 +216,14 @@
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')
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- Issue #15784: Modify OSError.__str__() to better distinguish between
+ errno error numbers and Windows error numbers.
+
Library
-------
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -1016,12 +1016,12 @@
#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
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list