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
8e455402
Kaydet (Commit)
8e455402
authored
Agu 15, 2013
tarafından
Eric Snow
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Closes issue #18698: ensure importlib.reload() returns the module out of sys.modules.
üst
01dbca0b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
1 deletion
+21
-1
__init__.py
Lib/importlib/__init__.py
+3
-1
test_api.py
Lib/test/test_importlib/test_api.py
+16
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/importlib/__init__.py
Dosyayı görüntüle @
8e455402
...
@@ -118,7 +118,9 @@ def reload(module):
...
@@ -118,7 +118,9 @@ def reload(module):
if
parent_name
and
parent_name
not
in
sys
.
modules
:
if
parent_name
and
parent_name
not
in
sys
.
modules
:
msg
=
"parent {!r} not in sys.modules"
msg
=
"parent {!r} not in sys.modules"
raise
ImportError
(
msg
.
format
(
parent_name
),
name
=
parent_name
)
raise
ImportError
(
msg
.
format
(
parent_name
),
name
=
parent_name
)
return
module
.
__loader__
.
load_module
(
name
)
module
.
__loader__
.
load_module
(
name
)
# The module may have replaced itself in sys.modules!
return
sys
.
modules
[
module
.
__name__
]
finally
:
finally
:
try
:
try
:
del
_RELOADING
[
name
]
del
_RELOADING
[
name
]
...
...
Lib/test/test_importlib/test_api.py
Dosyayı görüntüle @
8e455402
...
@@ -162,6 +162,22 @@ class ReloadTests(unittest.TestCase):
...
@@ -162,6 +162,22 @@ class ReloadTests(unittest.TestCase):
module
=
importlib
.
import_module
(
mod
)
module
=
importlib
.
import_module
(
mod
)
importlib
.
reload
(
module
)
importlib
.
reload
(
module
)
def
test_module_replaced
(
self
):
def
code
():
import
sys
module
=
type
(
sys
)(
'top_level'
)
module
.
spam
=
3
sys
.
modules
[
'top_level'
]
=
module
mock
=
util
.
mock_modules
(
'top_level'
,
module_code
=
{
'top_level'
:
code
})
with
mock
:
with
util
.
import_state
(
meta_path
=
[
mock
]):
module
=
importlib
.
import_module
(
'top_level'
)
reloaded
=
importlib
.
reload
(
module
)
actual
=
sys
.
modules
[
'top_level'
]
self
.
assertEqual
(
actual
.
spam
,
3
)
self
.
assertEqual
(
reloaded
.
spam
,
3
)
class
InvalidateCacheTests
(
unittest
.
TestCase
):
class
InvalidateCacheTests
(
unittest
.
TestCase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
8e455402
...
@@ -203,6 +203,8 @@ Core and Builtins
...
@@ -203,6 +203,8 @@ Core and Builtins
- Issue #17867: Raise an ImportError if __import__ is not found in __builtins__.
- Issue #17867: Raise an ImportError if __import__ is not found in __builtins__.
- Issue #18698: Ensure importlib.reload() returns the module out of sys.modules.
- Issue #17857: Prevent build failures with pre-3.5.0 versions of sqlite3,
- Issue #17857: Prevent build failures with pre-3.5.0 versions of sqlite3,
such as was shipped with Centos 5 and Mac OS X 10.4.
such as was shipped with Centos 5 and Mac OS X 10.4.
...
...
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