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
3aa2a49e
Kaydet (Commit)
3aa2a49e
authored
Agu 06, 2008
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add imp.reload(). This to help with transitioning to 3.0 the reload() built-in
has been removed there.
üst
c777a412
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
0 deletions
+35
-0
test_imp.py
Lib/test/test_imp.py
+19
-0
NEWS
Misc/NEWS
+3
-0
import.c
Python/import.c
+13
-0
No files found.
Lib/test/test_imp.py
Dosyayı görüntüle @
3aa2a49e
...
...
@@ -37,9 +37,28 @@ class LockTests(unittest.TestCase):
self
.
fail
(
"release_lock() without lock should raise "
"RuntimeError"
)
class
ReloadTests
(
unittest
.
TestCase
):
"""Very basic tests to make sure that imp.reload() operates just like
reload()."""
def
test_source
(
self
):
import
os
imp
.
reload
(
os
)
def
test_extension
(
self
):
import
time
imp
.
reload
(
time
)
def
test_builtin
(
self
):
import
marshal
imp
.
reload
(
marshal
)
def
test_main
():
test_support
.
run_unittest
(
LockTests
,
ReloadTests
,
)
if
__name__
==
"__main__"
:
...
...
Misc/NEWS
Dosyayı görüntüle @
3aa2a49e
...
...
@@ -41,6 +41,9 @@ Core and Builtins
Library
-------
- Issue #2338: Create imp.reload() to help with transitioning to Python 3.0 as
the reload() built-in has been removed.
- Changed code in the following modules/packages to remove warnings raised
while running under the ``-3`` flag: aifc, asyncore, bdb, bsddb,
ConfigParser, cookielib, DocXMLRPCServer, email, filecmp, fileinput, inspect,
...
...
Python/import.c
Dosyayı görüntüle @
3aa2a49e
...
...
@@ -3030,12 +3030,24 @@ imp_new_module(PyObject *self, PyObject *args)
return
PyModule_New
(
name
);
}
static
PyObject
*
imp_reload
(
PyObject
*
self
,
PyObject
*
v
)
{
return
PyImport_ReloadModule
(
v
);
}
/* Doc strings */
PyDoc_STRVAR
(
doc_imp
,
"This module provides the components needed to build your own
\n
\
__import__ function. Undocumented functions are obsolete."
);
PyDoc_STRVAR
(
doc_reload
,
"reload(module) -> module
\n
\
\n
\
Reload the module. The module must have been successfully imported before."
);
PyDoc_STRVAR
(
doc_find_module
,
"find_module(name, [path]) -> (file, filename, (suffix, mode, type))
\n
\
Search for a module. If path is omitted or None, search for a
\n
\
...
...
@@ -3080,6 +3092,7 @@ Release the interpreter's import lock.\n\
On platforms without threads, this function does nothing."
);
static
PyMethodDef
imp_methods
[]
=
{
{
"reload"
,
imp_reload
,
METH_O
,
doc_reload
},
{
"find_module"
,
imp_find_module
,
METH_VARARGS
,
doc_find_module
},
{
"get_magic"
,
imp_get_magic
,
METH_NOARGS
,
doc_get_magic
},
{
"get_suffixes"
,
imp_get_suffixes
,
METH_NOARGS
,
doc_get_suffixes
},
...
...
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