This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: asyncore dispatcher.__getattr__() masks self._map
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: dwhite, georg.brandl, zseil
Priority: normal Keywords:

Created on 2006-03-13 04:52 by dwhite, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg27764 - (view) Author: Doug White (dwhite) Date: 2006-03-13 04:52
The abstraction of socket_map in the asyncore module 
in Python 2.4 forgets to allow accesses to the 
internal attribute self._map in __getattr__(). This 
causes any asyncore application to fail in 
create_socket(), which pretty much renders asyncore 
inoperative in Python 2.4.  
 
This problem was introduced in rev 34469 as a commit 
of Bug #758241. 
 
Example backtrace, generated from an application that 
uses Medusa servers that don't use the private map 
function: 
 
Traceback (most recent call last): 
  File "/usr/local/qos/qosserver/qos_server.py", line 
1576, in ? 
    m = monitor.monitor_server ('127.0.0.1', 
BasePort) 
  File "/usr/local/qos/qosserver/monitor.py", line 
161, in __init__ 
    self.create_socket (socket.AF_INET, 
socket.SOCK_STREAM) 
  File "/usr/local/lib/python2.4/asyncore.py", line 
261, in create_socket 
    self.add_channel() 
  File "/usr/local/lib/python2.4/asyncore.py", line 
244, in add_channel 
    map = self._map 
  File "/usr/local/lib/python2.4/asyncore.py", line 
366, in __getattr__ 
    return getattr(self.socket, attr) 
AttributeError: '_socketobject' object has no 
attribute '_map' 
 
__getattr__() should test if the attribute exists in 
its own object before passing it on to the underlying 
socket object. 
msg27765 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2006-03-17 11:37
Logged In: YES 
user_id=1326842

This is a bug in your code, since you don't call the
base class's __init__() method, and as a consequence
the '_map' attribute really doesn't exist.

__getattr__() doesn't have to check for existance of
an attribute since it is called only when the normal
lookup mechanism fails. See the docs:
http://docs.python.org/ref/attribute-access.html

msg27766 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-03-17 11:51
Logged In: YES 
user_id=849994

It seems that zseil is right. Closing as Invalid.
msg27767 - (view) Author: Doug White (dwhite) Date: 2006-03-17 18:20
Logged In: YES 
user_id=105929

Ugh... this was my fault. I had code checkouts out of sync. So sorry :(
History
Date User Action Args
2022-04-11 14:56:15adminsetgithub: 43026
2006-03-13 04:52:25dwhitecreate