[Python-checkins] r81294 - in python/trunk/Lib: asyncore.py test/test_asyncore.py

giampaolo.rodola python-checkins at python.org
Tue May 18 22:04:31 CEST 2010


Author: giampaolo.rodola
Date: Tue May 18 22:04:31 2010
New Revision: 81294

Log:
Fix issue #8573 (asyncore._strerror bug): fixed os.strerror typo; included NameError in the tuple of expected exception; added test case for asyncore._strerror.

Modified:
   python/trunk/Lib/asyncore.py
   python/trunk/Lib/test/test_asyncore.py

Modified: python/trunk/Lib/asyncore.py
==============================================================================
--- python/trunk/Lib/asyncore.py	(original)
+++ python/trunk/Lib/asyncore.py	Tue May 18 22:04:31 2010
@@ -63,8 +63,8 @@
 
 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

Modified: python/trunk/Lib/test/test_asyncore.py
==============================================================================
--- python/trunk/Lib/test/test_asyncore.py	(original)
+++ python/trunk/Lib/test/test_asyncore.py	Tue May 18 22:04:31 2010
@@ -6,6 +6,7 @@
 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 @@
             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):


More information about the Python-checkins mailing list