8000 BUG: fix wrong error checks of PyBytes_AsStringAndSize by juliantaylor · Pull Request #5088 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: fix wrong error checks of PyBytes_AsStringAndSize #5088

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
Sep 19, 2014

Conversation

juliantaylor
Copy link
Contributor

The check in ufunc_type_resolution.c is broken due to a spurious not and
a few cases of TypeError being overwritten without clearing.
Also change all of these error checks to a negative check for
consistency.

@juliantaylor
Copy link
Contributor Author

rebased for backport

@charris
Copy link
Member
charris commented Sep 19, 2014

Certainly not wrong, but the < 0 check for negative error returns seems equally correct to me and is a common C construct.

@juliantaylor
Copy link
Contributor Author

its not wrong with current python, but the function is documented to return -1 not negative. As this type of error handling is so common its pretty much impossible python could change that but as I fixed one of them that was wrong my OCD forced me to fix all :)

@juliantaylor
Copy link
Contributor Author

currently numpy is half == -1 and half < 0, we alternatively could change all to < 0, that would make me happy too ;)

@charris
Copy link
Member
charris commented Sep 19, 2014

OCD is a common trait in programmers. It is a good thing :) I kind of like the < 0, but that may just be familiarity speaking. There are some numpy functions that can return various negative errors, so maybe <0 can be understood as any error and the == -1 as a specific error.

@juliantaylor juliantaylor force-pushed the not-fix branch from < 8000 a href="/numpy/numpy/commit/5df6ac7cea49b113d0c99fe1bdbda1b754f0610a" data-view-component="true" class="Link--primary Link text-bold">5df6ac7 to 2f74fce Compare September 19, 2014 22:24
The check in ufunc_type_resolution.c is broken due to a spurious not and
a few cases of TypeError being overwritten without clearing.
Also change all of these error checks to a negative check for
consistency.
@juliantaylor
Copy link
Contributor Author

changed all to < 0

charris added a commit that referenced this pull request Sep 19, 2014
BUG: fix wrong error checks of PyBytes_AsStringAndSize
@charris charris merged commit 2e3778a into numpy:master Sep 19, 2014
@charris
Copy link
Member
charris commented Sep 19, 2014

Looks good, thanks Julian.

juliantaylor added a commit that referenced this pull request Sep 24, 2014
BUG: fix wrong error checks of PyBytes_AsStringAndSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0