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
313fa9d3
Kaydet (Commit)
313fa9d3
authored
May 09, 2011
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
#11910: merge with 3.1.
üst
74efb718
199e0857
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
support.py
Lib/test/support.py
+8
-4
No files found.
Lib/test/support.py
Dosyayı görüntüle @
313fa9d3
...
...
@@ -92,12 +92,14 @@ def import_module(name, deprecated=False):
def
_save_and_remove_module
(
name
,
orig_modules
):
"""Helper function to save and remove a module from sys.modules
Return
value is True if the module was in sys.modules and
False otherwise
."""
Return
True if the module was in sys.modules, False otherwise.
Raise ImportError if the module can't be imported
."""
saved
=
True
try
:
orig_modules
[
name
]
=
sys
.
modules
[
name
]
except
KeyError
:
# try to import the module and raise an error if it can't be imported
__import__
(
name
)
saved
=
False
else
:
del
sys
.
modules
[
name
]
...
...
@@ -107,8 +109,7 @@ def _save_and_remove_module(name, orig_modules):
def
_save_and_block_module
(
name
,
orig_modules
):
"""Helper function to save and block a module in sys.modules
Return value is True if the module was in sys.modules and
False otherwise."""
Return True if the module was in sys.modules, False otherwise."""
saved
=
True
try
:
orig_modules
[
name
]
=
sys
.
modules
[
name
]
...
...
@@ -124,6 +125,7 @@ def import_fresh_module(name, fresh=(), blocked=(), deprecated=False):
the sys.modules cache is restored to its original state.
Modules named in fresh are also imported anew if needed by the import.
If one of these modules can't be imported, None is returned.
Importing of modules named in blocked is prevented while the fresh import
takes place.
...
...
@@ -145,6 +147,8 @@ def import_fresh_module(name, fresh=(), blocked=(), deprecated=False):
if
not
_save_and_block_module
(
blocked_name
,
orig_modules
):
names_to_remove
.
append
(
blocked_name
)
fresh_module
=
importlib
.
import_module
(
name
)
except
ImportError
:
fresh_module
=
None
finally
:
for
orig_name
,
module
in
orig_modules
.
items
():
sys
.
modules
[
orig_name
]
=
module
...
...
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