[Python-Dev] Guarantee the success of some object creation C API functions (original) (raw)

Chris Angelico rosuav at gmail.com
Mon May 1 17:52:26 EDT 2017


On Tue, May 2, 2017 at 6:52 AM, Terry Reedy <tjreedy at udel.edu> wrote:

The promise makes it clear that breaking the property is a bug to be fixed. It only decreases the probability for someone who has read the promise. Unfortunately, 'never fail' is hard to test ;-).

Aside from straight-up bugs, how can one of these functions fail? Is memory allocation failure the only way? If so, the proposed implementation (private references to pre-created singletons) ought to guarantee that, to the exact extent that anything else can be guaranteed.

(Or is that your point - that "never fail" is always "modulo bugs"?)

Incidentally, this guarantee, if implemented the obvious way, will also mean that (), "", 0, etc are singletons. People talk casually about the "empty tuple singleton", but I don't think it's actually guaranteed anywhere.

ChrisA



More information about the Python-Dev mailing list