[pypy-dev] Re: [pypy-svn] r8078 - pypy/trunk/src/pypy/interpreter

holger krekel hpk at trillke.net
Fri Jan 7 12:39:41 CET 2005


On Wed, Jan 05, 2005 at 17:35 +0100, tismer at codespeak.net wrote:
> Author: tismer
> Date: Wed Jan  5 17:35:47 2005
> New Revision: 8078
> 
> Modified:
>    pypy/trunk/src/pypy/interpreter/pyopcode.py
> Log:
> changed LOAD_GLOBAL to support the flow space better.
> In case of a NameError, where the space does not define NameError,
> we raise a real NameError with a message.
> 
> Modified: pypy/trunk/src/pypy/interpreter/pyopcode.py
> ==============================================================================
> --- pypy/trunk/src/pypy/interpreter/pyopcode.py	(original)
> +++ pypy/trunk/src/pypy/interpreter/pyopcode.py	Wed Jan  5 17:35:47 2005
> @@ -525,8 +525,13 @@
>                  if not e.match(f.space, f.space.w_KeyError):
>                      raise
>                  message = "global name '%s' is not defined" % varname
> -                w_exc_type = f.space.w_NameError
> -                w_exc_value = f.space.wrap(message)
> +                try:
> +                    w_exc_type = f.space.w_NameError
> +                    w_exc_value = f.space.wrap(message)
> +                except AttributeError:
> +                    # object space does not support it, so crash really
> +                    raise NameError, (message +
> +                        ", but %s has no NameError!" % f.space)
>                  raise OperationError(w_exc_type, w_exc_value)
>          f.valuestack.push(w_value)

I don't understand this change.  Why is raising a NameError
for not finding space.w_NameError better than just an
AttributeError?  This seems to me like mixing different levels
(application level and interpreter level).  It seems the flow
object space could easily provide its own w_NameError and
then you can check the usual way, catching an OperationError and 
then for e.match(space, space.w_NameError) without changing 
the interpreter. 

cheers (and happy new year to you, christian!), 

    holger



More information about the Pypy-dev mailing list