summaryrefslogtreecommitdiff
path: root/Programs
diff options
context:
space:
mode:
Diffstat (limited to 'Programs')
-rw-r--r--Programs/_freeze_module.c10
-rw-r--r--Programs/_testembed.c28
2 files changed, 15 insertions, 23 deletions
diff --git a/Programs/_freeze_module.c b/Programs/_freeze_module.c
index 316c70d2c7..e3f6c11c8b 100644
--- a/Programs/_freeze_module.c
+++ b/Programs/_freeze_module.c
@@ -23,13 +23,16 @@
of frozen modules instead, left deliberately blank so as to avoid
unintentional import of a stale version of _frozen_importlib. */
-static const struct _frozen _PyImport_FrozenModules[] = {
+static const struct _frozen no_modules[] = {
{0, 0, 0} /* sentinel */
};
static const struct _module_alias aliases[] = {
{0, 0} /* sentinel */
};
+const struct _frozen *_PyImport_FrozenBootstrap;
+const struct _frozen *_PyImport_FrozenStdlib;
+const struct _frozen *_PyImport_FrozenTest;
const struct _frozen *PyImport_FrozenModules;
const struct _module_alias *_PyImport_FrozenAliases;
@@ -188,7 +191,10 @@ main(int argc, char *argv[])
{
const char *name, *inpath, *outpath;
- PyImport_FrozenModules = _PyImport_FrozenModules;
+ _PyImport_FrozenBootstrap = no_modules;
+ _PyImport_FrozenStdlib = no_modules;
+ _PyImport_FrozenTest = no_modules;
+ PyImport_FrozenModules = NULL;
_PyImport_FrozenAliases = aliases;
if (argc != 4) {
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index 773c6c3e99..6fe18d93a7 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -8,6 +8,7 @@
#include <Python.h>
#include "pycore_initconfig.h" // _PyConfig_InitCompatConfig()
#include "pycore_runtime.h" // _PyRuntime
+#include "pycore_import.h" // _PyImport_FrozenBootstrap
#include <Python.h>
#include <inttypes.h>
#include <stdio.h>
@@ -1804,30 +1805,10 @@ static int test_unicode_id_init(void)
static int test_frozenmain(void)
{
- // Get "_frozen_importlib" and "_frozen_importlib_external"
- // from PyImport_FrozenModules
- const struct _frozen *importlib = NULL, *importlib_external = NULL;
- for (const struct _frozen *mod = PyImport_FrozenModules; mod->name != NULL; mod++) {
- if (strcmp(mod->name, "_frozen_importlib") == 0) {
- importlib = mod;
- }
- else if (strcmp(mod->name, "_frozen_importlib_external") == 0) {
- importlib_external = mod;
- }
- }
- if (importlib == NULL || importlib_external == NULL) {
- error("cannot find frozen importlib and importlib_external");
- return 1;
- }
-
static struct _frozen frozen_modules[4] = {
- {0, 0, 0}, // importlib
- {0, 0, 0}, // importlib_external
{"__main__", M_test_frozenmain, sizeof(M_test_frozenmain)},
{0, 0, 0} // sentinel
};
- frozen_modules[0] = *importlib;
- frozen_modules[1] = *importlib_external;
char* argv[] = {
"./argv0",
@@ -1846,7 +1827,12 @@ static int test_frozenmain(void)
static int list_frozen(void)
{
const struct _frozen *p;
- for (p = PyImport_FrozenModules; ; p++) {
+ for (p = _PyImport_FrozenBootstrap; ; p++) {
+ if (p->name == NULL)
+ break;
+ printf("%s\n", p->name);
+ }
+ for (p = _PyImport_FrozenStdlib; ; p++) {
if (p->name == NULL)
break;
printf("%s\n", p->name);