Message275753
Limiting the pointer-type cache could be a problem. It's expected that POINTER() returns a reference to an existing pointer type. ctypes uses Python types to ensure compatible C data types. For example:
LP_c_int = ctypes.POINTER(ctypes.c_int)
class LP_c_int_uncached(ctypes._Pointer):
_type_ = ctypes.c_int
>>> arr = (LP_c_int * 2)()
>>> ctypes.POINTER(ctypes.c_int) is LP_c_int
True
>>> arr[0] = ctypes.POINTER(ctypes.c_int)()
>>> arr[1] = LP_c_int_uncached()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: incompatible types, LP_c_int_uncached instance
instead of LP_c_int instance
The docs could warn users that the cache used by ctypes.POINTER(), and implicitly by ctypes.pointer(), will leak memory if it's called with a type that's created at function scope instead of at module or class-body scope. |
|
| Date |
User |
Action |
Args |
| 2016-09-11 09:19:11 | eryksun | set | recipients:
+ eryksun, paul.moore, vstinner, tim.golden, python-dev, Okko.Willeboordse, zach.ware, steve.dower |
| 2016-09-11 09:19:11 | eryksun | set | messageid: <[email protected]> |
| 2016-09-11 09:19:11 | eryksun | link | issue27932 messages |
| 2016-09-11 09:19:11 | eryksun | create | |
|