Menu

#1 help() barfs on missing __objclass__

closed-fixed
None
5
2003-03-04
2003-03-02
No

Using python22 builtin help() on a module containing a
class containing a reference to a WinDLL object fails
with the traceback below.

Reason is the gettattr in line 203 of inspect.py
homecls = getattr(obj, "__objclass__", None)

Modifying WinDLL to

class WinDLL(CDLL):
__def __getattr__(self, name):
____if name=="__objclass__": raise AttributeError # this
line added
____func = _DynFunction(name, self)
... etc
cures the problem for me.

Traceback:

help> Sensor
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python22\lib\site.py", line 284, in __call__
return pydoc.help(*args, **kwds)
File "C:\Python22\lib\pydoc.py", line 1519, in __call__
self.interact()
File "C:\Python22\lib\pydoc.py", line 1538, in interact
self.help(request)
File "C:\Python22\lib\pydoc.py", line 1550, in help
elif request: doc(request, 'Help on %s:')
File "C:\Python22\lib\pydoc.py", line 1346, in doc
pager(title % desc + '\n\n' + text.document(object,
name))
File "C:\Python22\lib\pydoc.py", line 267, in document
if inspect.ismodule(object): return apply
(self.docmodule, args)
File "C:\Python22\lib\pydoc.py", line 964, in docmodule
contents.append(self.document(value, key, name))
File "C:\Python22\lib\pydoc.py", line 268, in document
if inspect.isclass(object): return apply(self.docclass,
args)
File "C:\Python22\lib\pydoc.py", line 1080, in docclass
attrs = inspect.classify_class_attrs(object)
File "C:\Python22\lib\inspect.py", line 203, in
classify_class_attrs
homecls = getattr(obj, "__objclass__", None)
File "C:\Python22\lib\site-packages\ctypes.py", line
184, in __getattr__
func = _DynFunction(name, self)
ValueError: function '__objclass__' not found

Context: Active Python 2.2.2 , ctypes 4.0

Discussion

  • Thomas Heller

    Thomas Heller - 2003-03-04

    Logged In: YES
    user_id=11105

    Checking for '__objclass__' is not sufficient, there are a
    lot of other magic attributes. I changed the __getattr__
    implementations for all *DLL classes to raise an attribute
    error if the requested name both starts and ends with a
    double underscore.
    Thanks!

     
  • Thomas Heller

    Thomas Heller - 2003-03-04
    • assigned_to: nobody --> theller
    • status: open --> closed-fixed
     

Log in to post a comment.