[PyQt] BUG: sip instance attribute error: Re: [eric4] python qscintilla traceback with current snapshot also

Hans-Peter Jansen hpj at urpla.net
Wed Feb 2 21:59:27 GMT 2011


On Wednesday 02 February 2011, 22:29:48 Phil Thompson wrote:
> On Wed, 2 Feb 2011 22:25:09 +0100, "Hans-Peter Jansen"
> <hpj at urpla.net>
>
> wrote:
> > On Wednesday 02 February 2011, 22:16:46 Phil Thompson wrote:
> >> On Wed, 2 Feb 2011 21:33:39 +0100, "Hans-Peter Jansen"
> >> <hpj at urpla.net>
> >>
> >> wrote:
> >> > [Oops, sorry, send too fast]
> >> >
> >> > Dear Phil,
> >> >
> >> > On Tuesday 01 February 2011, 22:26:43 Hans-Peter Jansen wrote:
> >> >> Phil, something is badly broken with the current release and
> >> >> the snapshots.
> >> >
> >> > Here's the essence of the issue:
> >> >
> >> > class A(object):
> >> >     def __init__(self):
> >> >         # catch access a non existing attribute
> >> >         try:
> >> >             print self.a, type(self.a)
> >> >         except AttributeError:
> >> >             pass
> >> >
> >> > a = A()
> >> >
> >> > from PyQt4.Qsci import QsciScintilla
> >> >
> >> > # derive from a sip wrapped class
> >> > class B(QsciScintilla):
> >> >     def __init__(self):
> >> >         # access a non existing attribute results in:
> >> >         # TypeError: 'sip.methoddescriptor' object is not
> >> > callable try:
> >> >             print self.b, type(self.b)
> >> >         except AttributeError:
> >> >             pass
> >> >
> >> > b = B()
> >> >
> >> > results in:
> >> >
> >> > Traceback (most recent call last):
> >> >   File "sipinstance.py", line 22, in <module>
> >> >     b = B()
> >> >   File "sipinstance.py", line 18, in __init__
> >> >     print self.b, type(self.b)
> >> > TypeError: 'sip.methoddescriptor' object is not callable
> >> >
> >> > Obviously, accessing non existing attributes in classes wrapped
> >> > by sip causes havoc (an unexpected TypeError).
> >> >
> >> > At least for:
> >> > python: 2.6
> >> > sip: 4.12.1
> >> > qt4: 4.6.3
> >> > pyqt4: snapshot-4.8.4-278054fd857c
> >> >
> >> >
> >> > I was able to fix eric with this diff:
> >> >
> >> > --- QScintilla/Editor.py~       2011-02-02 21:31:20.741149390
> >> > +0100 +++ QScintilla/Editor.py        2011-02-02
> >> > 21:31:30.683988621 +0100 @@ -1258,7 +1258,7 @@ class
> >> > Editor(QsciScintillaCompat): """
> >> >          try:
> >>
> >> self.supportedEols[self.getLineSeparator()].setChecked(True)
> >>
> >> > -        except AttributeError:
> >> > +        except (AttributeError, TypeError):
> >> >              pass
> >> >
> >> >      def __eolChanged(self):
> >> >
> >> > Note: self.supportedEols doesn't exist, when this method is
> >> > called the first
> >> > time.
> >> >
> >> > Guess, it's sip 4.12.2 time ;-)
> >> >
> >> > Pete
> >>
> >> If I run the code as above I get a "RuntimeError: underlying
> >> C/C++..." as expected. Adding the missing call to
> >> QsciScintilla.__init__() (and creating a QApplication at the
> >> start) then it runs fine (ie. an AttributeError is raised).
> >
> > You mean:
> >
> > class A(object):
> >     def __init__(self):
> >         # catch access a non existing attribute
> >         try:
> >             print self.a, type(self.a)
> >         except AttributeError:
> >             pass
> >
> > a = A()
> >
> > from PyQt4 import QtGui
> > from PyQt4.Qsci import QsciScintilla
> >
> > app = QtGui.QApplication([])
> >
> > # derive from a sip wrapped class
> > class B(QsciScintilla):
> >     def __init__(self):
> >         super(B, self).__init__()
> >         # access a non existing attribute results in:
> >         # TypeError: 'sip.methoddescriptor' object is not callable
> >         try:
> >             print self.b, type(self.b)
> >         except AttributeError:
> >             pass
> >
> > b = B()
> >
> >
> > but still:
> >
> > Traceback (most recent call last):
> >   File "sipinstance.py", line 28, in <module>
> >     b = B()
> >   File "sipinstance.py", line 24, in __init__
> >     print self.b, type(self.b)
> > TypeError: 'sip.methoddescriptor' object is not callable
> >
> > It might be a Python version issue? (where I'm on 2.6, and you?)
>
> I've tried it with 2.6, 2.7 and 3.2rc2 - works fine.

I'm baffled, what TF is going here. 

Meanwhile, I relocated sitecustomize.py (just in case), and stopped all 
python instances, checked ldconfig, and what not.

Could you do me a flavor and call
python -v sipinstance.py (attached again) for your 2.6 setup.

Here's mine:

> python -v sipinstance.py
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /usr/lib/python2.6/site.pyc matches /usr/lib/python2.6/site.py
import site # precompiled from /usr/lib/python2.6/site.pyc
# /usr/lib/python2.6/os.pyc matches /usr/lib/python2.6/os.py
import os # precompiled from /usr/lib/python2.6/os.pyc
import errno # builtin
import posix # builtin
# /usr/lib/python2.6/posixpath.pyc matches /usr/lib/python2.6/posixpath.py
import posixpath # precompiled from /usr/lib/python2.6/posixpath.pyc
# /usr/lib/python2.6/stat.pyc matches /usr/lib/python2.6/stat.py
import stat # precompiled from /usr/lib/python2.6/stat.pyc
# /usr/lib/python2.6/genericpath.pyc matches /usr/lib/python2.6/genericpath.py
import genericpath # precompiled from /usr/lib/python2.6/genericpath.pyc
# /usr/lib/python2.6/warnings.pyc matches /usr/lib/python2.6/warnings.py
import warnings # precompiled from /usr/lib/python2.6/warnings.pyc
# /usr/lib/python2.6/linecache.pyc matches /usr/lib/python2.6/linecache.py
import linecache # precompiled from /usr/lib/python2.6/linecache.pyc
# /usr/lib/python2.6/types.pyc matches /usr/lib/python2.6/types.py
import types # precompiled from /usr/lib/python2.6/types.pyc
# /usr/lib/python2.6/UserDict.pyc matches /usr/lib/python2.6/UserDict.py
import UserDict # precompiled from /usr/lib/python2.6/UserDict.pyc
# /usr/lib/python2.6/_abcoll.pyc matches /usr/lib/python2.6/_abcoll.py
import _abcoll # precompiled from /usr/lib/python2.6/_abcoll.pyc
# /usr/lib/python2.6/abc.pyc matches /usr/lib/python2.6/abc.py
import abc # precompiled from /usr/lib/python2.6/abc.pyc
# /usr/lib/python2.6/copy_reg.pyc matches /usr/lib/python2.6/copy_reg.py
import copy_reg # precompiled from /usr/lib/python2.6/copy_reg.pyc
# /usr/lib/python2.6/new.pyc matches /usr/lib/python2.6/new.py
import new # precompiled from /usr/lib/python2.6/new.pyc
import encodings # directory /usr/lib/python2.6/encodings
# /usr/lib/python2.6/encodings/__init__.pyc matches /usr/lib/python2.6/encodings/__init__.py
import encodings # precompiled from /usr/lib/python2.6/encodings/__init__.pyc
# /usr/lib/python2.6/codecs.pyc matches /usr/lib/python2.6/codecs.py
import codecs # precompiled from /usr/lib/python2.6/codecs.pyc
import _codecs # builtin
# /usr/lib/python2.6/encodings/aliases.pyc matches /usr/lib/python2.6/encodings/aliases.py
import encodings.aliases # precompiled from /usr/lib/python2.6/encodings/aliases.pyc
# /usr/lib/python2.6/encodings/utf_8.pyc matches /usr/lib/python2.6/encodings/utf_8.py
import encodings.utf_8 # precompiled from /usr/lib/python2.6/encodings/utf_8.pyc
Python 2.6 (r26:66714, Mar 30 2010, 00:30:21) 
[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import PyQt4 # directory /usr/lib/python2.6/site-packages/PyQt4
# /usr/lib/python2.6/site-packages/PyQt4/__init__.pyc matches /usr/lib/python2.6/site-packages/PyQt4/__init__.py
import PyQt4 # precompiled from /usr/lib/python2.6/site-packages/PyQt4/__init__.pyc
dlopen("/usr/lib/python2.6/site-packages/PyQt4/QtGui.so", 2);
dlopen("/usr/lib/python2.6/site-packages/sip.so", 2);
import sip # dynamically loaded from /usr/lib/python2.6/site-packages/sip.so
dlopen("/usr/lib/python2.6/site-packages/PyQt4/QtCore.so", 2);
import PyQt4.QtCore # dynamically loaded from /usr/lib/python2.6/site-packages/PyQt4/QtCore.so
import PyQt4.QtGui # dynamically loaded from /usr/lib/python2.6/site-packages/PyQt4/QtGui.so
dlopen("/usr/lib/python2.6/site-packages/PyQt4/Qsci.so", 2);
import PyQt4.Qsci # dynamically loaded from /usr/lib/python2.6/site-packages/PyQt4/Qsci.so
Traceback (most recent call last):
  File "sipinstance.py", line 28, in <module>
    b = B()
  File "sipinstance.py", line 24, in __init__
    print self.b, type(self.b)
TypeError: 'sip.methoddescriptor' object is not callable

# rpm -qf sip.so PyQt4/QtCore.so 
python-sip-4.12.1-1.1
python-qt4-4.8.4-0.20110130.044752.2.1

Will try a reboot next.

Pete
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sipinstance.py
Type: application/x-python
Size: 638 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110202/5f873bf2/attachment.bin>


More information about the PyQt mailing list