Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
30147710
Commit
30147710
authored
Aug 28, 2012
by
Richard Oudkerk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #15784: Modify OSError.__str__() to better distinguish between
errno error numbers and Windows error numbers.
parent
ca2b6468
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
4 deletions
+7
-4
Lib/test/test_exceptions.py
Lib/test/test_exceptions.py
+2
-2
Misc/NEWS
Misc/NEWS
+3
-0
Objects/exceptions.c
Objects/exceptions.c
+2
-2
No files found.
Lib/test/test_exceptions.py
View file @
30147710
...
...
@@ -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
),
"[
Win
Error 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
),
"[
Win
Error 1001] foo"
)
# Non-numeric "errno"
w
=
OSError
(
'bar'
,
'foo'
)
self
.
assertEqual
(
w
.
errno
,
'bar'
)
...
...
Misc/NEWS
View file @
30147710
...
...
@@ -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
-------
...
...
Objects/exceptions.c
View file @
30147710
...
...
@@ -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
(
"[
Win
Error %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
(
"[
Win
Error %S] %S"
,
self
->
winerror
?
self
->
winerror
:
Py_None
,
self
->
strerror
?
self
->
strerror
:
Py_None
);
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment