Skip to content
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

objToJSON nonvoid function does not return a value #5326

Closed
toddrme2178 opened this issue Oct 25, 2013 · 10 comments · Fixed by #5334
Closed

objToJSON nonvoid function does not return a value #5326

toddrme2178 opened this issue Oct 25, 2013 · 10 comments · Fixed by #5334

Comments

@toddrme2178
Copy link

I am trying to package pandas 0.12.0 for openSUSE with python 3 the build fails with the following error:

E: python3-pandas no-return-in-nonvoid-function pandas/src/ujson/python/objToJSON.c:166

I think this may be related to pull request #3874, where the return type was changed to int but the rest of the function remains the same, so no int was actually returned.

@jreback
Copy link
Contributor

jreback commented Oct 25, 2013

@Komnomnomnom

we can't do anything for 0.12, but for 0.13?

@jtratner
Copy link
Contributor

Linked issue says that the import_arrays macro causes a return to be
inserted. Maybe there's an incorrect interaction between the compiler and
other components. I'm skeptical that the build error here is pandas' fault,
given that we build on Python 3 with every test, presumably @yaritkoptic
also builds on python 3 and statsmodels has been building against pandas on
Python 3 too, and we haven't heard anything about this.

@toddrme2178
Copy link
Author

On Fri, Oct 25, 2013 at 11:01 PM, Jeff Tratner notifications@github.comwrote:

Linked issue says that the import_arrays macro causes a return to be
inserted. Maybe there's an incorrect interaction between the compiler and
other components. I'm skeptical that the build error here is pandas' fault,
given that we build on Python 3 with every test, presumably @yaritkoptic
also builds on python 3 and statsmodels has been building against pandas on
Python 3 too, and we haven't heard anything about this.

This is a post-build check implemented in openSUSE's build system. It is a
valid problem though, a non-void function should return something. It
doesn't have to be anything useful.

There is also a compile warning regarding this:

pandas/src/ujson/python/objToJSON.c:166:1: warning: control reaches
end of non-void function [-Wreturn-type]

@jtratner
Copy link
Contributor

Okay, that's helpful context - I thought you were saying it refused to compile. I think the idea from the other PR was that there was an import_arrays() macro that magically inserted a return value...

@jtratner
Copy link
Contributor

I just pushed a branch that should fix this warning for both the compile check and for clang, I'm still not totally clear, but I'll put up a PR and wait for @cpcloud or @Komnomnomnom to comment.

@jtratner
Copy link
Contributor

But the problem is that when you do that, get the opposite error from gcc about returning void from function with int, b/c of issues with what import_array() expands to...

@jtratner
Copy link
Contributor

pandas/src/ujson/python/objToJSON.c: In function ‘initObjToJSON’:
pandas/src/ujson/python/objToJSON.c:176: warning: ‘return’ with no value, in function returning non-void

So I'm not sure where the right direction is with this (line numbers are 10 off b/c of versioning)

@jtratner
Copy link
Contributor

And here's the macro definition:

#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NUMPY_IMPORT_ARRAY_RETVAL; } }

And this is the definition of the retval:

#if PY_VERSION_HEX >= 0x03000000
#define NUMPY_IMPORT_ARRAY_RETVAL NULL
#else
#define NUMPY_IMPORT_ARRAY_RETVAL
#endif

So there's the problem. Maybe this is different in different versions of numpy?

@jreback
Copy link
Contributor

jreback commented Oct 25, 2013

@jratner this needs testing in windows
I think that was why it wS changed in first place

@jtratner
Copy link
Contributor

@toddrme2178 I looked at it again and the compiler's right (obviously!) in the case where it doesn't raise an error, you still get to the end of the function. I changed the function to return the same import array retval right afterwards, so that the function signature is always correct. Certainly a little bit clunky - I think functions are supposed to return different things if they can raise exceptions in Python 2 and Python 3?

Anyways, I have a PR up, please take a look.

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 a pull request may close this issue.

3 participants