[issue8483] asyncore.dispatcher.__repr__() is weird

Giampaolo Rodola' report at bugs.python.org
Wed Apr 21 17:31:05 CEST 2010


Giampaolo Rodola' <g.rodola at gmail.com> added the comment:

I think the problem relies in here:

    # cheap inheritance, used to pass all other attribute
    # references to the underlying socket object.
    def __getattr__(self, attr):
        return getattr(self.socket, attr)

I wonder why this has been added in the first place.
It also causes confusing error messages when accessing undefined attributes:

>>> class B(asyncore.dispatcher):
...     def __init__(self, *args):
...             asyncore.dispatcher.__init__(self, *args)
...
>>> b = B()
>>> b.blabla
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/asyncore.py", line 394, in __getattr__
    return getattr(self.socket, attr)
AttributeError: '_socketobject' object has no attribute 'blabla'
>>>

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8483>
_______________________________________


More information about the Python-bugs-list mailing list