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

Curt Hagenlocher curt at hagenlocher.org
Tue Jun 24 13:47:05 CEST 2008


Despite "locals" being involved, 16884 is not a related issue.  The problem
in 16884 is with the delegate that's created for function a and the way
that it's bound to the context in which the function was declared.  And
alas, 16884 is not fixed in beta 3.


On Tue, Jun 24, 2008 at 12:41 AM, Jonathan Slenders <jonathan at slenders.be>
wrote:

> 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
>>
>
>
> _______________________________________________
> 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://mail.python.org/pipermail/ironpython-users/attachments/20080624/efa37c8b/attachment.html>


More information about the Ironpython-users mailing list