diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-07-25 19:23:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-25 19:23:53 +0200 |
commit | 60b04c9f6fb87522a62ab6b95db9f8a09aef42d4 (patch) | |
tree | aaceeb9975ea792eb997e6c6904d5d4e23da10c8 /Modules/main.c | |
parent | 96d1e69a12ed8ab80203277e1abdaf573457a964 (diff) | |
download | cpython-git-60b04c9f6fb87522a62ab6b95db9f8a09aef42d4.tar.gz |
bpo-34228: Allow PYTHONTRACEMALLOC=0 (GH-8467)
PYTHONTRACEMALLOC=0 environment variable and -X tracemalloc=0 command
line option are now allowed to disable explicitly tracemalloc at
startup.
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Modules/main.c b/Modules/main.c index a16c340191..e116dd0765 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -1726,10 +1726,14 @@ pymain_init_tracemalloc(_PyCoreConfig *config) int nframe; int valid; + if (config->tracemalloc >= 0) { + return _Py_INIT_OK(); + } + const char *env = config_get_env_var(config, "PYTHONTRACEMALLOC"); if (env) { if (!pymain_str_to_int(env, &nframe)) { - valid = (nframe >= 1); + valid = (nframe >= 0); } else { valid = 0; @@ -1746,7 +1750,7 @@ pymain_init_tracemalloc(_PyCoreConfig *config) const wchar_t *sep = wcschr(xoption, L'='); if (sep) { if (!pymain_wstr_to_int(sep + 1, &nframe)) { - valid = (nframe >= 1); + valid = (nframe >= 0); } else { valid = 0; @@ -2249,17 +2253,22 @@ _PyCoreConfig_Read(_PyCoreConfig *config) config_init_locale(config); - /* Signal handlers are installed by default */ - if (config->install_signal_handlers < 0) { - config->install_signal_handlers = 1; - } - if (config->_install_importlib) { err = _PyCoreConfig_InitPathConfig(config); if (_Py_INIT_FAILED(err)) { return err; } } + + /* default values */ + if (config->tracemalloc < 0) { + config->tracemalloc = 0; + } + if (config->install_signal_handlers < 0) { + /* Signal handlers are installed by default */ + config->install_signal_handlers = 1; + } + return _Py_INIT_OK(); } |