[New-bugs-announce] [issue31828] Support Py_tss_NEEDS_INIT outside of static initialisation

Stefan Behnel report at bugs.python.org
Fri Oct 20 12:07:56 EDT 2017

New submission from Stefan Behnel <stefan_ml at behnel.de>:

Following up on issue 25658, it was found that the current definition of Py_tss_NEEDS_INIT restricts its use to initialisers in C and cannot be used for arbitrary assignments. It is currently declared as follows:

    #define Py_tss_NEEDS_INIT   {0}

which results in a C compiler error for assignments like "x = Py_tss_NEEDS_INIT".

I proposed to change this to

    #define Py_tss_NEEDS_INIT   ((Py_tss_t) {0})

in compliance with GCC and C99, but that fails to compile in MSVC and probably other old C++-ish compilers.

I'm not sure how to improve this declaration, but given that it's a public header file, restricting its applicability seems really unfortunate.

components: Extension Modules, Interpreter Core
messages: 304661
nosy: masamoto, ncoghlan, scoder
priority: normal
pull_requests: 4031
severity: normal
status: open
title: Support Py_tss_NEEDS_INIT outside of static initialisation
type: enhancement
versions: Python 3.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list