PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 543 - Regression: Signals with default values broken
: Regression: Signals with default values broken
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: PySide
: HEAD
: All All
: P2 major
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2010-12-11 18:16 EET by Lauro Moura
Modified: 2010-12-20 11:26 EET (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lauro Moura 2010-12-11 18:16:59 EET
Test case signal/signal_signature_test.py failing with all components from
HEAD.

The test also fails with QPushButton.clicked, another signal with default
value.

34: Test command: /usr/bin/python2.6-dbg
/home/lauro/dev/pyside/pyside/tests/signals/signal_signature_test.py
34: Test timeout computed to be: 60
34: F..
34: ======================================================================
34: FAIL: testNewStyle (__main__.TestConnectNotifyWithNewStyleSignals)
34: ----------------------------------------------------------------------
34: Traceback (most recent call last):
34:   File
"/home/lauro/dev/pyside/pyside/tests/signals/signal_signature_test.py", line
37, in testNewStyle
34:     self.assertEqual(sender.signal, SIGNAL('destroyed(QObject*)'))
34: AssertionError: '2destroyed()' != '2destroyed(QObject*)'
34: 
34: ----------------------------------------------------------------------
34: Ran 3 tests in 0.002s
34: 
34: FAILED (failures=1)
34: -------------------------------
34: WrapperMap: 0x1704fd0 (size: 0)
34: -------------------------------
34: [141199 refs]
1/1 Test #34: signals_signal_signature_test ....***Failed    0.15 sec
Comment 1 Lauro Moura 2010-12-11 18:56:56 EET
Updating bug summary and raising severity.

It seems that this issue is a little bit bigger than just the connectNotify
argument.

Signals with default values aren't working when connected directly (without
specifying the argument). If the callback expects the argument a TypeError is
raised as the argument is not provided.

Example:
def callback(checked):
   pass

button = QPushButton()
button.clicked.connect(callback)
button.click() # Will raise TypeError internally when calling callback()
instead of callback(checked).

Changing the connect line to clicked[bool] works.

One possible fix is making <signalwithdefaultargument>.connect() connect to the
expanded version of the signal, always turning default arguments into
non-default. This way, arguments will be provided when calling the callback. If
the callback don't want any of them, they would be dropped (just as they are
now).

PyQt4 seems to take this approach, as qobject.destroyed.connect(...) results in
a 'destroyed(QObject*)' signature in connectNotify.

So,

button.clicked.connect -> will connect clicked(bool)
object.destroyed.connect -> will connect destroyed(QObject*)

and so on.
Comment 2 Matti Airas 2010-12-13 15:49:03 EET
Thanks - I'm making this P2 as well because it is about signal/slot
functionality.
Comment 3 Marcelo Lira 2010-12-13 16:15:12 EET
The "destroyed(QObject* = 0)" signal is in fact two signals:
* destroyed()
* destroyed(QObject*)

Before the fix in commit Shiboken/33537a0e the signature "destroyed()" wasn't
being registered, and thus could not be used even explicitly
("destroyed[None].connect(...)"). Also it makes more sense when
"destroyed.connect(...") refers to "destroyed()", and
"destroyed[QObject].connect(...)" refers to "destroyed(QObject*)".

That being said, the tests were fixed on commit PySide/4630f41f.
Comment 4 Hugo Parente Lima 2010-12-20 11:26:15 EET
Closign bugs after release of 1.0.0 beta2.