Porting to python3

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!
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

peterl94 wrote: Thu Jan 03, 2019 6:39 am Found the problem. Not sure why it is not a problem for other platforms.
I think linux uses utf8 by default.

Checking the last-circle (osx) build I found this leftover-patch:

Code: Select all

Applying patch: '/Users/distiller/test/recipe/win_unicode.patch'
patching file src/Mod/Test/TestPythonSyntax.py
Which basically add some additional files to the whitelist. But I guess with your fix this is solved now and the patch can be removed. Also we should try to remove the whitelist. I never understood why some files where not parse-able on windows, so I added this whitelist. But maybe now it's possible to parse them all...
User avatar
dcapeletti
Posts: 504
Joined: Wed Jul 23, 2014 2:27 pm

Re: Porting to python3

Post by dcapeletti »

When I started freecad I got the following error:

Code: Select all

'ascii' codec can't decode byte 0xc3 in position 9036: ordinal not in range(128)
I think it appears because the home page has an accent in Spanish and does not decipher the character well.

OS: Debian GNU/Linux 9.6 (stretch)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15513 (Git) AppImage
Build type: Release
Branch: master
Hash: 42e6650ac0e6c6e53ebb7f2bb83a07a555ea51b0
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Spanish/Argentina (es_AR)
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Porting to python3

Post by NormandC »

This has already been fixed, your AppImage is almost 40 commits behind master.

Edit: also, you're not even using Python 3, which this topic is about.
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: Porting to python3

Post by Syres »

Clicking on a macro for example FCStairs or FCCircularText (both of which have an alternative storage url due to their size) in the AddOnManager > Macros tab using:

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15536 (Git)
Build type: Release
Branch: master
Hash: 98ebeaa198df945ba666c15912c6caf95920f0ef
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)

results in the following output in Report View:

Code: Select all

Traceback (most recent call last):
  File "E:\Data\FreeCAD_0.18.15536_Conda_Py3QT5-WinVS2015_x64\FreeCAD_0.18.15536_Conda_Py3QT5-WinVS2015_x64\Mod\AddonManager\AddonManager.py", line 815, in run
    self.macro.fill_details_from_wiki(url)
  File "E:\Data\FreeCAD_0.18.15536_Conda_Py3QT5-WinVS2015_x64\FreeCAD_0.18.15536_Conda_Py3QT5-WinVS2015_x64\Mod\AddonManager\addonmanager_macro.py", line 124, in fill_details_from_wiki
    response += data
TypeError: must be str, not bytes
After some testing back and forth in both Py3Qt5 and Py2Qt4, I propose the change as per https://forum.freecadweb.org/viewtopic. ... 10#p278156

If I'm looking at this from the wrong angle and the macro authors need to amend their side then please let me know.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

Syres wrote: Sat Jan 05, 2019 1:09 pm After some testing back and forth in both Py3Qt5 and Py2Qt4, I propose the change as per
Thanks for reporting: https://github.com/FreeCAD/FreeCAD/pull/1893

Btw. creating a PR on github is really easy. If you have an account it is up to browsing to the file clicking the edit symbol, make changes and propose via PR. In case you find any other issues like this one.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Porting to python3

Post by bernd »

Qtgui import problem on Python3 ... https://forum.freecadweb.org/viewtopic.php?f=4&t=33252
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

Exporting as .obj file:

Code: Select all

Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/home/lo/conda/envs/dakota/Mod/Arch/importOBJ.py", line 159, in export
    vlist,elist,flist = getIndices(obj.Shape,offset)
  File "/home/lo/conda/envs/dakota/Mod/Arch/importOBJ.py", line 71, in getIndices
    FreeCAD.Console.PrintWarning(translate("Arch","Found a shape containing curves, triangulating").decode('utf8')+"\n")
<class 'AttributeError'>: 'str' object has no attribute 'decode'
wmayer
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Porting to python3

Post by wmayer »

looo wrote: Tue Jan 08, 2019 9:29 am Exporting as .obj file:

Code: Select all

Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/home/lo/conda/envs/dakota/Mod/Arch/importOBJ.py", line 159, in export
    vlist,elist,flist = getIndices(obj.Shape,offset)
  File "/home/lo/conda/envs/dakota/Mod/Arch/importOBJ.py", line 71, in getIndices
    FreeCAD.Console.PrintWarning(translate("Arch","Found a shape containing curves, triangulating").decode('utf8')+"\n")
<class 'AttributeError'>: 'str' object has no attribute 'decode'
Fixed with: git commit 1ebcb3654
This is also wrong for Py2 because translate() returns a unicode object which raises an error for invalid characters (like umlauts because they are not encoded there). Looks like in the past it returned a bytes object.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

thanks.
ztirffritz
Posts: 2
Joined: Mon Dec 17, 2018 4:24 am
Location: Yakima WA
Contact:

Re: Porting to python3

Post by ztirffritz »

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15609 (Git)
Build type: Release
Branch: master
Hash: a14af0f2bd26f980d71be80a799ee48127bc7619
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)


I tried opening this version today and found all the file preview images are missing. It's just a "?" in place of the file preview. I'm obviously a FreeCAD newb, so forgive me if this is already reported or addressed elsewhere.
Good is the enemy of Excellent. Talent is not necessary for Excellence.
Persistence is necessary for Excellence. And Persistence is a Decision.
Post Reply