[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-3000
Subject:    Re: [Python-3000] PyInt_AS_LONG error checking
From:       Georg Brandl <g.brandl () gmx ! net>
Date:       2007-10-23 19:19:45
Message-ID: fflhd8$997$1 () ger ! gmane ! org
[Download RAW message or body]

Martin v. Löwis schrieb:
>> PyInt_AS_LONG is #defined as PyLong_AsLong since the int/long unification.
>> 
>> However, most places that use this macro (and also places that
>> use PyInt_AsLong) assume it cannot fail which means that an exception
>> won't be properly propagated in that case.
>> 
>> If I don't overlook something here, all these places have to be fixed...
> 
> I think you do overlook something. Many of these places do
> PyInt_CheckExact before invoking the macro. PyInt_CheckExact includes
> _PyLong_FitsInLong, so if that test returns true, then PyInt_AS_LONG
> cannot fail.
> 
> So the only places that need to be fixed are those where PyInt_AS_LONG
> isn't protected by PyInt_CheckExact.

Ok, thanks, that explains it.

Georg

BTW, _PyLong_FitsInLong says "/* conservative estimate */" -- it doesn't
really allow the whole range of C long...




_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: http://mail.python.org/mailman/options/python-3000/python-3000%40progressive-comp.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic