Ticket #5364: winerror3.patch

File winerror3.patch, 1.8 KB (added by Antoine Pitrou, 10 years ago)
  • twisted/python/win32.py

    diff -r f0773f8fb254 twisted/python/win32.py
    a b  
    156156        @rtype: C{str}
    157157        """
    158158        if self.winError is not None:
    159             return self.winError(errorcode)[1]
     159            return self.winError(errorcode).strerror
    160160        if self.formatMessage is not None:
    161161            return self.formatMessage(errorcode)
    162162        if self.errorTab is not None:
  • twisted/test/test_strerror.py

    diff -r f0773f8fb254 twisted/test/test_strerror.py
    a b  
    1414from twisted.python.runtime import platform
    1515
    1616
     17class _MyWindowsException(OSError):
     18    pass
     19
    1720
    1821class ErrorFormatingTestCase(TestCase):
    1922    """
     
    8184        winCalls = []
    8285        def winError(errorCode):
    8386            winCalls.append(errorCode)
    84             return (errorCode, self.probeMessage)
     87            return _MyWindowsException(errorCode, self.probeMessage)
    8588        formatter = _ErrorFormatter(
    8689            winError,
    8790            lambda error: 'formatMessage: wrong message',
     
    101104            from ctypes import WinError
    102105            self.assertEqual(
    103106                formatter.formatError(self.probeErrorCode),
    104                 WinError(self.probeErrorCode)[1])
     107                WinError(self.probeErrorCode).strerror)
    105108            formatter.winError = None
    106109
    107110        if formatter.formatMessage is not None:
     
    130133        acceptable = [socket.errorTab[ECONNABORTED]]
    131134        try:
    132135            from ctypes import WinError
    133             acceptable.append(WinError(ECONNABORTED)[1])
     136            acceptable.append(WinError(ECONNABORTED).strerror)
    134137        except ImportError:
    135138            pass
    136139        try: