[IronPython] NameError: locals() is not defined?

Jonathan Slenders jonathan at slenders.be
Tue Jun 24 00:41:56 PDT 2008


Does this mean that issue 16884 will be fixed as well in beta 3?

2008/6/24 Dino Viehland <dinov at exchange.microsoft.com>:

> It seems to be fixed in beta 3.  It's probably a bug in the interpreter as
> writing the snippet out and executing w/ execfile, which doesn't run under
> the interpreter, works in beta 2 as well.
>
> The reason it got silently fixed was because between the two versions the
> interpreter was moved from M.S.Core.dll up to M.S.dll and a bunch of bugs
> were fixed along the way.  In beta 3 the interpreter is also now always used
> for exec or eval - previously it avoided certain constructs it couldn't
> support.
>
> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] On Behalf Of Dan Eloff
> Sent: Monday, June 23, 2008 7:02 PM
> To: Discussion of IronPython
> Subject: [IronPython] NameError: locals() is not defined?
>
> In IronPython b2 I get:
>
> >>> s = '''
> ... def body(context):
> ...     def ccall():
> ...             body = lambda: None
> ...             context.update(locals())
> ...     ccall()
> ...
> ... '''
> >>> d = {}
> >>> exec s in d
> >>> c = {}
> >>> d['body'](c)
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "", line unknown, in Interpreted_body_1
> NameError: name 'locals' is not defined
>
> This works fine in CPython:
>
> >>> s = '''
> ... def body(context):
> ...     def ccall():
> ...             body = lambda: None
> ...             context.update(locals())
> ...     ccall()
> ...
> ... '''
> >>> exec s in d
> >>> c = {}
> >>> d['body'](c)
> >>> c
> {'body': <function <lambda> at 0x0359CCB0>, 'context': {...}}
>
> Any idea why?
>
> Thanks,
> -Dan
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20080624/c7335599/attachment.htm>


More information about the Users mailing list