bpo-34170: Enhance _PyCoreConfig_Read() (GH-8468)
* Inline cmdline_get_env_flags() into config_read_env_vars():
_PyCoreConfig_Read() now reads much more environment variables like
PYTHONVERBOSE.
* Allow to override faulthandler and allocator even if dev_mode=1.
PYTHONMALLOC is now the priority over PYTHONDEVMODE.
* Fix _PyCoreConfig_Copy(): copy also install_signal_handlers,
coerce_c_locale and coerce_c_locale_warn
* _PyCoreConfig.install_signal_handlers default is now 1: install
signals by default
* Fix also a compiler warning: don't define _PyPathConfig type twice.
diff --git a/Include/pystate.h b/Include/pystate.h
index 2c70505..f59d26b 100644
--- a/Include/pystate.h
+++ b/Include/pystate.h
@@ -26,15 +26,23 @@
typedef struct {
- int install_signal_handlers; /* Install signal handlers? -1 means unset */
+ /* Install signal handlers? Yes by default. */
+ int install_signal_handlers;
int ignore_environment; /* -E, Py_IgnoreEnvironmentFlag, -1 means unset */
int use_hash_seed; /* PYTHONHASHSEED=x */
unsigned long hash_seed;
- const char *allocator; /* Memory allocator: _PyMem_SetupAllocators() */
+ const char *allocator; /* Memory allocator: PYTHONMALLOC */
int dev_mode; /* PYTHONDEVMODE, -X dev */
- int faulthandler; /* PYTHONFAULTHANDLER, -X faulthandler */
- int tracemalloc; /* PYTHONTRACEMALLOC, -X tracemalloc=N */
+
+ /* Enable faulthandler?
+ Set to 1 by -X faulthandler and PYTHONFAULTHANDLER. -1 means unset. */
+ int faulthandler;
+
+ /* Enable tracemalloc?
+ Set by -X tracemalloc=N and PYTHONTRACEMALLOC. -1 means unset */
+ int tracemalloc;
+
int import_time; /* PYTHONPROFILEIMPORTTIME, -X importtime */
int show_ref_count; /* -X showrefcount */
int show_alloc_count; /* -X showalloccount */
@@ -229,9 +237,10 @@
#define _PyCoreConfig_INIT \
(_PyCoreConfig){ \
- .install_signal_handlers = -1, \
+ .install_signal_handlers = 1, \
.ignore_environment = -1, \
.use_hash_seed = -1, \
+ .faulthandler = -1, \
.tracemalloc = -1, \
.coerce_c_locale = -1, \
.utf8_mode = -1, \