8000 Parameter resolution for integer types doesn't work in some cases · Issue #1523 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

Skip to content
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.

public class MethodResolutionInt
    {
        public IEnumerable<byte> MethodA(ulong address, int size)
        {
            return new byte[10];
        }

        public int MethodA(string dummy, ulong address, int size)
        {
            return 0;
        }
    }
mri = MethodResolutionInt()
data = list(mri.MethodA(0x1000, 10))
assert len(data) == 10
assert data[0] == 0

data = list(mri.MethodA(0x100000000, 10))
assert len(data) == 10
assert data[0] == 0
  • If there was a crash, please include the traceback here.
Python.Runtime.PythonException: Expected UInt64, got Int32

The above exception was the direct cause of the following exception:
Python.Runtime.PythonException: Expected UInt64, got Int32

The 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 Int32

The 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

      0