Issue 32111: ObjectListView crashes on python3.5 (original) (raw)

Issue: On Python3.5, ObjectListView object crashes when double-clicked in cell to edit int type.

Traceback (most recent call last): File "C:\DevEnv\Python35\lib\site-packages\ObjectListView\ObjectListView.py", line 1726, in _HandleLeftClickOrDoubleClick self._PossibleStartCellEdit(rowIndex, subItemIndex) File "C:\DevEnv\Python35\lib\site-packages\ObjectListView\ObjectListView.py", line 2048, in _PossibleStartCellEdit self.StartCellEdit(rowIndex, subItemIndex) File "C:\DevEnv\Python35\lib\site-packages\ObjectListView\ObjectListView.py", line 2114, in StartCellEdit self.cellEditor.SetValue(evt.cellValue) File "C:\DevEnv\Python35\lib\site-packages\ObjectListView\CellEditor.py", line 268, in SetValue if isinstance(value, (long, int, float)): NameError: name 'long' is not defined

On debugging, I found that the actual root-cause of this bug lies in below code: File: ..lib\site-packages\ObjectListView\CellEditor.py Line: 100

def __init__(self):
    self.typeToFunctionMap = {}

    # Standard types and their creator functions
    self.typeToFunctionMap[str] = self._MakeStringEditor
    self.typeToFunctionMap[six.text_type] = self._MakeStringEditor
    self.typeToFunctionMap[bool] = self._MakeBoolEditor

    if six.PY2:
        self.typeToFunctionMap[int] = self._MakeIntegerEditor
        self.typeToFunctionMap[long] = self._MakeLongEditor
    else:

#Line:100
self.typeToFunctionMap[int] = self._MakeLongEditor

    self.typeToFunctionMap[float] = self._MakeFloatEditor
    self.typeToFunctionMap[datetime.datetime] = self._MakeDateTimeEditor
    self.typeToFunctionMap[datetime.date] = self._MakeDateEditor
    self.typeToFunctionMap[datetime.time] = self._MakeTimeEditor

Modified code:

    if six.PY2:
        self.typeToFunctionMap[int] = self._MakeIntegerEditor
        self.typeToFunctionMap[long] = self._MakeLongEditor
    else:

#Line:100 self.typeToFunctionMap[int] = self._MakeIntegerEditor

In place of integer type editor, long type editor is being created. As Python3.x does not support long type, the programme crashes here.

Yes, I am using this 3rd party library. Okay, I shall withdraw the issue from here. I'm new to Python and hence do not know the various groups and their purpose. Apologies! Thanks for the support.

Version info: ObjectListView 1.3.1 Python 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:07:06) [MSC v.1900 32 bit (Intel)] on win32