This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients Okko.Willeboordse, eryksun, paul.moore, python-dev, steve.dower, tim.golden, vstinner, zach.ware
Date 2016-09-11.09:19:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473585551.24.0.210745057455.issue27932@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-09-11 09:19:11eryksunsetrecipients: + eryksun, paul.moore, vstinner, tim.golden, python-dev, Okko.Willeboordse, zach.ware, steve.dower
2016-09-11 09:19:11eryksunsetmessageid: <1473585551.24.0.210745057455.issue27932@psf.upfronthosting.co.za>
2016-09-11 09:19:11eryksunlinkissue27932 messages
2016-09-11 09:19:11eryksuncreate