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.

classification
Title: ctype Structure keeps reference to function pointers
Type: behavior Stage:
Components: ctypes Versions: Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jcea, vpelletier
Priority: normal Keywords:

Created on 2012-07-02 19:29 by vpelletier, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
reproduce.py vpelletier, 2012-07-02 19:29 Test case (needs objgraph)
Messages (2)
msg164534 - (view) Author: Vincent Pelletier (vpelletier) Date: 2012-07-02 19:29
When storing a ctype function pointer in a ctype structure field, a reference remains even when that field is overwritten with some values:
- None
- None cast into a function pointer
But the reference is somehow removed when overwriting the field with a "real" function pointer (a lambda in attached test case).

This causes problem when the structure is a class property and function pointer is created out of a method of the same class: a circular reference is created, which is not garbage-collected.

To run the attached test case, you need objgraph[1], and to uncomment one (or none) of the commented-out lines in "close" method.

[1] http://mg.pov.lt/objgraph/
msg164535 - (view) Author: Vincent Pelletier (vpelletier) Date: 2012-07-02 19:40
Trying to generate a graph on several python and several uncommented lines, I see that my test case is incomplete. Time to review my copy.
History
Date User Action Args
2022-04-11 14:57:32adminsetgithub: 59445
2012-07-02 19:51:59jceasetnosy: + jcea
2012-07-02 19:40:37vpelletiersetstatus: open -> closed
resolution: not a bug
messages: + msg164535
2012-07-02 19:29:42vpelletiercreate