[docs] [issue33932] Calling Py_Initialize() twice now triggers a fatal error (Python 3.7)

STINNER Victor report at bugs.python.org
Thu Jun 28 08:49:55 EDT 2018

STINNER Victor <vstinner at redhat.com> added the comment:

I looked quickly at _Py_InitializeCore() and I'm not sure that it's designed to replace an existing configuration.


int Py_HashRandomizationFlag = 0; /* for -R and PYTHONHASHSEED */


    if (!core_config->use_hash_seed || core_config->hash_seed) {
        /* Random or non-zero hash seed */
        Py_HashRandomizationFlag = 1;

If Py_Initialize() sets Py_HashRandomizationFlag to 1, but Py_Main() doesn't use an hash seed, Py_HashRandomizationFlag value remains 1 which is wrong.

pymain_read_conf() fills _PyCoreConfig from global configuration flags, but then global configuration flags are supposed to be set from the global configuration flags.

So maybe for this specific case, _Py_InitializeCore() should always set Py_HashRandomizationFlag. But it was just one example to show that right now, _Py_InitializeCore() doesn't seem to support to be called twice with two different configurations.


Python tracker <report at bugs.python.org>

More information about the docs mailing list