Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6f35eda4
Kaydet (Commit)
6f35eda4
authored
Eki 29, 2010
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #10210: os.get_exec_path() ignores BytesWarning warnings
üst
bfd7b265
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
os.py
Lib/os.py
+16
-2
test_os.py
Lib/test/test_os.py
+4
-1
No files found.
Lib/os.py
Dosyayı görüntüle @
6f35eda4
...
@@ -382,18 +382,32 @@ def get_exec_path(env=None):
...
@@ -382,18 +382,32 @@ def get_exec_path(env=None):
*env* must be an environment variable dict or None. If *env* is None,
*env* must be an environment variable dict or None. If *env* is None,
os.environ will be used.
os.environ will be used.
"""
"""
# Use a local import instead of a global import to avoid bootstrap issue:
# the os module is used to build Python extensions.
import
warnings
if
env
is
None
:
if
env
is
None
:
env
=
environ
env
=
environ
try
:
try
:
path_list
=
env
.
get
(
'PATH'
)
# ignore BytesWarning warning
with
warnings
.
catch_warnings
(
record
=
True
):
path_list
=
env
.
get
(
'PATH'
)
except
(
TypeError
,
BytesWarning
):
except
(
TypeError
,
BytesWarning
):
# A BytesWarning here means that env has a b'PATH' key, but no 'PATH'
# key. Compare bytes and str raises a BytesWarning exception only if
# sys.flags.bytes_warning==2, and in this case it is not possible to
# create a dictionary with both keys.
path_list
=
None
path_list
=
None
if
supports_bytes_environ
:
if
supports_bytes_environ
:
try
:
try
:
path_listb
=
env
[
b
'PATH'
]
# ignore BytesWarning warning
with
warnings
.
catch_warnings
(
record
=
True
):
path_listb
=
env
[
b
'PATH'
]
except
(
KeyError
,
TypeError
,
BytesWarning
):
except
(
KeyError
,
TypeError
,
BytesWarning
):
# A BytesWarning here means that env has a 'PATH' key, but no
# b'PATH' key. See the comment above for an explaination.
pass
pass
else
:
else
:
if
path_list
is
not
None
:
if
path_list
is
not
None
:
...
...
Lib/test/test_os.py
Dosyayı görüntüle @
6f35eda4
...
@@ -461,8 +461,11 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
...
@@ -461,8 +461,11 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
if
os
.
supports_bytes_environ
:
if
os
.
supports_bytes_environ
:
# env cannot contain 'PATH' and b'PATH' keys
# env cannot contain 'PATH' and b'PATH' keys
try
:
try
:
mixed_env
=
{
'PATH'
:
'1'
,
b
'PATH'
:
b
'2'
}
# ignore BytesWarning warning
with
warnings
.
catch_warnings
(
record
=
True
):
mixed_env
=
{
'PATH'
:
'1'
,
b
'PATH'
:
b
'2'
}
except
BytesWarning
:
except
BytesWarning
:
# mixed_env cannot be created with python -bb
pass
pass
else
:
else
:
self
.
assertRaises
(
ValueError
,
os
.
get_exec_path
,
mixed_env
)
self
.
assertRaises
(
ValueError
,
os
.
get_exec_path
,
mixed_env
)
...
...
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