On Wednesday, May 30, 2012 09:37:15 AM Nathan Smith wrote:
> Hi all,
>
> I uncovered a bug in the new hash feature of Shiboken in the repositories.
> I'll submit a bug report when the system comes back up, but I'm interested
> in actually submitting a patch.
>
> The new hash function doesn't check to see if the provided object is valid
> before calculating the hash value. This can be seen
> in shiboken/libshiboken/basewrapper.cpp at line 754 and demonstrated using
>
> the following code:
> >>> from PySide import QtCore
> >>> import shiboken
> >>> a = QtCore.QObject()
> >>> b = QtCore.QObject(a)
> >>> shiboken.isValid(a)
>
> True
>
> >>> shiboken.isValid(b)
>
> True
>
> >>> del a
> >>> shiboken.isValid(b)
>
> False
>
> >>> hash(b)
>
> Segmentation Fault
>
>
> I made the following change in the code, but it didn't do what I expected:
>
> if (!isValid(pyObj)) {
> return 0L;
> }
>
>
> isValid raises a RuntimeException in addition to returning false, but I
> never see that exception in Python. So, I have two questions:
>
> 1. Is there some other code that should be checking isValid before the
> call ever gets to the C++ hash() function?
> 2. How do you correctly raise an exception from within Shiboken?You raise an exception using the Python C API. Use the PyErr_* functions, e.g. PyErr_SetString > Nathan
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ PySide mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/pyside
