Kaydet (Commit) 30aa46c9 authored tarafından Giampaolo Rodolà's avatar Giampaolo Rodolà

Merged revisions 81294 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81294 | giampaolo.rodola | 2010-05-18 22:04:31 +0200 (mar, 18 mag 2010) | 1 line

  Fix issue #8573 (asyncore._strerror bug): fixed os.strerror typo; included NameError in the tuple of expected exception; added test case for asyncore._strerror.
........
üst 4d1dc612
...@@ -62,8 +62,8 @@ except NameError: ...@@ -62,8 +62,8 @@ except NameError:
def _strerror(err): def _strerror(err):
try: try:
return strerror(err) return os.strerror(err)
except (ValueError, OverflowError): except (ValueError, OverflowError, NameError):
if err in errorcode: if err in errorcode:
return errorcode[err] return errorcode[err]
return "Unknown error %s" %err return "Unknown error %s" %err
......
...@@ -6,6 +6,7 @@ import socket ...@@ -6,6 +6,7 @@ import socket
import threading import threading
import sys import sys
import time import time
import errno
from test import test_support from test import test_support
from test.test_support import TESTFN, run_unittest, unlink from test.test_support import TESTFN, run_unittest, unlink
...@@ -314,6 +315,14 @@ class DispatcherTests(unittest.TestCase): ...@@ -314,6 +315,14 @@ class DispatcherTests(unittest.TestCase):
# test cheap inheritance with the underlying socket # test cheap inheritance with the underlying socket
self.assertEqual(d.family, socket.AF_INET) self.assertEqual(d.family, socket.AF_INET)
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): class dispatcherwithsend_noread(asyncore.dispatcher_with_send):
def readable(self): def readable(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment