pleiszenburg / zugbruecke

Calling routines in Windows DLLs from Python scripts running under Linux, MacOS or BSD
https://zugbruecke.readthedocs.io/en/latest/
GNU Lesser General Public License v2.1
111 stars 11 forks source link

argtypes definitions with one single argument are not raising a TypeError if not passed as a tuple or list #21

Closed s-m-e closed 6 years ago

s-m-e commented 6 years ago

See here.

s-m-e commented 6 years ago

This is how ctypes expects the definition of a single argument:

>>> import ctypes 
>>> dll = ctypes.cdll.msvcrt
>>> demo = dll.sqrt
>>> demo.argtypes = (ctypes.c_double,)
>>> demo.restype = ctypes.c_double
>>> demo(9.0)
3.0

This is how it throws an error if the argtypes are not initialized with a tuple or list:

>>> import ctypes
>>> dll = ctypes.cdll.msvcrt
>>> demo = dll.sqrt
>>> demo.argtypes = ctypes.c_double   
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: _argtypes_ must be a sequence of types

zugbruecke currently crashes when parsing demo.argtypes = ctypes.c_double, which is sort of right - it should actually throw a TypeError instead (#8).

s-m-e commented 6 years ago

Fixed in 679b383.

s-m-e commented 6 years ago

Fix released as part of v0.0.8.