ID 425201 - Using lambda functions inside a PySide2/Qt Signal returns a boolean rather than the argument passed

Follow

Problem summary
Using lambda functions inside a PySide2 Signal returns a boolean rather than the argument passed


This only seems to affect Qt's New Syntax, rather than it's Traditional syntax


Customer reported version
nuke.12.0v4


Customer reported platform
centos7


Steps to reproduce


1) Open Nuke

2) In the Script Editor, run the below code:

from PySide2 import QtWidgets, QtCore

class TestClass(QtWidgets.QDialog):
    def __init__(self, parent=None):
        super(TestClass, self).__init__()
        layout = QtWidgets.QVBoxLayout()

        self.btn1 = QtWidgets.QPushButton("Button 1")
        func1 = lambda printVar="Button 1" : self.printer(printVar)
        self.btn1.clicked.connect(func1) ### New Syntax
        layout.addWidget(self.btn1)

        self.btn2 = QtWidgets.QPushButton("Button 2")
        func2 = lambda printVar="Button 2" : self.printer(printVar)
        QtCore.QObject.connect(self.btn2, QtCore.SIGNAL ('clicked()'), func2) ### Traditional Syntax
        layout.addWidget(self.btn2)

        self.setLayout(layout)

    def printer(self, printVar):
        print "Button pressed: " + str(printVar)

UI = TestClass()
UI.show()

3) In the new dialog, click both Buttons, they should both print their names


Expected behaviour
For Button 1 to print Button 1


Actual behaviour
Button 1 printed False, and returns a boolean, rather than the string defined in the argument of the lambda function.


Workaround
Use the Traditional Syntax, as Button 2 does in this example.


Reproduced by support
This bug has been reproduced in:

Nuke 12.0v4 - Windows 10 - CentOS 7.7 - MacOSX 10.13

Nuke 12.0v1 - Windows 10 - CentOS 7.7 - MacOSX 10.13 - regression


Unable to reproduce bug in:
Nuke 11.3v6 - Windows 10 - CentOS 7.7 - MacOSX 10.13


Earliest version tested
Nuke 11.3v6 - This issue doesn't appear in this version and has regressed


    We're sorry to hear that

    Please tell us why