Skip to content

Python.Runtime causes casting errors when setting global vars #420

Closed

Description

@den-run-ai

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)

Activity

  1. den-run-ai commented on Mar 6, 2017

    @den-run-ai
    ContributorAuthor

    If this .NET issue, I'm using .NET 4.0

  2. vmuriart commented on Mar 7, 2017

    @vmuriart
    Contributor

    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.

  3. vmuriart commented on Mar 7, 2017

    @vmuriart
    Contributor

    All tests work as well post signing.

  4. den-run-ai commented on Mar 7, 2017

    @den-run-ai
    ContributorAuthor

    Weird, I reproduced the issue on multiple machines, but using our internal key. Let me check with other keys.

  5. vmuriart commented on Mar 8, 2017

    @vmuriart
    Contributor

    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.

  6. den-run-ai commented on Mar 8, 2017

    @den-run-ai
    ContributorAuthor

    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 :)

  7. den-run-ai commented on Mar 8, 2017

    @den-run-ai
    ContributorAuthor

    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 :)

  8. 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
  9. vmuriart commented on Mar 8, 2017

    @vmuriart
    Contributor

    I wonder which commit fixed it. I'll add the test I used earlier.

  10. vmuriart commented on Mar 8, 2017

    @vmuriart
    Contributor

    Test added. closing since solved at some point between v2.2.2 and latest commit.

  11. vmuriart commented on Mar 8, 2017

    @vmuriart
    Contributor

    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.

  12. added a commit that references this issue on Jun 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions