Forwarding from the Pandas bug: pandas-dev/pandas#41935 (and I had also opened a Python one, but right now cython seems a more likely candidate): https://bugs.python.org/issue46451
There is an issue that calling back into Python from a Cython function can mutate module globals if the module global is a default argument (possibly not only then) and tracing is enabled and this is running on Python 3.10 (I think I confirmed for Cython 3.0 alpha as well). The repro is as easy as:
import mod
def cyfunc(arg):
mod.function(arg)
with mod.py:
mod_global = "something"
def function(arg, mod_global=None):
if mod_global is None: # probably not necessary
mod_global = arg
I have a functioning reproducer at: https://github.com/seberg/bpo46451 importing bpo46451 will run the function and tracing will start printing None instead of the correct "this is a mod global".
I suspect this happens here: https://github.com/cython/cython/blob/master/Cython/Utility/ObjectHandling.c#L2569-L2611
Forwarding from the Pandas bug: pandas-dev/pandas#41935 (and I had also opened a Python one, but right now cython seems a more likely candidate): https://bugs.python.org/issue46451
There is an issue that calling back into Python from a Cython function can mutate module globals if the module global is a default argument (possibly not only then) and tracing is enabled and this is running on Python 3.10 (I think I confirmed for Cython 3.0 alpha as well). The repro is as easy as:
with
mod.py:I have a functioning reproducer at: https://github.com/seberg/bpo46451 importing
bpo46451will run the function and tracing will start printingNoneinstead of the correct"this is a mod global".I suspect this happens here: https://github.com/cython/cython/blob/master/Cython/Utility/ObjectHandling.c#L2569-L2611