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 loewis
Recipients brian.curtin, loewis, meador.inge, plynch76, r.david.murray, tim.golden
Date 2012-04-16.13:45:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1334583922.92.0.741599931901.issue14597@psf.upfronthosting.co.za>
In-reply-to
Content
In principle, it should be possible (but perhaps not desirable, see below) to call FreeLibrary in a CDLL's __del__. However, since this would be a new feature, it can't go into 2.7. Patches are welcome; make sure to support both FreeLIbrary and dlclose.

There is a general issue with closing/freeing DLLs: if they are still referenced somewhere (e.g. in an atexit function, a C++ virtual method table, or on the call stack of another thread), then a later access to the code will crash the interpreter. In a typical DLL today (including all Python extension modules), the likelihood of crashes is close to 100%. For that reason, it's probably not a good idea to have ctypes auto-close DLLs; instead, it should be an opt-in mechanism.

For most ctypes uses, closing is irrelevant, since people typically access system libraries that are independently loaded anyway, so closing them would not have any effect.
History
Date User Action Args
2012-04-16 13:45:22loewissetrecipients: + loewis, tim.golden, r.david.murray, brian.curtin, meador.inge, plynch76
2012-04-16 13:45:22loewissetmessageid: <1334583922.92.0.741599931901.issue14597@psf.upfronthosting.co.za>
2012-04-16 13:45:22loewislinkissue14597 messages
2012-04-16 13:45:22loewiscreate