summaryrefslogtreecommitdiffstats
path: root/Lib/asyncore.py
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2013-04-09 15:21:25 (GMT)
committerGiampaolo Rodola' <g.rodola@gmail.com>2013-04-09 15:21:25 (GMT)
commita4c377cde9b010f6bee5e5e0a15e8545228d31e2 (patch)
treecbb04d46c81bd15a4d5f401542b3ed57a6d90637 /Lib/asyncore.py
parentfa1b02a126ef6b6ce58b2ea595a97384ae616593 (diff)
downloadcpython-a4c377cde9b010f6bee5e5e0a15e8545228d31e2.zip
cpython-a4c377cde9b010f6bee5e5e0a15e8545228d31e2.tar.gz
cpython-a4c377cde9b010f6bee5e5e0a15e8545228d31e2.tar.bz2
Do not raise exception on close() on account of socket attribute still being None:
>>> import asyncore >>> d = asyncore.dispatcher() >>> d.close() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.4/asyncore.py", line 401, in close self.socket.close() AttributeError: 'NoneType' object has no attribute 'close' >>>
Diffstat (limited to 'Lib/asyncore.py')
-rw-r--r--Lib/asyncore.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/asyncore.py b/Lib/asyncore.py
index f146643..75481dd 100644
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -397,11 +397,12 @@ class dispatcher:
self.accepting = False
self.connecting = False
self.del_channel()
- try:
- self.socket.close()
- except OSError as why:
- if why.args[0] not in (ENOTCONN, EBADF):
- raise
+ if self.socket is not None:
+ try:
+ self.socket.close()
+ except OSError as why:
+ if why.args[0] not in (ENOTCONN, EBADF):
+ raise
# cheap inheritance, used to pass all other attribute
# references to the underlying socket object.