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
0c2dd0c0
Commit
0c2dd0c0
authored
Aug 23, 2013
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close #17702: On error, os.environb now removes suppress the except context
when raising a new KeyError with the original key.
parent
f1e02730
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
2 deletions
+8
-2
Lib/os.py
Lib/os.py
+2
-2
Lib/test/test_os.py
Lib/test/test_os.py
+3
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/os.py
View file @
0c2dd0c0
...
...
@@ -673,7 +673,7 @@ class _Environ(MutableMapping):
value
=
self
.
_data
[
self
.
encodekey
(
key
)]
except
KeyError
:
# raise KeyError with the original key value
raise
KeyError
(
key
)
raise
KeyError
(
key
)
from
None
return
self
.
decodevalue
(
value
)
def
__setitem__
(
self
,
key
,
value
):
...
...
@@ -689,7 +689,7 @@ class _Environ(MutableMapping):
del
self
.
_data
[
encodedkey
]
except
KeyError
:
# raise KeyError with the original key value
raise
KeyError
(
key
)
raise
KeyError
(
key
)
from
None
def
__iter__
(
self
):
for
key
in
self
.
_data
:
...
...
Lib/test/test_os.py
View file @
0c2dd0c0
...
...
@@ -644,10 +644,13 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
with
self
.
assertRaises
(
KeyError
)
as
cm
:
os
.
environ
[
missing
]
self
.
assertIs
(
cm
.
exception
.
args
[
0
],
missing
)
self
.
assertTrue
(
cm
.
exception
.
__suppress_context__
)
with
self
.
assertRaises
(
KeyError
)
as
cm
:
del
os
.
environ
[
missing
]
self
.
assertIs
(
cm
.
exception
.
args
[
0
],
missing
)
self
.
assertTrue
(
cm
.
exception
.
__suppress_context__
)
class
WalkTests
(
unittest
.
TestCase
):
"""Tests for os.walk()."""
...
...
Misc/NEWS
View file @
0c2dd0c0
...
...
@@ -66,6 +66,9 @@ Core and Builtins
Library
-------
- Issue #17702: On error, os.environb now removes suppress the except context
when raising a new KeyError with the original key.
- Issue #18755: Fixed the loader used in imp to allow get_data() to be called
multiple times.
...
...
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