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
38430e2d
Commit
38430e2d
authored
Aug 19, 2010
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix os.get_exec_path() (code and tests) for python -bb
Catch BytesWarning exceptions.
parent
9802b39c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
Lib/os.py
Lib/os.py
+2
-2
Lib/test/test_os.py
Lib/test/test_os.py
+10
-3
No files found.
Lib/os.py
View file @
38430e2d
...
...
@@ -387,13 +387,13 @@ def get_exec_path(env=None):
try
:
path_list
=
env
.
get
(
'PATH'
)
except
TypeError
:
except
(
TypeError
,
BytesWarning
)
:
path_list
=
None
if
supports_bytes_environ
:
try
:
path_listb
=
env
[
b'PATH'
]
except
(
KeyError
,
TypeError
):
except
(
KeyError
,
TypeError
,
BytesWarning
):
pass
else
:
if
path_list
is
not
None
:
...
...
Lib/test/test_os.py
View file @
38430e2d
...
...
@@ -450,8 +450,12 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
if
os
.
supports_bytes_environ
:
# env cannot contain 'PATH' and b'PATH' keys
self
.
assertRaises
(
ValueError
,
os
.
get_exec_path
,
{
'PATH'
:
'1'
,
b'PATH'
:
b'2'
})
try
:
mixed_env
=
{
'PATH'
:
'1'
,
b'PATH'
:
b'2'
}
except
BytesWarning
:
pass
else
:
self
.
assertRaises
(
ValueError
,
os
.
get_exec_path
,
mixed_env
)
# bytes key and/or value
self
.
assertSequenceEqual
(
os
.
get_exec_path
({
b'PATH'
:
b'abc'
}),
...
...
@@ -723,7 +727,10 @@ class ExecTests(unittest.TestCase):
# os.get_exec_path() reads the 'PATH' variable
with
_execvpe_mockup
()
as
calls
:
env_path
=
env
.
copy
()
env_path
[
'PATH'
]
=
program_path
if
test_type
is
bytes
:
env_path
[
b'PATH'
]
=
program_path
else
:
env_path
[
'PATH'
]
=
program_path
self
.
assertRaises
(
OSError
,
os
.
_execvpe
,
program
,
arguments
,
env
=
env_path
)
self
.
assertEqual
(
len
(
calls
),
1
)
...
...
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