View Issue Details

IDProjectCategoryView StatusLast Update
0003569FreeCADBugpublic2020-09-02 11:19
ReporterTheMarkster Assigned Towmayer  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionreopened 
Product Version0.18 
Fixed in Version0.18 
Summary0003569: App::PropertyStringList not python3 ready
DescriptionFeature python objects containing a property of type App::PropertyStringList do not work in Python3. When attempting to modify this property you get this error in the report view:

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>

See this post on the forum: https://forum.freecadweb.org/viewtopic.php?f=3&t=7598&p=252150#p251960
and
https://forum.freecadweb.org/viewtopic.php?f=22&t=30462
Steps To ReproduceYou need to be running a python3 build.
Run this macro (see attached TestClass.py file) to create a simple feature python object named TestObject:

import FreeCAD
from PySide import QtGui,QtCore

class TestClass:
    def __init__(self, obj):
        obj.Proxy = self

   
    def onChanged(self, fp, prop):
        '''Do something when a property has changed'''

        FreeCAD.Console.PrintMessage("Change property: " + str(prop) + "\n")
 
 
    def execute(self, fp):
        '''Do something when doing a recomputation, this method is mandatory'''
        pass


test=FreeCAD.ActiveDocument.addObject("App::FeaturePython","TestObject")
TestClass(test)

test.addProperty("App::PropertyStringList","propertyStringList")

Select the "propertyStringList" property in the data tab of the property view after selecting the TestObject object in the tree view. Click the 3 dots ... and enter some lines of text and press OK. You will get the error message and the property will not get updated.
Additional InformationOS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.14426 (Git)
Build type: Release
Branch: master
Hash: 3927a2ed8b009ab4dfdca53fbebf0060193b67b4
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)
Tagspython feature
FreeCAD Information

Activities

TheMarkster

2018-08-23 20:52

reporter  

TestClass.py (674 bytes)   
import FreeCAD
from PySide import QtGui,QtCore

class TestClass:
    def __init__(self, obj):
        obj.Proxy = self

   
    def onChanged(self, fp, prop):
        '''Do something when a property has changed'''

        FreeCAD.Console.PrintMessage("Change property: " + str(prop) + "\n")
 
 
    def execute(self, fp):
        '''Do something when doing a recomputation, this method is mandatory'''
        pass
        #FreeCAD.Console.PrintMessage("Recompute Python SSHelper feature\n")


test=FreeCAD.ActiveDocument.addObject("App::FeaturePython","TestObject")
TestClass(test)

test.addProperty("App::PropertyStringList","propertyStringList")
TestClass.py (674 bytes)   

TheMarkster

2018-08-23 21:21

reporter   ~0011648

Fixed already: Your text to link here...

Kunda1

2018-08-25 23:45

administrator   ~0011656

Fixed by wmayer in http://github.com/FreeCAD/FreeCAD/commit/24579fff3

DeepSOIC

2018-09-03 17:38

developer   ~0011695

New steps to reproduce:
1. paste to console:
import FreeCAD
from PySide import QtGui,QtCore

class TestClass:
    def __init__(self, obj):
        obj.Proxy = self
    def onChanged(self, fp, prop):
        '''Do something when a property has changed'''
        FreeCAD.Console.PrintMessage("Change property: " + str(prop) + "\n")
    def execute(self, fp):
        '''Do something when doing a recomputation, this method is mandatory'''
        pass


test=FreeCAD.ActiveDocument.addObject("App::FeaturePython","TestObject")
TestClass(test)

test.addProperty("App::PropertyStringList","propertyStringList")


2. select new object, modify propertyStringList property. type 4 lines:
a
b
c
d

3. Clear selection, select the object again. The property value now reads
abcd

TheMarkster

2018-09-03 18:13

reporter   ~0011696

https://github.com/FreeCAD/FreeCAD/pull/1642

wmayer

2018-09-10 13:54

administrator   ~0011705

https://github.com/FreeCAD/FreeCAD/commit/9e5b31fe2a49c57436fb47df7b56150db6362dcd

Kunda1

2020-09-02 11:19

administrator   ~0014724

c:FreeCAD:24579fff3:
c:FreeCAD:9e5b31fe2:

Issue History

Date Modified Username Field Change
2018-08-23 20:52 TheMarkster New Issue
2018-08-23 20:52 TheMarkster Tag Attached: python feature
2018-08-23 20:52 TheMarkster File Added: TestClass.py
2018-08-23 21:21 TheMarkster Note Added: 0011648
2018-08-25 23:45 Kunda1 Assigned To => wmayer
2018-08-25 23:45 Kunda1 Status new => closed
2018-08-25 23:45 Kunda1 Resolution open => fixed
2018-08-25 23:45 Kunda1 Fixed in Version => 0.18
2018-08-25 23:45 Kunda1 Note Added: 0011656
2018-09-03 17:38 DeepSOIC Status closed => feedback
2018-09-03 17:38 DeepSOIC Resolution fixed => reopened
2018-09-03 17:38 DeepSOIC Note Added: 0011695
2018-09-03 17:42 DeepSOIC Description Updated
2018-09-03 18:13 TheMarkster Note Added: 0011696
2018-09-03 18:13 TheMarkster Status feedback => assigned
2018-09-10 13:54 wmayer Status assigned => closed
2018-09-10 13:54 wmayer Note Added: 0011705
2020-09-02 11:19 Kunda1 Note Added: 0014724