bpo-32030: Add more options to _PyCoreConfig (#4485)
Py_Main() now handles two more -X options:
* -X showrefcount: new _PyCoreConfig.show_ref_count field
* -X showalloccount: new _PyCoreConfig.show_alloc_count field
diff --git a/Modules/main.c b/Modules/main.c
index 70c1c3d..e5e4f33 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -1384,6 +1384,14 @@
}
core_config->allocator = Py_GETENV("PYTHONMALLOC");
+ /* -X options */
+ if (pymain_get_xoption(pymain, L"showrefcount")) {
+ core_config->show_ref_count = 1;
+ }
+ if (pymain_get_xoption(pymain, L"showalloccount")) {
+ core_config->show_alloc_count = 1;
+ }
+
/* More complex options: env var and/or -X option */
if (pymain_get_env_var("PYTHONFAULTHANDLER")
|| pymain_get_xoption(pymain, L"faulthandler")) {
@@ -1391,7 +1399,7 @@
}
if (pymain_get_env_var("PYTHONPROFILEIMPORTTIME")
|| pymain_get_xoption(pymain, L"importtime")) {
- core_config->importtime = 1;
+ core_config->import_time = 1;
}
if (pymain_init_tracemalloc(pymain) < 0) {
return -1;