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
Wrong argument in call of tp_new in SWIG_Python_NewShadowInstance for Python3 #1321
Comments
I think this makes sense. I'd like a way to replicate this though to commit with the fix. Could you provide a way to reproduce the assert? |
I think every call An example from LLDB project:
|
Mmm, I can't replicate this and I'm not convinced the patch is the best solution, it might be hiding a deeper problem. Can you give lots more info? Also which version of SWIG are you using? What the generated SBDebugger python class looks like will be helpful and exactly which lines of code in |
SWIG Version 3.0.12 SwigPyClientData_New executes these lines:
clientdata->pytype == NULL Then, in SWIG_Python_NewShadowInstance, in line
'((PyTypeObject*)data->newargs)->tp_new' points to Generated python:
|
What Python code are you running to cause the assertion? Something like creating an instance: Where is the assertion, can you give file and line info? Also as you have an assertion, this implies you are using a debug build of the python interpreter. I don't think assertions are normally turned on in the Python interpreter, so how did you build your interpreter? Are you using some sort of special build? I presume you are using Windows as you mention dlls? Is it the same on Linux? Looking at |
Yes, I use python_d on Windows, it is not a special build, just set debugging symbols and binaries option in installer settings. The change was not in object_new itself, call sequence looks like object_new -> excess_args -> PyTuple_GET_SIZE(args). And the last executes assert(PyTuple_Check) now. I have older version of python on linux, so cannot reproduce there. But the issue doesn't look OS-dependent. |
Okay, I can replicate with a debug build of the Python 3.7 interpreter. Patch makes sense to me now and I've applied it (had to make a few small changes though). |
It's good, thank you! |
Is there going to be a new release anytime soon or will I have to build my own SWIG from head to get the fix? |
I'm aiming to make the SWIG 4.0 release before the year is out. |
Since Python 3.7 tp_new parameter
args
must be a tuple (due to PyTuple_GET_SIZE performs assert(PyTuple_Check(args)); now).Few years ago Andreas Gäer had fixed this issue in his patch.
The text was updated successfully, but these errors were encountered: