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
e92dc9c2
Kaydet (Commit)
e92dc9c2
authored
Haz 25, 2016
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix a scoping issue where an UnboundLocalError was triggered if a
lazy-loaded module was already in sys.modules.
üst
559ad5d4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
util.py
Lib/importlib/util.py
+1
-1
test_lazy.py
Lib/test/test_importlib/test_lazy.py
+13
-3
NEWS
Misc/NEWS
+4
-0
No files found.
Lib/importlib/util.py
Dosyayı görüntüle @
e92dc9c2
...
@@ -241,7 +241,7 @@ class _LazyModule(types.ModuleType):
...
@@ -241,7 +241,7 @@ class _LazyModule(types.ModuleType):
if
id
(
self
)
!=
id
(
sys
.
modules
[
original_name
]):
if
id
(
self
)
!=
id
(
sys
.
modules
[
original_name
]):
msg
=
(
'module object for {!r} substituted in sys.modules '
msg
=
(
'module object for {!r} substituted in sys.modules '
'during a lazy load'
)
'during a lazy load'
)
raise
ValueError
(
msg
.
format
(
original_name
))
raise
ValueError
(
msg
.
format
(
original_name
))
# Update after loading since that's what would happen in an eager
# Update after loading since that's what would happen in an eager
# loading situation.
# loading situation.
self
.
__dict__
.
update
(
attrs_updated
)
self
.
__dict__
.
update
(
attrs_updated
)
...
...
Lib/test/test_importlib/test_lazy.py
Dosyayı görüntüle @
e92dc9c2
import
importlib
import
importlib
from
importlib
import
abc
from
importlib
import
abc
from
importlib
import
util
from
importlib
import
util
import
sys
import
types
import
unittest
import
unittest
from
.
import
util
as
test_util
from
.
import
util
as
test_util
...
@@ -122,12 +124,20 @@ class LazyLoaderTests(unittest.TestCase):
...
@@ -122,12 +124,20 @@ class LazyLoaderTests(unittest.TestCase):
self
.
assertFalse
(
hasattr
(
module
,
'__name__'
))
self
.
assertFalse
(
hasattr
(
module
,
'__name__'
))
def
test_module_substitution_error
(
self
):
def
test_module_substitution_error
(
self
):
source_code
=
'import sys; sys.modules[__name__] = 42'
module
=
self
.
new_module
(
source_code
)
with
test_util
.
uncache
(
TestingImporter
.
module_name
):
with
test_util
.
uncache
(
TestingImporter
.
module_name
):
with
self
.
assertRaises
(
ValueError
):
fresh_module
=
types
.
ModuleType
(
TestingImporter
.
module_name
)
sys
.
modules
[
TestingImporter
.
module_name
]
=
fresh_module
module
=
self
.
new_module
()
with
self
.
assertRaisesRegex
(
ValueError
,
"substituted"
):
module
.
__name__
module
.
__name__
def
test_module_already_in_sys
(
self
):
with
test_util
.
uncache
(
TestingImporter
.
module_name
):
module
=
self
.
new_module
()
sys
.
modules
[
TestingImporter
.
module_name
]
=
module
# Force the load; just care that no exception is raised.
module
.
__name__
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
Misc/NEWS
Dosyayı görüntüle @
e92dc9c2
...
@@ -13,6 +13,10 @@ Core and Builtins
...
@@ -13,6 +13,10 @@ Core and Builtins
Library
Library
-------
-------
- Fix a scoping issue in importlib.util.LazyLoader which triggered an
UnboundLocalError when lazy-loading a module that was already put into
sys.modules.
- Issue #27079: Fixed curses.ascii functions isblank(), iscntrl() and ispunct().
- Issue #27079: Fixed curses.ascii functions isblank(), iscntrl() and ispunct().
- Issue #26754: Some functions (compile() etc) accepted a filename argument
- Issue #26754: Some functions (compile() etc) accepted a filename argument
...
...
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