@@ -404,6 +404,16 @@ class Cls(Structure):
404404 self .assertEqual (len (ws_typ ), 0 , ws_typ )
405405 self .assertEqual (len (ws_ptr ), 0 , ws_ptr )
406406
407+ def test_pointer_proto_missing_argtypes_error (self ):
408+ class BadType (ctypes ._Pointer ):
409+ # _type_ is intentionally missing
410+ pass
411+
412+ func = ctypes .pythonapi .Py_GetVersion
413+ func .argtypes = (BadType ,)
414+
415+ with self .assertRaises (ctypes .ArgumentError ):
416+ func (None )
407417
408418class PointerTypeCacheTestCase (unittest .TestCase ):
409419 # dummy tests to check warnings and base behavior
@@ -473,23 +483,6 @@ class C(Structure):
473483 ptr .set_type (c_int )
474484 self .assertIs (ptr ._type_ , c_int )
475485
476- class TestPointerStringProto (unittest .TestCase ):
477- def test_pointer_string_proto_argtypes_error (self ):
478- with self .assertWarns (DeprecationWarning ):
479- BadType = ctypes .POINTER ("BugTrigger" )
480-
481- if os .name == "nt" :
482- libc = ctypes .WinDLL ("kernel32.dll" )
483- func = libc .GetCurrentProcessId
484- else :
485- libc = ctypes .CDLL (None )
486- func = libc .getpid
487-
488- func .argtypes = (BadType ,)
489-
490- with self .assertRaises (ctypes .ArgumentError ):
491- func (ctypes .byref (ctypes .c_int (0 )))
492-
493486
494487if __name__ == '__main__' :
495488 unittest .main ()
0 commit comments