Kristján Valur Jónsson <krist...@ccpgames.com> added the comment: I _think_ the only python related things you can do from tp_clear() is Py_DECREF(), this is what I mean by trivial. This is the reason, for example, that special care was done with generators. An IO object could of course do non-python operations such as closing files and freeing buffers.
If file.close() can be an arbitrary python method, then it can no more be called from gc, than an object's __del__ method. This would not be a regression, this would be a fact of life. The point of _this_ defect (issue 9141) is to allow objects to be smarter about this, being able to tell gc if their finalizers are trivial or not. I will start a discussion on python-dev to see if anyone knows exactly why these limitations are in place, and what they are. They are not documented in the source code. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9141> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com