[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: starting to dive into python package bugs



On Jul 02, 2013, at 09:42 PM, Stéphane Blondon wrote:

>I found in 'http://udd.debian.org/cgi-bin/python_bugs.cgi' that the
>'Python string exceptions' are listed several times and I think the
>base to fix it is easy:
>replacing "raise 'error message' " by "raise Exception('error
>message')" should fix the problem. I guess the fix will be more or
>less the same for each ones so it will not really hard to do (so an
>easy introduction into the team).

Well, be careful though because now you also have to check every attempt to
catch these exceptions, not just in the library you're changing, but every
client of that library (i.e. at least all its reverse dependencies).

The reason is that if some code is trying to:

    except 'error message'

this will fail if the raise site is changed.  Of course, such clients are just
getting lucky and/or exploiting an unguaranteed CPython implementation quirk
for it even to work in the first place.

What works, but is still icky, is to do something like this:

    ERROR_MESSAGE = 'error message'
    ...
    raise ERROR_MESSAGE
    ...
    except ERROR_MESSAGE:

Certainly I'd consider this a bug in upstream even for Python 2, so fixes
should go upstream if possible.

-Barry


Reply to: