-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Regression: generated Python functions return a list instead of a single value #3084
Comments
It looks like the detection of whether the function is BTW, do |
There are other functions in the C lib which use a pointer to a PTError struct as an argument.
This is obviously a copy/paste error. It's a duplicate. |
Hmm. In this case, I'd have to move the the error handling logic into a higher level Python API which looks at the returned list, pop the first element from it and raise an exception if it's not Or remove SWIG from the build completely, and find a different solution using |
FWIW you should be do this at SWIG level with |
@vadz Thanks, so at least the workaround code can be saved where it belongs. |
Just for information, my workaround code looks like this:
|
I've encountered the same issue while building Python bindings of Subversion 1.14.4 with SWIG 4.3.0. Example:
with the following typemaps:
As a workaround, the following changed:
|
@hvbtup, some guess work is required with what you've provided, as how https://github.com/swig/swig/blob/8fd4df01bd4111e5f7322fe4f9d4817ffd6f0c6d/CHANGES#L377-L397 so call |
@wsfulton I don't understand your answer. In the description I showed the relevant code. As you can see, I did not use |
I use swig 4.3.0 to generate Python wrappers for a C library.
For example, one of the C functions is defined as
PTError is defined as
And I am using the following in the *.i file:
With SWIG 4.1.0, calling the function
PBMGetLevel(bmh)
in Python returned a single integer-1
.With SWIG 4.3.0, this now returns a list with two elements:
[None, -1]
.The same happens for all functions in the C lib:
Instead of just the expected, they return a list containing None and the expected value.
I think that this issue is a consequence of the fix for #2905.
Comparing the C code generated with SWIG 4.1.0 and SWIG 4.3.0, it looks like this:
The additional argument 0 is given to the SWIG_Python_AppendOutput function.
Is this a bug in SWIG?
If not, what can I do in the *.i file to get the same behavior as in 4.1.0?
The text was updated successfully, but these errors were encountered: