summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiampaolo RodolĂ  <g.rodola@gmail.com>2010-05-18 20:04:31 (GMT)
committerGiampaolo RodolĂ  <g.rodola@gmail.com>2010-05-18 20:04:31 (GMT)
commite3a84e857fb568f6310cba2f15122a258d41bf03 (patch)
treecd10c47d104550421a57d5641231890939488eab
parentcccfce19593e58c06d14525f16ed214b9324522d (diff)
downloadcpython-e3a84e857fb568f6310cba2f15122a258d41bf03.zip
cpython-e3a84e857fb568f6310cba2f15122a258d41bf03.tar.gz
cpython-e3a84e857fb568f6310cba2f15122a258d41bf03.tar.bz2
Fix issue #8573 (asyncore._strerror bug): fixed os.strerror typo; included NameError in the tuple of expected exception; added test case for asyncore._strerror.
-rw-r--r--Lib/asyncore.py4
-rw-r--r--Lib/test/test_asyncore.py9
2 files changed, 11 insertions, 2 deletions
diff --git a/Lib/asyncore.py b/Lib/asyncore.py
index ce18d83..3e3907e 100644
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -63,8 +63,8 @@ except NameError:
def _strerror(err):
try:
- return strerror(err)
- except (ValueError, OverflowError):
+ return os.strerror(err)
+ except (ValueError, OverflowError, NameError):
if err in errorcode:
return errorcode[err]
return "Unknown error %s" %err
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py
index ed4c8a3..6973f4b 100644
--- a/Lib/test/test_asyncore.py
+++ b/Lib/test/test_asyncore.py
@@ -6,6 +6,7 @@ import socket
import sys
import time
import warnings
+import errno
from test import test_support
from test.test_support import TESTFN, run_unittest, unlink
@@ -323,6 +324,14 @@ class DispatcherTests(unittest.TestCase):
self.assertTrue(len(w) == 1)
self.assertTrue(issubclass(w[0].category, DeprecationWarning))
+ def test_strerror(self):
+ # refers to bug #8573
+ err = asyncore._strerror(errno.EPERM)
+ if hasattr(os, 'strerror'):
+ self.assertEqual(err, os.strerror(errno.EPERM))
+ err = asyncore._strerror(-1)
+ self.assertTrue("unknown error" in err.lower())
+
class dispatcherwithsend_noread(asyncore.dispatcher_with_send):
def readable(self):