diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h index 56018d9cbad..b4bd93a8bcb 100644 --- a/Include/internal/pycore_ceval.h +++ b/Include/internal/pycore_ceval.h @@ -311,7 +311,7 @@ PyAPI_FUNC(void) _PyEval_FormatExcCheckArg(PyThreadState *tstate, PyObject *exc, PyAPI_FUNC(void) _PyEval_FormatExcUnbound(PyThreadState *tstate, PyCodeObject *co, int oparg); PyAPI_FUNC(void) _PyEval_FormatKwargsError(PyThreadState *tstate, PyObject *func, PyObject *kwargs); PyAPI_FUNC(PyObject *) _PyEval_ImportFrom(PyThreadState *, PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) _PyEval_LazyImportName(PyThreadState *tstate, PyObject *builtins, PyObject *globals, +PyAPI_FUNC(PyObject *) _PyEval_LazyImportName(PyThreadState *tstate, PyObject *builtins, PyObject *globals, PyObject *locals, PyObject *name, PyObject *fromlist, PyObject *level, int lazy); PyAPI_FUNC(PyObject *) _PyEval_LazyImportFrom(PyThreadState *tstate, PyObject *v, PyObject *name); PyAPI_FUNC(PyObject *) _PyEval_ImportName(PyThreadState *tstate, PyObject *builtins, PyObject *globals, PyObject *locals, diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 1a1bcc77ece..0403739c015 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -1706,7 +1706,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(effective_ids)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(element_factory)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(emptyerror)); - _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(enabled)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(encode)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(encoding)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(end)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 0633ceeaf0c..ce94e69b28c 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -429,7 +429,6 @@ struct _Py_global_strings { STRUCT_FOR_ID(effective_ids) STRUCT_FOR_ID(element_factory) STRUCT_FOR_ID(emptyerror) - STRUCT_FOR_ID(enabled) STRUCT_FOR_ID(encode) STRUCT_FOR_ID(encoding) STRUCT_FOR_ID(end) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index c0f60925a0f..af2795debae 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -1704,7 +1704,6 @@ extern "C" { INIT_ID(effective_ids), \ INIT_ID(element_factory), \ INIT_ID(emptyerror), \ - INIT_ID(enabled), \ INIT_ID(encode), \ INIT_ID(encoding), \ INIT_ID(end), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index 0b1bc279722..3e6ec8801b0 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -1496,10 +1496,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); assert(PyUnicode_GET_LENGTH(string) != 1); - string = &_Py_ID(enabled); - _PyUnicode_InternStatic(interp, &string); - assert(_PyUnicode_CheckConsistency(string, 1)); - assert(PyUnicode_GET_LENGTH(string) != 1); string = &_Py_ID(encode); _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py index 59341f08431..cb687f7cc4f 100644 --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -191,7 +191,7 @@ def attr_matches(self, text): continue if (isinstance(thisobject, types.ModuleType) - and + and isinstance(thisobject.__dict__.get(word),types.LazyImportType) ): value = thisobject.__dict__.get(word) diff --git a/Lib/test/test_import/data/lazy_imports/pkg/b.py b/Lib/test/test_import/data/lazy_imports/pkg/b.py index 3aa53d31aae..a266b7c7c0d 100644 --- a/Lib/test/test_import/data/lazy_imports/pkg/b.py +++ b/Lib/test/test_import/data/lazy_imports/pkg/b.py @@ -1,3 +1,2 @@ def foo(): return 'foo' - diff --git a/Lib/test/test_import/data/lazy_imports/pkg/bar.py b/Lib/test/test_import/data/lazy_imports/pkg/bar.py index c02e2d137aa..b7a4d7111a6 100644 --- a/Lib/test/test_import/data/lazy_imports/pkg/bar.py +++ b/Lib/test/test_import/data/lazy_imports/pkg/bar.py @@ -1,2 +1 @@ def f(): pass - diff --git a/Programs/test_frozenmain.h b/Programs/test_frozenmain.h index f808544045e..cf33b95399f 100644 --- a/Programs/test_frozenmain.h +++ b/Programs/test_frozenmain.h @@ -13,10 +13,10 @@ unsigned char M_test_frozenmain[] = { 82,5,93,6,12,0,82,6,93,5,93,6,44,26,0,0, 0,0,0,0,0,0,0,0,12,0,50,4,52,1,0,0, 0,0,0,0,31,0,75,26,0,0,9,0,30,0,82,1, - 35,0,41,8,233,0,0,0,0,78,122,18,70,114,111,122, - 101,110,32,72,101,108,108,111,32,87,111,114,108,100,122,8, + 35,0,41,8,233,0,0,0,0,78,218,18,70,114,111,122, + 101,110,32,72,101,108,108,111,32,87,111,114,108,100,218,8, 115,121,115,46,97,114,103,118,218,6,99,111,110,102,105,103, - 122,7,99,111,110,102,105,103,32,122,2,58,32,41,5,218, + 218,7,99,111,110,102,105,103,32,218,2,58,32,41,5,218, 12,112,114,111,103,114,97,109,95,110,97,109,101,218,10,101, 120,101,99,117,116,97,98,108,101,218,15,117,115,101,95,101, 110,118,105,114,111,110,109,101,110,116,218,17,99,111,110,102, @@ -25,15 +25,15 @@ unsigned char M_test_frozenmain[] = { 3,115,121,115,218,17,95,116,101,115,116,105,110,116,101,114, 110,97,108,99,97,112,105,218,5,112,114,105,110,116,218,4, 97,114,103,118,218,11,103,101,116,95,99,111,110,102,105,103, - 115,114,3,0,0,0,218,3,107,101,121,169,0,243,0,0, + 115,114,5,0,0,0,218,3,107,101,121,169,0,243,0,0, 0,0,218,18,116,101,115,116,95,102,114,111,122,101,110,109, 97,105,110,46,112,121,218,8,60,109,111,100,117,108,101,62, - 114,18,0,0,0,1,0,0,0,115,94,0,0,0,240,3, + 114,22,0,0,0,1,0,0,0,115,94,0,0,0,240,3, 1,1,1,243,8,0,1,11,219,0,24,225,0,5,208,6, 26,212,0,27,217,0,5,128,106,144,35,151,40,145,40,212, 0,27,216,9,26,215,9,38,210,9,38,211,9,40,168,24, 213,9,50,128,6,243,2,6,12,2,128,67,241,14,0,5, 10,136,71,144,67,144,53,152,2,152,54,160,35,157,59,152, - 45,208,10,40,214,4,41,243,15,6,12,2,114,16,0,0, + 45,208,10,40,214,4,41,243,15,6,12,2,114,20,0,0, 0, }; diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 036f8864462..45fd79e8d58 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -297,7 +297,7 @@ __lazy_import__ as builtin___lazy_import__ fromlist: object(c_default="NULL") = () level: int = 0 -Lazily imports a module. +Lazily imports a module. Returns either the module to be imported or a imp.lazy_module object which indicates the module to be lazily imported. diff --git a/Python/ceval.c b/Python/ceval.c index 86a089c2cfa..32a052ddba5 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3512,7 +3512,7 @@ check_lazy_import_comatibility(PyThreadState *tstate, PyObject *globals, PyObject * _PyEval_LazyImportName(PyThreadState *tstate, PyObject *builtins, PyObject *globals, - PyObject *locals, PyObject *name, PyObject *fromlist, PyObject *level, + PyObject *locals, PyObject *name, PyObject *fromlist, PyObject *level, int lazy) { PyObject *res = NULL; diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h index 493c756b827..c8c141f863d 100644 --- a/Python/clinic/bltinmodule.c.h +++ b/Python/clinic/bltinmodule.c.h @@ -1380,4 +1380,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=65b2a6dfb50b64bc input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1c3327da8885bb8e input=a9049054013a1b77]*/ diff --git a/Python/clinic/sysmodule.c.h b/Python/clinic/sysmodule.c.h index 49ec484355e..5d30faeaa17 100644 --- a/Python/clinic/sysmodule.c.h +++ b/Python/clinic/sysmodule.c.h @@ -2000,9 +2000,10 @@ PyDoc_STRVAR(sys_get_lazy_modules__doc__, "\n" "Gets the set of module names that have been lazily imported.\n" "\n" -"Returns a set of fully-qualified module names that have been lazily imported\n" -"at some point (primarily for diagnostics and introspection). Note that modules\n" -"are removed from this set when they are reified (actually loaded)."); +"Returns a set of fully-qualified module names that have been lazily\n" +"imported at some point (primarily for diagnostics and introspection).\n" +"Note that modules are removed from this set when they are reified\n" +"(actually loaded)."); #define SYS_GET_LAZY_MODULES_METHODDEF \ {"get_lazy_modules", (PyCFunction)sys_get_lazy_modules, METH_NOARGS, sys_get_lazy_modules__doc__}, @@ -2143,4 +2144,4 @@ exit: #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF #define SYS_GETANDROIDAPILEVEL_METHODDEF #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */ -/*[clinic end generated code: output=cec3ca2ba0ad32cc input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a64004ec17cceb34 input=a9049054013a1b77]*/ diff --git a/Python/codegen.c b/Python/codegen.c index de57dceb078..1c5781d189a 100644 --- a/Python/codegen.c +++ b/Python/codegen.c @@ -2960,7 +2960,7 @@ codegen_from_import(compiler *c, stmt_ty s) ADDOP_NAME_CUSTOM(c, LOC(s), IMPORT_NAME, from, names, 2, 0); } } - + for (Py_ssize_t i = 0; i < n; i++) { alias_ty alias = (alias_ty)asdl_seq_GET(s->v.ImportFrom.names, i); identifier store_name; diff --git a/Python/compile.c b/Python/compile.c index fa7a1ce6dc9..d3cff59d9d1 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -816,7 +816,7 @@ _PyCompile_InExceptionHandler(compiler *c) default: break; } - } + } return false; } diff --git a/Python/import.c b/Python/import.c index 8c6ba97b681..9aa43392f1f 100644 --- a/Python/import.c +++ b/Python/import.c @@ -3793,7 +3793,7 @@ resolve_name(PyThreadState *tstate, PyObject *name, PyObject *globals, int level PyObject * _PyImport_ResolveName(PyThreadState *tstate, PyObject *name, PyObject *globals, int level) { - return resolve_name(tstate, name, globals, level); + return resolve_name(tstate, name, globals, level); } PyObject * @@ -4767,7 +4767,7 @@ PyImport_SetLazyImportsFilter(PyObject *filter) /* Gets the lazy imports filter. Returns a new reference. */ PyObject * -PyImport_GetLazyImportsFilter() +PyImport_GetLazyImportsFilter(void) { PyInterpreterState *interp = _PyInterpreterState_GET(); return Py_XNewRef(FT_ATOMIC_LOAD_PTR_RELAXED(LAZY_IMPORTS_FILTER(interp))); @@ -4784,7 +4784,7 @@ PyImport_SetLazyImportsMode(PyImport_LazyImportsMode mode) /* Checks if lazy imports is globally enabled or disabled. Return 1 when globally * forced on, 0 when globally forced off, or -1 when */ PyImport_LazyImportsMode -PyImport_GetLazyImportsMode() +PyImport_GetLazyImportsMode(void) { PyInterpreterState *interp = _PyInterpreterState_GET(); return FT_ATOMIC_LOAD_INT_RELAXED(LAZY_IMPORTS_MODE(interp)); diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 31495493844..eee24e5fc6a 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -2896,15 +2896,16 @@ sys.get_lazy_modules Gets the set of module names that have been lazily imported. -Returns a set of fully-qualified module names that have been lazily imported -at some point (primarily for diagnostics and introspection). Note that modules -are removed from this set when they are reified (actually loaded). +Returns a set of fully-qualified module names that have been lazily +imported at some point (primarily for diagnostics and introspection). +Note that modules are removed from this set when they are reified +(actually loaded). [clinic start generated code]*/ static PyObject * sys_get_lazy_modules_impl(PyObject *module) -/*[clinic end generated code: output=4c641f8881ba87c0 input=06c7a1d05bcfa36a]*/ +/*[clinic end generated code: output=4c641f8881ba87c0 input=511b3a9682c09282]*/ { PyInterpreterState *interp = _PyInterpreterState_GET(); PyObject *lazy_modules_set = interp->imports.lazy_modules_set;