Re: [Python-Dev] Guarantee the success of some object creation C API functions

2017-05-02 Thread Brett Cannon
On Mon, 1 May 2017 at 21:19 Nick Coghlan wrote: > On 2 May 2017 at 07:52, Chris Angelico wrote: > > On Tue, May 2, 2017 at 6:52 AM, Terry Reedy 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 re

Re: [Python-Dev] Guarantee the success of some object creation C API functions

2017-05-01 Thread Serhiy Storchaka
On 02.05.17 00:52, Chris Angelico wrote: Aside from straight-up bugs, how can one of these functions fail? Is memory allocation failure the only way? Yes, memory allocation failure is the only way. In normal Python build this can happen only at early stage of the interpreter initialization, u

Re: [Python-Dev] Guarantee the success of some object creation C API functions

2017-05-01 Thread Nick Coghlan
On 2 May 2017 at 07:52, Chris Angelico wrote: > On Tue, May 2, 2017 at 6:52 AM, Terry Reedy 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 te

Re: [Python-Dev] Guarantee the success of some object creation C API functions

2017-05-01 Thread Chris Angelico
On Tue, May 2, 2017 at 6:52 AM, Terry Reedy 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

Re: [Python-Dev] Guarantee the success of some object creation C API functions

2017-05-01 Thread Terry Reedy
On 5/1/2017 5:50 AM, Serhiy Storchaka wrote: I want to add promises to public C API functions that create trivial instances of immutable basic types (integers 0 and 1, empty tuple, string and bytes object) -- PyLong_FromLong(0), PyLong_FromLong(1), PyTuple_New(0), PyUnicode_FromStringAndSize(NULL

[Python-Dev] Guarantee the success of some object creation C API functions

2017-05-01 Thread Serhiy Storchaka
I want to add promises to public C API functions that create trivial instances of immutable basic types (integers 0 and 1, empty tuple, string and bytes object) -- PyLong_FromLong(0), PyLong_FromLong(1), PyTuple_New(0), PyUnicode_FromStringAndSize(NULL, 0), PyUnicode_FromString(""), PyBytes_FromStr