You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python.Runtime causes casting errors when setting global vars #420
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=1deftest_glob():
returnGLOB
Microsoft(R) Roslyn C# Compiler version 1.2.0.60425
Loading context from 'CSharpInteractive.rsp'.Type"#help" for moreinformation.> #r "C:\Python\Python27_32b\Lib\site-packages\Python.Runtime.dll">using Python.Runtime;>dynamictest_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)
The above example works without signing the assembly?
Looks to be an issue with whatever post-build signing you are using or an issue only with Interactive (which doesn't work for me on any version of pythonnet). I added your test to the embedded tests on my local machine and ran them before and after strongname signing them as part of the build.
I think its an issue w the 3rd party party program you mentioned you were using to sign the assemblies. I signed them as part of the build process, you can try with the artifacts from this build.
I'll push the changes from the master branch after v2.3.0 release.
changed the title [-]strongly signed Python.Runtime causes casting errors when setting global vars[/-][+]Python.Runtime causes casting errors when setting global vars[/+]on Mar 8, 2017
32bit python is probably why it didn't work for me. weird behavior though, ive seen it mentioned a couple times now in other issues to use 32bit for hooking the debugger too.
Activity
den-run-ai commentedon Mar 6, 2017
If this .NET issue, I'm using .NET 4.0
vmuriart commentedon Mar 7, 2017
The above example works without signing the assembly?
Looks to be an issue with whatever post-build signing you are using or an issue only with Interactive (which doesn't work for me on any version of pythonnet). I added your test to the embedded tests on my local machine and ran them before and after strongname signing them as part of the build.
No issues either way.
vmuriart commentedon Mar 7, 2017
All tests work as well post signing.
den-run-ai commentedon Mar 7, 2017
Weird, I reproduced the issue on multiple machines, but using our internal key. Let me check with other keys.
vmuriart commentedon Mar 8, 2017
I think its an issue w the 3rd party party program you mentioned you were using to sign the assemblies. I signed them as part of the build process, you can try with the artifacts from this build.
I'll push the changes from the
masterbranch afterv2.3.0release.den-run-ai commentedon Mar 8, 2017
BTW, I use scriptcs, csi, and clrmagic interactively without any issues. csi requires 32-bit Python but it has very nice intellisense.
I'm guessing that my issue is specific to localized machine(s). I cannot reproduce with various keys, with VS or StrongNameSigner on Windows 10.
But the issue is reproducible on Windows 7.
Maybe I should start suspecting my antivirus :)
den-run-ai commentedon Mar 8, 2017
ok, it looks like it is failing even without strong-named assembly.
This issue is resolved in the latest master, but failing on 2.2.2.
We need to add these tests for auto-fixed regression :)
[-]strongly signed Python.Runtime causes casting errors when setting global vars[/-][+]Python.Runtime causes casting errors when setting global vars[/+]vmuriart commentedon Mar 8, 2017
I wonder which commit fixed it. I'll add the test I used earlier.
Add test for pyscript global variable casting
vmuriart commentedon Mar 8, 2017
Test added. closing since solved at some point between
v2.2.2and latest commit.vmuriart commentedon Mar 8, 2017
32bit python is probably why it didn't work for me. weird behavior though, ive seen it mentioned a couple times now in other issues to use 32bit for hooking the debugger too.
Add test for pyscript global variable casting
Rebase with master (#2)