[IronPython] __main__ module and global variables issue...

Shri Borde Shri.Borde at microsoft.com
Mon Jul 3 19:10:23 CEST 2006

There should be nothing special about the default scope, other than the fact that all the PythonEngine APIs like Evaluate, Execute have an overload that implicitly operate on the default scope. The DefaultScope is created just like any other scope.

Is it possible that you are executing some code that sets the values of your variables to None? You could put a breakpoint in ModuleScope.SetLocal and ModuleScope.SetGlobal to watch for all assignments.

Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Alex Henderson
Sent: Saturday, July 01, 2006 9:46 PM
To: 'Discussion of IronPython'
Subject: [IronPython] __main__ module and global variables issue...

Our system is using IP for an expression engine - in most cases we are
creating a new ModuleScope and evaluating against it, which works fine ie.
On setup we assign some global variables, and generate functions on the fly
for the lifetime of the module which are evaluated, and thrown away after

However I've also been using the default module scope for evaluating some
expressions, and I seem to be getting some odd behavior... where any global
variables we've assigned (in this case, "_container", "_log" and "_config")
at some indeterminate point end up reverting to None values - the names
still exist, but the references to the class instances have gone.

This is only happening for the default module scope, everything works as
expected when we create our own module scope... and there's no code being
executed other then that which sets the global variables in the first place,
which is definitely assigning non-null values (I've changed the methods to
set then fetch the value to make sure).

Is there perhaps something different between a scope I've created using new
ModuleScope(), and the PythonEngine's DefaultModuleScope with regards to
global variables?


 - Alex

users mailing list
users at lists.ironpython.com

More information about the Ironpython-users mailing list