I connected three buttons to a function which takes an argument and simply prints it. The buttons pass the argument in cosmetically different ways, as you can see in the MWE below, though as I far as I know there isn't any semantic difference.
from PyQt5.QtWidgets import QPushButton, QFrame, QApplication, QVBoxLayout
from functools import partial
def func(i):
print(i)
app = QApplication([])
frame = QFrame()
layout = QVBoxLayout()
frame.setLayout(layout)
b1 = QPushButton('button 1', frame)
b1.clicked.connect(lambda: func(1))
b2 = QPushButton('button 2', frame)
b2.clicked.connect(partial(func, i=2))
b3 = QPushButton('button 3', frame)
b3.clicked.connect(lambda x=3: func(x))
layout.addWidget(b1)
layout.addWidget(b2)
layout.addWidget(b3)
frame.show()
app.exec()
So when I click the buttons 1 through 3 I expect to see
1
2
3
But instead I get
1
2
False
What's wrong with the last lambda? Could this possibly be a bug of PyQt?
PyQt version is 5.15.2.