Draft: change super() so it is compatible with Python 2
In Python 3 `super()` can be used without an argument in order to get the parent class, `super()`. In Python 2 the present class must be used as an argument, `super(ThisClass, self)`. This commit is done to support Python 2, as without it all Gui Command tools will be broken and will fail to launch, even if the unit tests pass. Also, set the `__metaclass__` variable to `type`. This is done to turn all classes into "new style" classes in Python 2. This is required so `super()` works correctly in this version of Pyton. This commit can be reverted once Python 2 support is completely dropped, and only Python 3 compatible code is used.
This commit is contained in:
@@ -46,7 +46,7 @@ class CircularArray(gui_base.GuiCommandBase):
|
||||
"""Gui command for the CircularArray tool."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
super(CircularArray, self).__init__()
|
||||
self.command_name = "Circular array"
|
||||
self.location = None
|
||||
self.mouse_event = None
|
||||
@@ -136,7 +136,7 @@ class CircularArray(gui_base.GuiCommandBase):
|
||||
self.callback_click)
|
||||
if Gui.Control.activeDialog():
|
||||
Gui.Control.closeDialog()
|
||||
super().finish()
|
||||
super(CircularArray, self).finish()
|
||||
|
||||
|
||||
Gui.addCommand('Draft_CircularArray', CircularArray())
|
||||
|
||||
Reference in New Issue
Block a user