11import _ctypes
22import os
33import platform
4- import re
54import sys
65import test .support
76import unittest
@@ -137,33 +136,17 @@ def setUpClass(cls):
137136 if cls .libc_filename is None :
138137 raise unittest .SkipTest ('cannot find libc' )
139138
140- def check_filename_in_dlerror (self , error_message ):
141- if not sys .platform .startswith ('linux' ):
142- # On macOS, the filename is not reported by dlerror().
143- return
144-
145- if not re .match (r'(i[3-6]86|x86_64)$' , platform .machine ()):
146- # On some architectures, the libc file is detected
147- # to be 'libc.so.6' but is incorrectly reported by
148- # dlerror() as libc-X.Y.so.
149- self .skipTest ('do not search for filename '
150- 'in dlerror() error message' )
151-
152- self .assertIn (self .libc_filename , error_message )
153-
154139 @configure_locales
155140 def test_localized_error_from_dll (self ):
156141 dll = CDLL (self .libc_filename )
157- with self .assertRaises (AttributeError ) as cm :
142+ with self .assertRaises (AttributeError ):
158143 dll .this_name_does_not_exist
159- self .check_filename_in_dlerror (str (cm .exception ))
160144
161145 @configure_locales
162146 def test_localized_error_in_dll (self ):
163147 dll = CDLL (self .libc_filename )
164- with self .assertRaises (ValueError ) as cm :
148+ with self .assertRaises (ValueError ):
165149 c_int .in_dll (dll , 'this_name_does_not_exist' )
166- self .check_filename_in_dlerror (str (cm .exception ))
167150
168151 @unittest .skipUnless (hasattr (_ctypes , 'dlopen' ),
169152 'test requires _ctypes.dlopen()' )
@@ -185,9 +168,8 @@ def test_localized_error_dlopen(self):
185168 @configure_locales
186169 def test_localized_error_dlsym (self ):
187170 dll = _ctypes .dlopen (self .libc_filename )
188- with self .assertRaises (OSError ) as cm :
171+ with self .assertRaises (OSError ):
189172 _ctypes .dlsym (dll , 'this_name_does_not_exist' )
190- self .check_filename_in_dlerror (str (cm .exception ))
191173
192174
193175if __name__ == "__main__" :
0 commit comments