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

Guido van Rossum guido@python.org
Wed, 09 Apr 2003 15:52:03 -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.

[In response, Neil admitted]

I guess I would have to say overdesign. I was thinking that tpclear and tptraverse 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 tptraverse and tpclear should have returned "void". That would have made implementing those methods easier. Testing for errors in tptraverse 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 tptraverse and tpclear are ignored. If we agree on that, I volunteer to go through the code and remove the useless tests for errors in the tptraverse methods.

That's a good first step. Unfortunately changing the declaration to void will break 3rd party extensions so that will be too painful.

--Guido van Rossum (home page: http://www.python.org/~guido/)