Nick Coghlan <[email protected]> added the comment:
Right, the cases we were aiming to cover were:
- C variable declarations ("static Py_tss_t tss_key = Py_tss_NEEDS_INIT;")
- dynamic allocation with PyThread_tss_alloc
- resetting a key back to the uninitialised state with PyThread_tss_delete
The problem we have is that the second field in Py_tss_t is platform dependent,
and not all platforms define a safe "unused" value for their NATIVE_TSS_KEY_T,
which means Py_tss_NEEDS_INIT ends up being only a partial initialiser (earlier
versions of the PEP used a field initialiser, but we were asked to switch it to
a partial initialiser in order to support more compilers).
We *could* offer a `PyThread_tss_reset` (to reset a key back to
Py_tss_NEEDS_INIT), but that's confusingly similar to PyThread_tss_delete.
Another option would be to check for typed partial initialiser support in the
configure script, and declare Py_tss_NEEDS_INIT accordingly. However, that
wouldn't solve the problem for any clients that are themselves also attempting
to write cross-platform code.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue31828>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com