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?

Nathan
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside

Reply via email to