blueloveTH před 1 rokem
rodič
revize
4b292abb4e

+ 8 - 0
docs/modules/importlib.md

@@ -0,0 +1,8 @@
+---
+icon: package
+label: importlib
+---
+
+### `importlib.reload(module)`
+
+Reload a previously imported module. The argument must be a module object, so it must have been successfully imported before. This is useful if you have edited the module source file using an external editor and want to try out the new version without leaving the Python interpreter. The return value is the module object (the same as the argument).

+ 0 - 1
include/pocketpy/common/_generated.h

@@ -12,5 +12,4 @@ extern const char kPythonLibs_datetime[];
 extern const char kPythonLibs_functools[];
 extern const char kPythonLibs_heapq[];
 extern const char kPythonLibs_operator[];
-extern const char kPythonLibs_this[];
 extern const char kPythonLibs_typing[];

+ 1 - 1
include/pocketpy/pocketpy.h

@@ -486,7 +486,7 @@ PK_API py_GlobalRef py_newmodule(const char* path);
 /// Get a module by path.
 PK_API py_GlobalRef py_getmodule(const char* path);
 /// Reload an existing module.
-PK_API bool py_importlib_reload(py_GlobalRef module) PY_RAISE;
+PK_API bool py_importlib_reload(py_GlobalRef module) PY_RAISE PY_RETURN;
 
 /// Import a module.
 /// The result will be set to `py_retval()`.

+ 0 - 21
python/this.py

@@ -1,21 +0,0 @@
-print("""The Zen of Python, by Tim Peters
-
-Beautiful is better than ugly.
-Explicit is better than implicit.
-Simple is better than complex.
-Complex is better than complicated.
-Flat is better than nested.
-Sparse is better than dense.
-Readability counts.
-Special cases aren't special enough to break the rules.
-Although practicality beats purity.
-Errors should never pass silently.
-Unless explicitly silenced.
-In the face of ambiguity, refuse the temptation to guess.
-There should be one-- and preferably only one --obvious way to do it.
-Although that way may not be obvious at first unless you're Dutch.
-Now is better than never.
-Although never is often better than *right* now.
-If the implementation is hard to explain, it's a bad idea.
-If the implementation is easy to explain, it may be a good idea.
-Namespaces are one honking great idea -- let's do more of those!""")

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
src/common/_generated.c


+ 1 - 3
src/modules/importlib.c

@@ -3,9 +3,7 @@
 static bool importlib_reload(int argc, py_Ref argv) {
     PY_CHECK_ARGC(1);
     PY_CHECK_ARG_TYPE(0, tp_module);
-    bool ok = py_importlib_reload(argv);
-    py_newnone(py_retval());
-    return ok;
+    return py_importlib_reload(argv);
 }
 
 void pk__add_module_importlib() {

+ 1 - 0
src/public/modules.c

@@ -174,6 +174,7 @@ bool py_importlib_reload(py_GlobalRef module) {
     if(data == NULL) return ImportError("module '%v' not found", path);
     bool ok = py_exec(data, filename->data, EXEC_MODE, module);
     c11_string__delete(filename);
+    py_assign(py_retval(), module);
     return ok;
 }
 

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů