New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Cython and Py 3.10 have create issues when debugging #21008
Comments
Seems weird, but two questions:
There is some weird issue with 3.10 + Cython + trancing (i.e. Pythons profiling/debugging hook). I think the Cython re-release fixes it, but unless your project is the Cython component that might be hard to use. And this looks a lot like that weird issue (pandas runs into it if you debug/profile) due to callbacks from pandas to NumPy (python): pandas-dev/pandas#41935 |
Thanks for the quick response! numeric.dtype=<class 'numpy.dtype'>
type(numeric.dtype)=<class 'numpy._DTypeMeta'> to numeric.dtype=<class 'numpy.uint64'>
type(numeric.dtype)=<class 'type'> around some random sampling using numpy's SFC64 BitGenerator. |
Thanks, so the underlying issue seems in Cython due to Python changes and fixed in Cythons the upcoming release. I guess workarounds in NumPy may be possible for the specific symptoms, right now I would hope that Cython can fix and we can regenerate As soon as there is a Cython fix available, we need to pin against that maybe... |
I'd be happy to help with testing any new versions :) |
No tests needed, the only question is probably whether we should make sure to include the workaround from the Cython issue in the next NumPy release (there is an option to disable the faulty code-paths, although that might add some slight overheads). |
I see. That I would leave to the numpy devs. |
The quick fix (until the next cython release) is to do:
This may slow down some things in random slightly. The other option is to wait for the next release or to just use the alpha version. |
|
I am a bit surprised, so to note that this is a C define I believe, and not an environment variable. So use would probably look like: (EDIT: Also, this is at compile time of course) |
I see, sorry. Misunderstood that one. In that case it might work, but I didn't try it. |
@seberg What do you think we should do for 1.,22.4? Looks like Cython isn't going to fix it. |
I don't think there is anything we can do besides using |
Should we do that for the Wheels? I think that can be done for the docker images through |
We could measure the performance change when using CFLAGS="-DCYTHON_FAST_PYCALL=0" for cython-compiled code. Maybe we should try to have a discussion with @scoder about what the path forward should be. CPython 3.11 is just around the corner: do we continue with Cython0.29? Do we encourage use of Cython3? |
Hmm. We will need to do that eventually, I guess the question is, is it ready. |
I would be happy if we just tried out the alpha even. But I am unsure we should do so in a point release. Looking at the performance impact for an example function that use a lot of Python calls back to NumPy (or simliar) would maybe be best to get an idea if just disabling it is even noticable in practice. |
The largest remaining open question for Cython 3 is really what we do with cython/cython#4280 (letting C functions propagate exceptions by default). That's a tough call. We have been trying hard to keep the transition easy for users and to avoid breaking existing code wherever possible. But that's a very tempting property, and Cython 3 is the right time to make that change. |
Thanks for fixing it in cython/cython#4735 on the cython side. So it would be nice to publish the next wheels in a way that ensures this is used. |
I am running in the same issue and it really troubles me right now. This is not the first time these days, kicking in the debugger changed the behaviour of the program itself. Had a similar thing going on with the This makes me question why and how a debugger changes the behaviour of the program? Somehow this seems broken. |
Hmm. I'm going to delay 1.22.4 a while in the hope that Cython makes a new release soon so that we can fix this. |
I just wanted to report that cython 0.29.29 was released yesterday |
Cython 0.29.30 is out and merged for the upcoming 1.22.4, so this should be fixed. If the problem persists feel free to reopen. |
@charris I don't have Cython installed and I get the error It still occurs with 1.22.4. Reference Jetbrains issue: https://youtrack.jetbrains.com/issue/PY-52137
|
Have the same issue. Still get TypeError: 'NoneType' object is not callable Out of the box i hadn't cython installed. |
To add a (maybe important) observation. The bug seems to be fixed when calling things from the main-loop. But when using threads (I'm using Qt Threads), the bug still persists |
The bug is related with tracing (debugging/profiling) and not threads I think. In any case, NumPy being fixed is not really much help because in most cases this is triggered by pandas or someone else. |
Yeah, you're right. It wasn't related to the threads. But to the order how stuff is loaded The following code causes the error:
The following code is fine:
Just the order of when scipy is imported is different. The combination of libraries makes this really difficult. At a different point the application fails when triggering sklearn. But when only running the code that uses sklearn in unittest, I can debug. |
@NeanderThaler if you think this is the problem, I would suggest you just solve it by applying patience: wait a week or two and upgrade all of the packages that may be affected. Beyond that, the only thing you can do easily is avoid "tracing". If |
Describe the issue:
I'm experiencing some inconsistent behavior for
np.dtype
andnp.iinfo
. From within some code I cannot share here, I run the snippet below which fails with a TypeError (details also below). If I simply execute a main in which I call this function directly, it works however. Since I have a call stack of about 10 levels in the error case, I don't know, where exactly the difference is caused. If someone knows a way of easily and quickly isolating this issue, I'm happy to apply it.The same code does not yield an error, if run in Python 3.8.5 and numpy 1.19.5. It does occur in python 3.10 and numpy versions 1.21.2, 1.22.0, 1.22.1, and 1.22.2.
Reproduce the code example:
Error message:
NumPy/Python version information:
1.21.2 3.10.0 (default, Dec 7 2021, 09:05:11) [Clang 12.0.5 (clang-1205.0.22.9)]
The text was updated successfully, but these errors were encountered: