Skip to content

super() does not work for Qt classes #39

Open
@usiems

Description

@usiems

I just want to share some insights into this issue, I currently have no intention to fix the issue, as that would be somewhat complicated.

This is an example of what does not work:

from PythonQt.QtGui import QDoubleValidator

class MyFunnyValidator(QDoubleValidator):
  def setRange(self, minimum, maximum, decimals):
    super().setRange(minimum, maximum, decimals+1)

The problem boils down to the fact that the method lookup of super() directly accesses the internal tp_dict member of the super classes, which is only filled to an absolute minimum by PythonQt (for performance reasons). Everything else is delivered through tp_getattro calls, but this does not work for super.

I discussed with Florian Link what would have to be done to fill the tp_dict.

  • This would probably need to happen in PythonQtInstanceWrapper_init the first time an instance of the class is created.
  • One could have a look at PythonQtClassWrapper_getattro how this is done, where the __dict__ member is dynamically filled.
  • But one would have to have in mind that QObject class wrappers can get updated methods when, e.g., the Qt bindings are loaded, so the class tp_dict would have to be updated then or at least flushed.
  • There might be other unforeseen consequences.

We both agreed that this change is somewhat tricky and probably currently not worthwhile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions