[New-bugs-announce] [issue15240] ctype Structure keeps reference to function pointers

Vincent Pelletier report at bugs.python.org
Mon Jul 2 21:29:42 CEST 2012


New submission from Vincent Pelletier <plr.vincent at gmail.com>:

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/

----------
components: ctypes
files: reproduce.py
messages: 164534
nosy: vpelletier
priority: normal
severity: normal
status: open
title: ctype Structure keeps reference to function pointers
type: behavior
versions: Python 2.6, Python 2.7, Python 3.2
Added file: http://bugs.python.org/file26234/reproduce.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15240>
_______________________________________


More information about the New-bugs-announce mailing list