[solved] python3 exception

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

[solved] python3 exception

Post by looo »

I need some help with exceptions in python3. When a workbench or command fails the traceback is always "unknown".
<unknown exception traceback>
Searching for this in the source gives this result: https://github.com/FreeCAD/FreeCAD/blob ... ols.c#L281
So the unknown traceback is caused by the traceback variable being NULL.

the function PyError_Fetch looks the same for python2 and 3
https://docs.python.org/3/c-api/excepti ... yErr_Fetch
https://docs.python.org/2/c-api/excepti ... yErr_Fetch
Last edited by looo on Mon Feb 13, 2017 3:16 pm, edited 1 time in total.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: python3 exception

Post by looo »

I think I have found: there is no StringIO in python3
User avatar
yorik
Founder
Posts: 13660
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: [solved] python3 exception

Post by yorik »

looo wrote:I think I have found: there is no StringIO in python3
I think we found a workaround for that somewhere in the py3 branch..
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: [solved] python3 exception

Post by looo »

yes, solution is: StringIO.StringIO (py2) -> io.StringIO (py3)
Post Reply