Skip to content

BUG: ensure extobj and axes have their own references. #11257

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

Merged
merged 1 commit into from
Jun 6, 2018

Conversation

mhvk
Copy link
Contributor

@mhvk mhvk commented Jun 6, 2018

Alternative to #11244, where get_ufunc_arguments just ensures any object from the kwargs has its own reference. Must say I like this better.

@@ -555,8 +555,9 @@ ufunc_get_name_cstr(PyUFuncObject *ufunc) {
* Parses the positional and keyword arguments for a generic ufunc call.
*
* Note that if an error is returned, the caller must free the
* non-zero references in out_op. This
* function does not do its own clean-up.
* non-zero references in out_op. This function does not do its own clean-up.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to change it so it does this too, but I suppose there's no need for that to be part of this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I thought about that too, and am happy to do a follow-up PR for that; there is no reason not to clean up.

@@ -36,6 +36,10 @@ def test_sig_dtype(self):
assert_raises(RuntimeError, np.add, 1, 2, signature='ii->i',
dtype=int)

def test_extobj_refcount(self):
# Should not segfault with USE_DEBUG.
assert_raises(TypeError, np.add, 1, 2, extobj=[4096], parrot=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invalid_keyword_arg would be a little clearer than parrot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I finally got a Monty-Python reference in!

@eric-wieser
Copy link
Member

Yep, this looks pretty straightforward to me. One nit, that you can choose to ignore

@mhvk mhvk merged commit 9a4d75d into numpy:master Jun 6, 2018
@mhvk mhvk deleted the ufunc-parsing-no-borrowed-refs branch June 6, 2018 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants