[pypy-dev] Re: [gmane.comp.python.pypy] deep breakage
Michael Hudson
mwh at python.net
Mon Jun 9 11:36:08 MEST 2003
I wonder if I can post via gmane yet...
Armin Rigo <arigo at tunes.org> writes:
> Hello Michael,
>
> On Sat, Jun 07, 2003 at 08:38:32PM +0100, Michael Hudson wrote:
>> try:
>> "x" + 1
>> except TypeError, e:
>> raise e
>>
>> because here 'e' gets bound to a *string* and then this is what's
>> reraised.
>
> This is the same problem as in CPython. Most failing internal operations call
> PyErr_SetString(), which causes a string to be used as the exception value.
> The hack is that when the user code reaches an 'except' clauses the exception
> is "normalized", which translates the pair "TypeError class + string" into the
> pair "TypeError class + TypeError instance".
I think I now have code that does this, after modifying
decode_code_arguments to not try to catch IndexError (that one was fun
to find!).
> We might either choose to mimic this behavior or clean it up a bit, e.g. by
> always using internally a single object as the exception instance.
I couldn't get normalizing the exception at raise time (roughly what
you mean here, right?) to work... there may be a reason other than
performance that CPython does it this way.
> String exceptions are being deprecated, but still we could
> reasonably emulate them, say by inventing a StringException
> class. This would isolate the hacky parts around this specific class
> (like setting sys.exc_type to something else than
> current_exception.__class__ for this particular case).
I'm not sure I understand...
Cheers,
M>
--
Two decades later, well-known hacker Henry Spencer described the
Perl scripting language as a "Swiss-Army chainsaw", intending to
convey his evaluation of the language as exceedingly powerful but
ugly and noisy and prone to belch noxious fumes. -- the jargon file
More information about the pypy-dev
mailing list