Python.Runtime causes casting errors when setting global vars

Environment

  • Pythonnet version: 2.2.2, strongly signed post-installation
  • Python version: 2.7, 32bit
  • Operating System: Windows 7, 64bit

Details

  • Describe what you were trying to get done.
GLOB=1
def test_glob():
	return GLOB
Microsoft (R) Roslyn C# Compiler version 1.2.0.60425
Loading context from 'CSharpInteractive.rsp'.
Type "#help" for more information.
> #r "C:\Python\Python27_32b\Lib\site-packages\Python.Runtime.dll"
> using Python.Runtime;
> dynamic test_glob; using (Py.GIL()) { test_glob = Py.Import("test_glob"); }
> test_glob.GLOB
[1]
> test_glob.GLOB=1
Unable to cast object of type 'System.Int32' to type 'Python.Runtime.PyObject'.
  + Python.Runtime.PyObject.TrySetMember(System.Dynamic.SetMemberBinder, object)
  + System.Dynamic.UpdateDelegates.UpdateAndExecute2<T0, T1, TRet>(System.Runtime.CompilerServices.CallSite, T0, T1)