From 8552a8eb74379224fc542f7881e9736dafe8343a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 15 Jun 2026 11:06:00 +0200 Subject: [PATCH 1/2] gh-139227: Remove unused _PyRuntime.imports.pkgcontext The global variable has been replaced by the thread local variable "pkgcontext" in Python/import.c. --- Include/internal/pycore_interp_structs.h | 2 -- Python/import.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/Include/internal/pycore_interp_structs.h b/Include/internal/pycore_interp_structs.h index 956fa290f0ad0e7..5500c70a3b0aad9 100644 --- a/Include/internal/pycore_interp_structs.h +++ b/Include/internal/pycore_interp_structs.h @@ -308,8 +308,6 @@ struct _import_runtime_state { Modules are added there and looked up in _imp.find_extension(). */ struct _Py_hashtable_t *hashtable; } extensions; - /* Package context -- the full module name for package imports */ - const char * pkgcontext; }; struct _import_state { diff --git a/Python/import.c b/Python/import.c index 42bfe15121f84f7..48066261df4785b 100644 --- a/Python/import.c +++ b/Python/import.c @@ -81,8 +81,6 @@ static struct _inittab *inittab_copy = NULL; #define LAST_MODULE_INDEX _PyRuntime.imports.last_module_index #define EXTENSIONS _PyRuntime.imports.extensions -#define PKGCONTEXT (_PyRuntime.imports.pkgcontext) - /*******************************/ /* interpreter import state */ From 879eb71beb0777949cf5af769ac90fe6bb7209aa Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 15 Jun 2026 11:55:48 +0200 Subject: [PATCH 2/2] Remove undef --- Python/import.c | 1 - 1 file changed, 1 deletion(-) diff --git a/Python/import.c b/Python/import.c index 48066261df4785b..6da6faf5f28cc3b 100644 --- a/Python/import.c +++ b/Python/import.c @@ -881,7 +881,6 @@ _PyImport_ClearModulesByIndex(PyInterpreterState *interp) */ static _Py_thread_local const char *pkgcontext = NULL; -# undef PKGCONTEXT # define PKGCONTEXT pkgcontext const char *