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 889 - Nonimplemented virtual methods can lead to strange application errors
: Nonimplemented virtual methods can lead to strange application errors
Status: CLOSED WONTFIX
Product: PySide
Classification: Unclassified
Component: PySide
: 1.0.4
: PC MS Windows XP/Vista/7
: P3 normal
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2011-06-15 22:32 EEST by Christian
Modified: 2011-08-23 00:37 EEST (History)
8 users (show)

See Also:


Attachments
Minimal example where a non implemented virtual method leads to strange error behaviour. (1.64 KB, text/plain)
2011-06-15 22:32 EEST, Christian
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian 2011-06-15 22:32:20 EEST
Created attachment 349 [details]
Minimal example where a non implemented virtual method leads to strange error
behaviour.

Nonimplemented virtual methods can lead to event handling Problems.

Run the script as it is and you will observe the following issues:

- Frame cannot be closed kindly only by killing the process

- Resizing the Program leads to strange error messages:
     QPainter::begin: Paint device returned engine == 0, type: 0


Proposed changes:

    - Detect unresolvable virtual methods and print appropriate error message



NOTES:

This bug might be related to Bug 887.
Comment 1 Hugo Parente Lima 2011-06-16 16:55:41 EEST
As explained on mailing list[1] check those types of problems would slow down
object creation and turn impossible some things like method duck punching, so
marking as WONTFIX.

[1] http://lists.pyside.org/pipermail/pyside/2011-June/002582.html

Regards
Comment 2 renato filho 2011-06-22 20:25:18 EEST
release 1.0.4
Comment 3 Christian 2011-06-27 23:13:12 EEST
This issue is still not resolved in 1.0.4

And I still suggest:

"Try to resolve the method. If that is not possible (AttributeError)
print warning and return dummy object to C++ interface."

This should only have a negligible overhead for normal method dispatching but
would make it much easier to track down such an error.
Comment 4 Hugo Parente Lima 2011-06-28 00:05:01 EEST
Christian, read the comment #1

Regards.
Comment 5 Christian 2011-06-28 00:25:49 EEST
I suggest to adapt the existing code to something like that (Python like pseudo
code):


try:
    func = getattribute(obj, virtual_method_name)
except AttributeError:
    print 'Cannot find virtual method ... '
else:
    res = func(*args)
    if isinstance(res, expected_return_value):
        return res.cobject()
    else:
        print 'Invalid return value, got ... expected ... '
return <dummy cobject>



regarding comment #1
> As explained on mailing list check 
> those types of problems would slow down object creation 

I am not suggesting and I have never suggested to do any checks at object
creation time. You are right that would be a huge slowdown.

> and turn impossible some things like method duck punching

Why should method duck punching be broken?
Comment 6 renato filho 2011-08-11 00:40:10 EEST
(In reply to comment #5)
> I suggest to adapt the existing code to something like that (Python like pseudo
> code):
> 
> 
> try:
>     func = getattribute(obj, virtual_method_name)
> except AttributeError:
>     print 'Cannot find virtual method ... '
> else:
>     res = func(*args)
>     if isinstance(res, expected_return_value):
>         return res.cobject()
>     else:
>         print 'Invalid return value, got ... expected ... '
> return <dummy cobject>
> 
> 
> 

The PySide implementation already do something similar to this, but the problem
here is that, the error occurred during the c++ call, at this point PySide set
the python error with the necessary values, this error will be raised when the
python interpret returns. But the this never happen because all code python has
already executed.

This is how python works we can not change that. You can have more information
about that on python documentation:
http://docs.python.org/c-api/exceptions.html


Feel free to suggest some different solutions.

Thanks
Comment 7 renato filho 2011-08-22 23:35:36 EEST
Since we did not receive any reply during the release window, I will mark this
bug as WONTFIX. But feel free to re open if necessary.
Comment 8 renato filho 2011-08-23 00:37:22 EEST
Release PySide 1.0.6