-
-
Notifications
You must be signed in to change notification settings - Fork 11k
BUG: Incrementing the wrong reference on return #7308
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
Conversation
It almost never happens that you have NULL, NULL only happens for newly initialized arrays and then is interpreted as if it was the None object. Not sure if this is even easy to create such a NULLed array from python or any sane method at all to be honest. |
That makes sense, otherwise I imaging this would have been caught a very long time ago :) |
I thought |
You could try np.zeros as well. If neither works, maybe we can just merge without a test |
Sorry, I am just now beginning to figure out where things are in the C code. Could you please point me to the file that you want me to mess with? |
Uh, I was thinking of the simple python calls, but
But you can abuse ndarray:
note that while |
And yeah, that |
Just to be clear, all I would like is a short test for these two NULL cases, since it seems pretty easy to do (and if it ever breaks because we change mp.ndarray, so be it). |
I understand. I just need to dig around a little more. All the tests I tried to construct in Python ended up returning None instead of NULL. |
@madphysicist as I said: |
|
This is already suspicious. I put in a bunch of print statements to make sure I knew which branch is being taken. I tried three cases:
The case we want is never triggered. This is pretty much to be expected given the initial printout. As I mentioned before, I am just starting out with the C API. I will keep this PR in mind as I keep going and will add tests if I see a good way to do so. |
This is creating an array of nulls -- it's just that we map null pointers to None when going from C to Python. To convince yourself:
|
I have two theories why it does not work:
|
I am sure it's not #1 since I put a bunch of |
I the meantime, since the |
Yes, fine. If you still find something, we can put it in later, nothing to dabble about now I guess, in the end maybe that whole NULL == None logic is maybe just some weird historic stuff. Thanks. |
BUG: Incrementing the wrong reference on return
How did this work before? If
i2
isNULL
,Py_INCREF
will generally crash. That pretty much means that this branch was never excercised in a test or elsewhere?