Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82e02b5

Browse files
committed
Merged revisions 81294 via svnmerge from
svn+ssh://[email protected]/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. ........
1 parent 8fddc9e commit 82e02b5

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

Lib/asyncore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363

6464
def _strerror(err):
6565
try:
66-
return strerror(err)
67-
except (ValueError, OverflowError):
66+
return os.strerror(err)
67+
except (ValueError, OverflowError, NameError):
6868
if err in errorcode:
6969
return errorcode[err]
7070
return "Unknown error %s" %err

Lib/test/test_asyncore.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sys
77
import time
88
import warnings
9+
import errno
910

1011
from test import support
1112
from test.support import TESTFN, run_unittest, unlink
@@ -324,6 +325,14 @@ def test_issue_8594(self):
324325
self.assertTrue(len(w) == 1)
325326
self.assertTrue(issubclass(w[0].category, DeprecationWarning))
326327

328+
def test_strerror(self):
329+
# refers to bug #8573
330+
err = asyncore._strerror(errno.EPERM)
331+
if hasattr(os, 'strerror'):
332+
self.assertEqual(err, os.strerror(errno.EPERM))
333+
err = asyncore._strerror(-1)
334+
self.assertTrue("unknown error" in err.lower())
335+
327336

328337
class dispatcherwithsend_noread(asyncore.dispatcher_with_send):
329338
def readable(self):

0 commit comments

Comments
 (0)