metaclasses and Exceptions
Michael Hudson
mwh at python.net
Tue Aug 3 08:56:58 EDT 2004
python at rcn.com (Raymond Hettinger) writes:
> Michael Hudson <mwh at python.net> wrote > One of the areas where PyPy is
> different from CPython is that there
> > are no old-style classes or instances, so exceptions are necessarily
> > new-style. This has caused no real problems on any Python program
> > we've tried it on yet...
>
> How does PyPy distinguish between instance and class arguments to
> raise?
"isinstance(x, type)", iirc.
The code is in this file:
http://codespeak.net/svn/pypy/trunk/src/pypy/interpreter/pyframe.py
in the function app_normalize_exception(). There's a kind of horrible
issue if you do things like:
class Nasty(type, Exception):
pass
raise Nasty()
I can't remember what PyPy does here (the answer is quite possibly
"break").
> Given: raise X
> Does it pass X or X()?
Depends on X! Has to, really, or we certainly would have had more
problems from this than we've had.
Cheers,
mwh
--
"declare"? my bogometer indicates that you're really programming
in some other language and trying to force Common Lisp into your
mindset. this won't work. -- Erik Naggum, comp.lang.lisp
More information about the Python-list
mailing list