[Python-Dev] Re: tp_clear return value (original) (raw)

Neil Schemenauer nas@python.ca
Wed, 9 Apr 2003 15:48:10 -0400


On Wed, Apr 09, 2003 at 03:33:47PM -0400, Jeremy Hylton wrote:

Why does tpclear have a return value? All the code I've seen returns 0, but the only place that clear is called doesn't inspect its return value.

I guess I would have to say overdesign. I was thinking that tp_clear and tp_traverse could somehow be used by things other than the GC. In retrospect that doesn't seem likely or even possible. The GC has pretty specific requirements.

In retrospect, I think both tp_traverse and tp_clear should have returned "void". That would have made implementing those methods easier. Testing for errors in tp_traverse methods is silly since nothing returns an error, and, even if it did, the GC couldn't handle it.

:-(

How do we sort this out? I suppose one step would be to document that the return values of tp_traverse and tp_clear are ignored. If we agree on that, I volunteer to go through the code and remove the useless tests for errors in the tp_traverse methods.

Neil