Skip to content

Commit 6deccd5

Browse files
Set up memory allocator before initializing runtime.
1 parent 6438bf5 commit 6deccd5

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Modules/main.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,6 @@ read_command_line(int argc, wchar_t **argv, _Py_CommandLineDetails *cmdline)
380380
wchar_t *command = NULL;
381381
wchar_t *module = NULL;
382382
int c;
383-
char *opt;
384-
385-
opt = Py_GETENV("PYTHONMALLOC");
386-
if (_PyMem_SetupAllocators(opt) < 0) {
387-
fprintf(stderr,
388-
"Error in PYTHONMALLOC: unknown allocator \"%s\"!\n", opt);
389-
exit(1);
390-
}
391383

392384
_PyOS_ResetGetOpt();
393385

@@ -603,6 +595,13 @@ Py_Main(int argc, wchar_t **argv)
603595
}
604596
}
605597

598+
char *pymalloc = Py_GETENV("PYTHONMALLOC");
599+
if (_PyMem_SetupAllocators(pymalloc) < 0) {
600+
fprintf(stderr,
601+
"Error in PYTHONMALLOC: unknown allocator \"%s\"!\n", pymalloc);
602+
exit(1);
603+
}
604+
606605
/* Initialize the core language runtime */
607606
Py_IgnoreEnvironmentFlag = core_config.ignore_environment;
608607
core_config._disable_importlib = 0;

0 commit comments

Comments
 (0)