Porting to python3

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
looo
Posts: 2067
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Mon Jun 04, 2018 3:19 pm

I found a new problem:

Code: Select all

>>> from FreeCAD import Units
>>> Units.Quantity()
TypeError: function takes exactly 2 arguments (0 given)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
SystemError: <class 'Base.Quantity'> returned a result with an error set
I don't see something obvious: https://github.com/FreeCAD/FreeCAD/blob ... mp.cpp#L58
wmayer
Site Admin
Posts: 13284
Joined: Thu Feb 19, 2009 10:32 am

Re: Porting to python3

Postby wmayer » Mon Jun 04, 2018 3:48 pm

I don't see something obvious:
But I do. There is a missing call of PyErr_Clear.
git commit 9ec4d8368
looo
Posts: 2067
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Mon Jun 04, 2018 5:29 pm

looo
Posts: 2067
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Mon Jun 04, 2018 7:08 pm

thanks for merging. Here is another problem which I found by trying to open this file:
https://github.com/uncreatednet/wikilab ... wren.FCStd

Code: Select all

#0  /lib/x86_64-linux-gnu/libc.so.6(+0x354b0) [0x7f44de16d4b0]
#1  /lib/libpython3.6m.so.1.0(PyObject_GetAttrString+0x9) [0x7f44df94dbb9]
#2  0x7f44e0302e3f in App::PropertyPythonObject::Restore(Base::XMLReader&) from /work/lib/libFreeCADApp.so+0x60f
#3  0x7f44e02d9e7d in App::DynamicProperty::Restore(Base::XMLReader&) from /work/lib/libFreeCADApp.so+0x1ad
#4  0x7f44e0247087 in App::Document::readObjects(Base::XMLReader&) from /work/lib/libFreeCADApp.so+0x2d7
#5  0x7f44e024d633 in App::Document::Restore(Base::XMLReader&) from /work/lib/libFreeCADApp.so+0x1c3
#6  0x7f44e024ee5d in App::Document::restore() from /work/lib/libFreeCADApp.so+0x1dd
#7  0x7f44e032e023 in App::Application::openDocument(char const*) from /work/lib/libFreeCADApp.so+0x243
#8  0x7f44e0343a2c in App::Application::sOpenDocument(_object*, _object*, _object*) from /work/lib/libFreeCADApp.so+0x5c
If I copy the objects in the file to another document and open this file with py3 everything loads fine.
User avatar
sgrogan
Posts: 4563
Joined: Wed Oct 22, 2014 5:02 pm

Re: Porting to python3

Postby sgrogan » Mon Jun 04, 2018 9:21 pm

OS: Ubuntu 14.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.13905 (Git)
Build type: Unknown
Branch: master
Hash: e80b5678ccfa59a5222b91bdc7e748a53a468468
Python version: 3.4.3
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 7.3.0.beta
Locale: English/UnitedStates (en_US)

Code: Select all

Traceback (most recent call last):
  File "/usr/lib/python3.4/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/usr/lib/python3.4/unittest/case.py", line 577, in run
    testMethod()
  File "/home/sgrogan/freecad-py3-build/Mod/Test/TestPythonSyntax.py", line 44, in testAll
    test_python_syntax(mod_dir, self.whitelist)
  File "/home/sgrogan/freecad-py3-build/Mod/Test/TestPythonSyntax.py", line 27, in test_python_syntax
    raise RuntimeError("there are some files not parse-able with the used python-interpreter" + message)
RuntimeError: there are some files not parse-able with the used python-interpreter

##############################
2 python files are not parseable:

1 invalid syntax (/home/sgrogan/freecad-py3-build/Mod/Path/PathScripts/PathKurveUtils.py, line 164)
2 invalid syntax (/home/sgrogan/freecad-py3-build/Mod/Path/PathScripts/phillips_post.py, line 327)
looo
Posts: 2067
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Mon Jun 04, 2018 9:37 pm

sgrogan wrote: 1 invalid syntax (/home/sgrogan/freecad-py3-build/Mod/Path/PathScripts/PathKurveUtils.py, line 164)
2 invalid syntax (/home/sgrogan/freecad-py3-build/Mod/Path/PathScripts/phillips_post.py, line 327)
I think these files are not part of the current master.
User avatar
sgrogan
Posts: 4563
Joined: Wed Oct 22, 2014 5:02 pm

Re: Porting to python3

Postby sgrogan » Mon Jun 04, 2018 9:50 pm

looo wrote:
Mon Jun 04, 2018 9:37 pm
I think these files are not part of the current master.
Thanks looo, I did make clean, scratch build compiling now.

EDIT: scratch build all self-tests pass from the gui. Thanks all for the effort.
wmayer
Site Admin
Posts: 13284
Joined: Thu Feb 19, 2009 10:32 am

Re: Porting to python3

Postby wmayer » Sat Jun 09, 2018 1:57 pm

looo wrote:
Mon Jun 04, 2018 7:08 pm
thanks for merging. Here is another problem which I found by trying to open this file:
https://github.com/uncreatednet/wikilab ... wren.FCStd

Code: Select all

#0  /lib/x86_64-linux-gnu/libc.so.6(+0x354b0) [0x7f44de16d4b0]
#1  /lib/libpython3.6m.so.1.0(PyObject_GetAttrString+0x9) [0x7f44df94dbb9]
#2  0x7f44e0302e3f in App::PropertyPythonObject::Restore(Base::XMLReader&) from /work/lib/libFreeCADApp.so+0x60f
#3  0x7f44e02d9e7d in App::DynamicProperty::Restore(Base::XMLReader&) from /work/lib/libFreeCADApp.so+0x1ad
#4  0x7f44e0247087 in App::Document::readObjects(Base::XMLReader&) from /work/lib/libFreeCADApp.so+0x2d7
#5  0x7f44e024d633 in App::Document::Restore(Base::XMLReader&) from /work/lib/libFreeCADApp.so+0x1c3
#6  0x7f44e024ee5d in App::Document::restore() from /work/lib/libFreeCADApp.so+0x1dd
#7  0x7f44e032e023 in App::Application::openDocument(char const*) from /work/lib/libFreeCADApp.so+0x243
#8  0x7f44e0343a2c in App::Application::sOpenDocument(_object*, _object*, _object*) from /work/lib/libFreeCADApp.so+0x5c
If I copy the objects in the file to another document and open this file with py3 everything loads fine.
git commit cb1337674
User avatar
Kunda1
Posts: 3243
Joined: Thu Jan 05, 2017 9:03 pm

Re: Porting to python3

Postby Kunda1 » Mon Jun 11, 2018 12:32 am

Quick question: So this thread is pretty long, and therefore a little daunting to traverse to see if this question was already asked. Hence I apologize in advance if this was asked already: I'd like to know how volunteers could contribute to helping port FC to py3? (From finding bugs to actually developing)
Thanks
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
looo
Posts: 2067
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Mon Jun 11, 2018 2:42 am

Kunda1 wrote:
Mon Jun 11, 2018 12:32 am
Quick question: So this thread is pretty long, and therefore a little daunting to traverse to see if this question was already n,asked. Hence I apologize in advance if this was asked already: I'd like to know how volunteers could contribute to helping port FC to py3? (From finding bugs to actually developing)
Thanks
simple install freecad with python 3 and use it. most things will work but there are still some issues. If you find a problem, first try to solve it by your own and make a Pr, if this is not possible post the problem here in this topic so others can try to solve it.
if that also doesn't work, create a bugreport.

I guess currently the most problematic workbench is Path. Maybe trying to do a path-tutorial with a py3 build would be a good start.