Issue #22977: Fixed formatting Windows error messages on Wine.

Patch by Martin Panter.
This commit is contained in:
Serhiy Storchaka 2015-04-02 09:47:27 +03:00
parent a7eaf56a6d
commit f41f8f9974
3 changed files with 14 additions and 3 deletions

View file

@ -6,10 +6,11 @@ import unittest
import pickle
import weakref
import errno
import ctypes
from test.support import (TESTFN, captured_output, check_impl_detail,
check_warnings, cpython_only, gc_collect, run_unittest,
no_tracing, unlink)
no_tracing, unlink, get_attribute)
class NaiveException(Exception):
def __init__(self, x):
@ -245,6 +246,13 @@ class ExceptionTests(unittest.TestCase):
self.assertEqual(w.strerror, 'foo')
self.assertEqual(w.filename, None)
def test_windows_message(self):
"""Should fill in unknown error code in Windows error message"""
windll = get_attribute(ctypes, "windll")
code = int.from_bytes(b"\xE0msc", "big")
with self.assertRaisesRegex(OSError, hex(code)):
windll.kernel32.RaiseException(code, 0, 0, None)
def testAttributes(self):
# test that exception attributes are happy