Message158538
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. |
|
Date |
User |
Action |
Args |
2012-04-17 10:38:00 | kristjan.jonsson | set | recipients:
+ kristjan.jonsson, tim.peters, loewis, rhettinger, amaury.forgeotdarc, pitrou, dstanek, stutzbach, asvetlov, Jim.Jewett |
2012-04-17 10:38:00 | kristjan.jonsson | set | messageid: <1334659080.54.0.88058540041.issue9141@psf.upfronthosting.co.za> |
2012-04-17 10:37:59 | kristjan.jonsson | link | issue9141 messages |
2012-04-17 10:37:59 | kristjan.jonsson | create | |
|