Skip to content

PySide6 behaves differently between decorated and non-decorated function #243

@bersbersbers

Description

@bersbersbers

In this code example, fun behaves different from decorated_fun. For more context, see https://stackoverflow.com/q/76596620/. I have tried a lot of things already to fix this. What works is the FunctionBuilder approach of boltons (basically some exec(compile(def fun(...)))). wrapt, however, is not able to fully emulate fun:

import wrapt
# pip install PySide6-Essentials
from PySide6.QtWidgets import QApplication, QSpinBox

def fun():
    print("This works")

@wrapt.decorator
def my_decorator(wrapped, _instance, args, kwargs):
    return wrapped(*args, **kwargs)

@my_decorator
def decorated_fun():
    print("This fails")

app = QApplication()
box = QSpinBox()
box.valueChanged.connect(fun)
box.valueChanged.connect(decorated_fun)
box.setValue(10)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions