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
e8ef4e11
Kaydet (Commit)
e8ef4e11
authored
Şub 26, 2007
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add a partial list of limitations, stripping out some corresponding XXX comments.
üst
4f7ac2e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
6 deletions
+27
-6
xreload.py
Lib/xreload.py
+27
-6
No files found.
Lib/xreload.py
Dosyayı görüntüle @
e8ef4e11
"""Alternative to reload().
This works by executing the module in a scratch namespace, and then
patching classes, methods and functions. This avoids the need to
patch instances. New objects are copied into the target namespace.
patching classes, methods and functions in place. This avoids the
need to patch instances. New objects are copied into the target
namespace.
Some of the many limitiations include:
- Global mutable objects other than classes are simply replaced, not patched
- Code using metaclasses is not handled correctly
- Code creating global singletons is not handled correctly
- Functions and methods using decorators (other than classmethod and
staticmethod) is not handled correctly
- Renamings are not handled correctly
- Dependent modules are not reloaded
- When a dependent module contains 'from foo import bar', and
reloading foo deletes foo.bar, the dependent module continues to use
the old foo.bar object rather than failing
- Frozen modules and modules loaded from zip files aren't handled
correctly
- Classes involving __slots__ are not handled correctly
"""
import
imp
...
...
@@ -43,7 +68,6 @@ def xreload(mod):
# Turn it into a code object
try
:
# Is it Python source code or byte code read from a file?
# XXX Could handle frozen modules, zip-import modules
if
kind
not
in
(
imp
.
PY_COMPILED
,
imp
.
PY_SOURCE
):
# Fall back to built-in reload()
return
reload
(
mod
)
...
...
@@ -106,7 +130,6 @@ def _update(oldobj, newobj):
return
_update_classmethod
(
oldobj
,
newobj
)
if
isinstance
(
newobj
,
staticmethod
):
return
_update_staticmethod
(
oldobj
,
newobj
)
# XXX How to support decorators?
# Not something we recognize, just give up
return
newobj
...
...
@@ -120,7 +143,6 @@ def _update_function(oldfunc, newfunc):
oldfunc
.
__dict__
.
update
(
newfunc
.
__dict__
)
oldfunc
.
__code__
=
newfunc
.
__code__
oldfunc
.
__defaults__
=
newfunc
.
__defaults__
# XXX What else?
return
oldfunc
...
...
@@ -133,7 +155,6 @@ def _update_method(oldmeth, newmeth):
def
_update_class
(
oldclass
,
newclass
):
"""Update a class object."""
# XXX What about __slots__?
olddict
=
oldclass
.
__dict__
newdict
=
newclass
.
__dict__
oldnames
=
set
(
olddict
)
...
...
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