[Python-checkins] r62787 - python/trunk/Lib/warnings.py

Brett Cannon brett at python.org
Wed May 7 21:03:00 CEST 2008


On Wed, May 7, 2008 at 11:47 AM, Benjamin Peterson
<musiccomposition at gmail.com> wrote:
> On Wed, May 7, 2008 at 1:40 PM, Brett Cannon <brett at python.org> wrote:
>  >  I purposefully didn't put this check in the Python code as the proper
>  >  exception will propagate and callable is not in 3.x for a reason; it
>  >  is not exactly a reliable check.
>
>  The same is true of the C code. Before I put the goto in, it just gave
>  a TypeError: "type 'whatever' is not callable' Should I remove both?

No, the C fix is right; I screwed up and forgot to return the NULL to
have the exception propagate. The C code's check is that way because
it is the only reliable way to check for the 'line' argument (unless
you can come up with a better way) directly. The other option would be
to have PyObject_CallFunctionObjArgs() happen and if it throws a fit
because it didn't get something callable to let that exception
propagate.

I just tend to use LBYL in C and EAFP in Python.

-Brett


More information about the Python-checkins mailing list