[issue32096] Py_DecodeLocale() fails if used before the runtime is initialized.

Eric Snow report at bugs.python.org
Tue Nov 21 10:46:14 EST 2017


Eric Snow <ericsnowcurrently at gmail.com> added the comment:

I see at least 3 ways to sort this out:

 1. partially revert the _PyRuntime change, sort of temporarily
   ("revert the change on memory allocators, and retry later to fix
   it, once other initializations issues are fixed", as suggested by
   Victor in the email thread)
 2. statically initialize the "raw" allocator with defaults, enough
   to make PyMem_RawMalloc() and PyMem_RawFree() work pre-init (this
   is what my PR does)
 3. use hard-coded defaults in PyMem_RawMalloc() and PyMem_RawFree()
   if the runtime has not been initialized yet

I considered implementing #3 instead, but wasn't sure about the performance impact.  It would add a pointer comparison to NULL and a branch on each PyMem_RawMalloc() and PyMem_RawFree() call.  I'm not convinved it would make much of a difference.  Furthermore, I consider #3 to be the simplest solution, both to implement and to maintain, so I'll probably try it out.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32096>
_______________________________________


More information about the Python-bugs-list mailing list