[refixed] #3569 Py3 Bug. Editor for App::PropertyStringList feeds py3-incompatible code to interpreter

Need help, or want to share a macro? Post here!
User avatar
DeepSOIC
Posts: 7477
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

[refixed] #3569 Py3 Bug. Editor for App::PropertyStringList feeds py3-incompatible code to interpreter

Postby DeepSOIC » Thu Aug 23, 2018 1:23 pm

1. Run this code:

Code: Select all

App.newDocument()
f = App.ActiveDocument.addObject('App::FeaturePython')
f.addProperty('App::PropertyStringList', 'TestProp')
2. select the object in tree, and edit 'TestProp' property. Click OK.
-> error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
<class 'NameError'>: name 'unicode' is not defined
Stack Trace: Traceback (most recent call last):
File "<string>", line 1, in <module>


OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.Unknown
Build type: Release
Python version: 3.6.5
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: Russian/Russia (ru_RU)
Last edited by DeepSOIC on Mon Sep 03, 2018 8:32 pm, edited 5 times in total.
User avatar
DeepSOIC
Posts: 7477
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: [Py3] Bug. Editor for App::PropertyStringList feeds py3-incompatible code to interpreter

Postby DeepSOIC » Thu Aug 23, 2018 1:56 pm

looo wrote:summoning Py3 master!
User avatar
DeepSOIC
Posts: 7477
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: [Py3] Bug. Editor for App::PropertyStringList feeds py3-incompatible code to interpreter

Postby DeepSOIC » Thu Aug 23, 2018 2:06 pm

Also, searching for "unicode(" in freecad source, I get a few more suspicious places in drawing, openscad, material, ...
User avatar
DeepSOIC
Posts: 7477
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: [Py3] Bug. Editor for App::PropertyStringList feeds py3-incompatible code to interpreter

Postby DeepSOIC » Thu Aug 23, 2018 3:49 pm

wmayer wrote:
Thu Aug 23, 2018 3:47 pm
git commit 24579fff3
Wow, quick! Thanks!
User avatar
DeepSOIC
Posts: 7477
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: [fixed] Py3 Bug. Editor for App::PropertyStringList feeds py3-incompatible code to interpreter

Postby DeepSOIC » Sun Sep 02, 2018 2:37 pm

I'm not sure if it is a consequence, but I recently got a bug report for Lattice2 concerning propertystringlist again.
https://github.com/DeepSOIC/Lattice2/issues/24
TheMarkster
Posts: 1185
Joined: Thu Apr 05, 2018 1:53 am

Re: [fixed] Py3 Bug. Editor for App::PropertyStringList feeds py3-incompatible code to interpreter

Postby TheMarkster » Sun Sep 02, 2018 6:36 pm

DeepSOIC wrote:
Sun Sep 02, 2018 2:37 pm
I'm not sure if it is a consequence, but I recently got a bug report for Lattice2 concerning propertystringlist again.
https://github.com/DeepSOIC/Lattice2/issues/24
Looks like it needs commas inserted:

Code: Select all

>>> FreeCAD.getDocument("lattice_manual_arrays").getObject("LinearArray002").Values = [u"0"u"0.14952381"u"0.299047619"u"0.448571429"u"0.598095238"u"0.747619048"u"0.897142857"u"1.046666667"u"1.196190476"u"1.345714286"u"1.495238095"u"1.644761905"u"1.794285714"u"1.943809524"u"2.093333333"u"2.242857143"u"2.392380952"u"2.541904762"u"2.691428571"u"2.840952381"u"2.99047619"u"3.14"u"3.28952381"u"3.439047619"u"3.588571429"u"3.738095238"u"3.887619048"u"4.037142857"u"4.186666667"u"4.336190476"u"4.485714286"u"4.635238095"u"4.784761905"u"4.934285714"u"5.083809524"u"5.233333333"u"5.382857143"u"5.532380952"u"5.681904762"u"5.831428571"u"5.980952381"u"6.13047619"u"6.28"]

Code: Select all

\FreeCAD\Mod\lattice2\lattice2LinearArray.py", line 154, in derivedExecute
    values = [float(strv) for strv in obj.Values]
  File "C:\Users\mwganson\AppData\Roaming\FreeCAD\Mod\lattice2\lattice2LinearArray.py", line 154, in <listcomp>
    values = [float(strv) for strv in obj.Values]
<class 'ValueError'>: could not convert string to float: '00.149523810.2990476190.4485714290.5980952380.7476190480.8971428571.0466666671.1961904761.3457142861.4952380951.6447619051.7942857141.9438095242.0933333332.2428571432.3923809522.5419047622.6914285712.8409523812.990476193.143.289523813.4390476193.5885714293.7380952383.8876190484.0371428574.1866666674.3361904764.4857142864.6352380954.7847619054.9342857145.0838095245.2333333335.3828571435.5323809525.6819047625.8314285715.9809523816.130476196.28'
Values as they appear in the data tab:

Code: Select all

[0,0.14952381,0.299047619,0.448571429,0.598095238,0.747619048,0.897142857,1.046666667,1.196190476,1.345714286,1.495238095,1.644761905,1.794285714,1.943809524,2.093333333,2.242857143,2.392380952,2.541904762,2.691428571,2.840952381,2.99047619,3.14,3.28952381,3.439047619,3.588571429,3.738095238,3.887619048,4.037142857,4.186666667,4.336190476,4.485714286,4.635238095,4.784761905,4.934285714,5.083809524,5.233333333,5.382857143,5.532380952,5.681904762,5.831428571,5.980952381,6.13047619,6.28]
Edit: last code section was from wrong object property, fixed.
My FreeCAD video series on youtube: https://www.youtube.com/playlist?list=P ... GEBlLshYGa
User avatar
DeepSOIC
Posts: 7477
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: [reopened] Py3 Bug. Editor for App::PropertyStringList feeds py3-incompatible code to interpreter

Postby DeepSOIC » Mon Sep 03, 2018 5:27 pm

confirmed, see TheMarkster's post above. Both Py2 and Py3 versions are broken.

EDIT: linking in tracker ticket: issue #3569