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
79d79a0f
Kaydet (Commit)
79d79a0f
authored
Tem 07, 2012
tarafından
Florent Xicluna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Minor refactoring in importlib._bootstrap, and fix the '_wrap' docstring.
üst
a1c974a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
_bootstrap.py
Lib/importlib/_bootstrap.py
+15
-14
No files found.
Lib/importlib/_bootstrap.py
Dosyayı görüntüle @
79d79a0f
...
...
@@ -140,7 +140,7 @@ def _write_atomic(path, data):
def
_wrap
(
new
,
old
):
"""Simple substitute for functools.
wraps
."""
"""Simple substitute for functools.
update_wrapper
."""
for
replace
in
[
'__module__'
,
'__name__'
,
'__qualname__'
,
'__doc__'
]:
if
hasattr
(
old
,
replace
):
setattr
(
new
,
replace
,
getattr
(
old
,
replace
))
...
...
@@ -345,7 +345,7 @@ def set_package(fxn):
"""Set __package__ on the returned module."""
def
set_package_wrapper
(
*
args
,
**
kwargs
):
module
=
fxn
(
*
args
,
**
kwargs
)
if
not
hasattr
(
module
,
'__package__'
)
or
module
.
__package__
is
None
:
if
getattr
(
module
,
'__package__'
,
None
)
is
None
:
module
.
__package__
=
module
.
__name__
if
not
hasattr
(
module
,
'__path__'
):
module
.
__package__
=
module
.
__package__
.
rpartition
(
'.'
)[
0
]
...
...
@@ -438,7 +438,7 @@ def _requires_builtin(fxn):
"""Decorator to verify the named module is built-in."""
def
_requires_builtin_wrapper
(
self
,
fullname
):
if
fullname
not
in
sys
.
builtin_module_names
:
raise
ImportError
(
"{
0
} is not a built-in module"
.
format
(
fullname
),
raise
ImportError
(
"{} is not a built-in module"
.
format
(
fullname
),
name
=
fullname
)
return
fxn
(
self
,
fullname
)
_wrap
(
_requires_builtin_wrapper
,
fxn
)
...
...
@@ -449,7 +449,7 @@ def _requires_frozen(fxn):
"""Decorator to verify the named module is frozen."""
def
_requires_frozen_wrapper
(
self
,
fullname
):
if
not
_imp
.
is_frozen
(
fullname
):
raise
ImportError
(
"{
0
} is not a frozen module"
.
format
(
fullname
),
raise
ImportError
(
"{} is not a frozen module"
.
format
(
fullname
),
name
=
fullname
)
return
fxn
(
self
,
fullname
)
_wrap
(
_requires_frozen_wrapper
,
fxn
)
...
...
@@ -511,7 +511,7 @@ class BuiltinImporter:
@classmethod
@_requires_builtin
def
is_package
(
cls
,
fullname
):
"""Return
Non
e as built-in modules are never packages."""
"""Return
Fals
e as built-in modules are never packages."""
return
False
...
...
@@ -936,7 +936,7 @@ class _NamespacePath:
return
len
(
self
.
_recalculate
())
def
__repr__
(
self
):
return
"_NamespacePath({
0
!r})"
.
format
(
self
.
_path
)
return
"_NamespacePath({!r})"
.
format
(
self
.
_path
)
def
__contains__
(
self
,
item
):
return
item
in
self
.
_recalculate
()
...
...
@@ -1198,7 +1198,7 @@ def _resolve_name(name, package, level):
if
len
(
bits
)
<
level
:
raise
ValueError
(
'attempted relative import beyond top-level package'
)
base
=
bits
[
0
]
return
'{
0}.{1
}'
.
format
(
base
,
name
)
if
name
else
base
return
'{
}.{
}'
.
format
(
base
,
name
)
if
name
else
base
def
_find_module
(
name
,
path
):
...
...
@@ -1228,7 +1228,7 @@ def _sanity_check(name, package, level):
if
not
isinstance
(
package
,
str
):
raise
TypeError
(
"__package__ not set to a string"
)
elif
package
not
in
sys
.
modules
:
msg
=
(
"Parent module {
0
!r} not loaded, cannot perform relative "
msg
=
(
"Parent module {!r} not loaded, cannot perform relative "
"import"
)
raise
SystemError
(
msg
.
format
(
package
))
if
not
name
and
level
==
0
:
...
...
@@ -1267,7 +1267,7 @@ def _find_and_load_unlocked(name, import_):
parent_module
=
sys
.
modules
[
parent
]
setattr
(
parent_module
,
name
.
rpartition
(
'.'
)[
2
],
module
)
# Set __package__ if the loader did not.
if
not
hasattr
(
module
,
'__package__'
)
or
module
.
__package__
is
None
:
if
getattr
(
module
,
'__package__'
,
None
)
is
None
:
try
:
module
.
__package__
=
module
.
__name__
if
not
hasattr
(
module
,
'__path__'
):
...
...
@@ -1336,11 +1336,12 @@ def _handle_fromlist(module, fromlist, import_):
fromlist
=
list
(
fromlist
)
fromlist
.
remove
(
'*'
)
fromlist
.
extend
(
module
.
__all__
)
for
x
in
(
y
for
y
in
fromlist
if
not
hasattr
(
module
,
y
)):
try
:
import_
(
'{0}.{1}'
.
format
(
module
.
__name__
,
x
))
except
ImportError
:
pass
for
x
in
fromlist
:
if
not
hasattr
(
module
,
x
):
try
:
import_
(
'{}.{}'
.
format
(
module
.
__name__
,
x
))
except
ImportError
:
pass
return
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