Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Parameter resolution for integer types doesn't work in some cases #1523

Closed
@slide

Description

@slide

Environment

  • Pythonnet version: master
  • Python version: 3.7
  • Operating System: Windows 10
  • .NET Runtime: .NET 4.8

Details

  • Describe what you were trying to get done.

Calling .NET methods from Python

  • What commands did you run to trigger this issue?

Given a class like the following, any value you pass for address to the first MethodA will cause the exception underneath, it looks like because when needsResolution is true, the Converter will see the the value as an Int32 in GetTypeByAlias since in 3.7 there is no distinction between int and long anymore.

publicclassMethodResolutionInt{publicIEnumerable<byte>MethodA(ulongaddress,intsize){returnnewbyte[10];}publicintMethodA(stringdummy,ulongaddress,intsize){return0;}}
mri=MethodResolutionInt()data=list(mri.MethodA(0x1000,10))assertlen(data)==10assertdata[0]==0data=list(mri.MethodA(0x100000000,10))assertlen(data)==10assertdata[0]==0
  • If there was a crash, please include the traceback here.
Python.Runtime.PythonException: Expected UInt64, got Int32The above exception was the direct cause of the following exception:Python.Runtime.PythonException: Expected UInt64, got Int32The above exception was the direct cause of the following exception:System.ArgumentException: Expected UInt64, got Int32 in method System.Collections.Generic.IEnumerable`1[System.Byte] MethodA(UInt64, Int32) ---> Python.Runtime.PythonException: Expected UInt64, got Int32   --- End of inner exception stack trace ---The above exception was the direct cause of the following exception:Python.Runtime.PythonException: Expected UInt64, got Int32The above exception was the direct cause of the following exception:System.ArgumentException: Expected UInt64, got Int32 in method System.Collections.Generic.IEnumerable`1[System.Byte] MethodA(UInt64, Int32) ---> Python.Runtime.PythonException: Expected UInt64, got Int32   --- End of inner exception stack trace ---The above exception was the direct cause of the following exception:System.AggregateException: One or more errors occurred. ---> System.ArgumentException: Expected UInt64, got Int32 in method System.Collections.Generic.IEnumerable`1[System.Byte] MethodA(UInt64, Int32) ---> Python.Runtime.PythonException: Expected UInt64, got Int32   --- End of inner exception stack trace ---   --- End of inner exception stack trace ------> (Inner Exception #0) System.ArgumentException: Expected UInt64, got Int32 in method System.Collections.Generic.IEnumerable`1[System.Byte] MethodA(UInt64, Int32) ---> Python.Runtime.PythonException: Expected UInt64, got Int32   --- End of inner exception stack trace ---<---

I have a PR almost ready with A solution to the issue, but it may not be the correct solution.

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp