Nick Coghlan <[EMAIL PROTECTED]> writes:

> PyInt_AsLong can already fail with OverflowError

> it accepts arbitrary objects and coerces them to integers via
> __int__, instead of just accepting PyInt instances.

If it calls __int__, it can fail with any exception resulting from
user code.

Grepping sources (2.4.2) reveals that usages are split into 4 groups:

1. Calling PyInt_AsLong only after PyInt_Check succeeds.

2. Handling the case when PyInt_AsLong returns -1 and PyErr_Occurred(),
   or just when PyErr_Occurred().

3. Doing both (e.g. Modules/mmapmodule.c). The test is superfluous
   but harmless.

4. Doing neither (e.g. Modules/parsermodule.c, Modules/posixmodule.c,
   Modules/selectmodule.c and possibly more). This is potentially buggy.

-- 
   __("<         Marcin Kowalczyk
   \__/       [EMAIL PROTECTED]
    ^^     http://qrnik.knm.org.pl/~qrczak/
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to