[Python-checkins] r64768 - in python/trunk/Lib: asynchat.py asyncore.py test/test_asyncore.py
josiah.carlson
python-checkins at python.org
Mon Jul 7 06:51:47 CEST 2008
Author: josiah.carlson
Date: Mon Jul 7 06:51:46 2008
New Revision: 64768
Log:
Fixed bugs 760475, 953599, and 1519.
Modified:
python/trunk/Lib/asynchat.py
python/trunk/Lib/asyncore.py
python/trunk/Lib/test/test_asyncore.py
Modified: python/trunk/Lib/asynchat.py
==============================================================================
--- python/trunk/Lib/asynchat.py (original)
+++ python/trunk/Lib/asynchat.py Mon Jul 7 06:51:46 2008
@@ -59,7 +59,7 @@
ac_in_buffer_size = 4096
ac_out_buffer_size = 4096
- def __init__ (self, conn=None):
+ def __init__ (self, sock=None, map=None):
# for string terminator matching
self.ac_in_buffer = ''
@@ -74,7 +74,7 @@
# we toss the use of the "simple producer" and replace it with
# a pure deque, which the original fifo was a wrapping of
self.producer_fifo = deque()
- asyncore.dispatcher.__init__ (self, conn)
+ asyncore.dispatcher.__init__ (self, sock, map)
def collect_incoming_data(self, data):
raise NotImplementedError("must be implemented in subclass")
Modified: python/trunk/Lib/asyncore.py
==============================================================================
--- python/trunk/Lib/asyncore.py (original)
+++ python/trunk/Lib/asyncore.py Mon Jul 7 06:51:46 2008
@@ -99,8 +99,10 @@
obj.handle_read_event()
if flags & select.POLLOUT:
obj.handle_write_event()
- if flags & (select.POLLERR | select.POLLHUP | select.POLLNVAL):
+ if flags & (select.POLLERR | select.POLLNVAL):
obj.handle_expt_event()
+ if flags & select.POLLHUP:
+ obj.handle_close_event()
except (ExitNow, KeyboardInterrupt, SystemExit):
raise
except:
@@ -467,7 +469,7 @@
),
'error'
)
- self.close()
+ self.handle_close()
def handle_expt(self):
self.log_info('unhandled exception', 'warning')
Modified: python/trunk/Lib/test/test_asyncore.py
==============================================================================
--- python/trunk/Lib/test/test_asyncore.py (original)
+++ python/trunk/Lib/test/test_asyncore.py Mon Jul 7 06:51:46 2008
@@ -38,6 +38,7 @@
raise asyncore.ExitNow()
handle_write_event = handle_read_event
+ handle_close_event = handle_read_event
handle_expt_event = handle_read_event
class crashingdummy:
@@ -48,6 +49,7 @@
raise Exception()
handle_write_event = handle_read_event
+ handle_close_event = handle_read_event
handle_expt_event = handle_read_event
def handle_error(self):
@@ -117,6 +119,7 @@
def __init__(self):
self.read = False
self.write = False
+ self.closed = False
self.expt = False
def handle_read_event(self):
@@ -125,6 +128,9 @@
def handle_write_event(self):
self.write = True
+ def handle_close_event(self):
+ self.closed = True
+
def handle_expt_event(self):
self.expt = True
@@ -167,9 +173,9 @@
for flag in (select.POLLERR, select.POLLHUP, select.POLLNVAL):
tobj = testobj()
- self.assertEqual(tobj.expt, False)
+ self.assertEqual((tobj.expt, tobj.closed)[flag == select.POLLHUP], False)
asyncore.readwrite(tobj, flag)
- self.assertEqual(tobj.expt, True)
+ self.assertEqual((tobj.expt, tobj.closed)[flag == select.POLLHUP], True)
# check that ExitNow exceptions in the object handler method
# bubbles all the way up through asyncore readwrite calls
More information about the Python-checkins
mailing list