Open
Description
Environment
- Pythonnet version:
3.0.2 from pip
- Python version:
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
- Operating System:
Debian GNU/Linux 12 (bookworm); Linux localhost 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.38-1 (2023-07-14) x86_64 unknown unknown linux
- .NET Runtime:
8.0.100-preview.3.23178.7 [/home/jorge/.dotnet/sdk]
Details
-
Describe what you were trying to get done.
I was exploring pythonnet inside Python REPL (by the way it's a very amazing library!) and I tried to useT[].Address(int)
, but when I called Address using wrong arguments, it crashes the interpreter instead of throwing an exception.
The same thing happens when trying to useT[].Get
andT[].Set
. -
What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
>>> import clr_loader, pythonnet
>>> pythonnet.set_runtime(clr_loader.get_coreclr(runtime_config="/home/jorge/runtimeconfig.json", dotnet_root="/home/jorge/.dotnet"))
>>> pythonnet.load()
>>> import System
>>> array = System.Array[int]((1,))
>>> array.Address()
>>> # runtime being loaded and array created the same way as first example
>>> array.A# press TAB here
- If there was a crash, please include the traceback here.
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'key')
at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
at System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
at Python.Runtime.MethodBinder.MatchesArgumentCount(Int32 positionalArgumentCount, ParameterInfo[] parameters, Dictionary`2 kwargDict, Boolean& paramsArray, ArrayList& defaultArgList, Int32& kwargsMatched, Int32& defaultsNeeded) in /tmp/build-via-sdist-zkttv147/pythonnet-3.0.2/src/runtime/MethodBinder.cs:line 775
at Python.Runtime.MethodBinder.Bind(BorrowedReference inst, BorrowedReference args, Dictionary`2 kwargDict, MethodBase[] methods, Boolean matchGenerics) in /tmp/build-via-sdist-zkttv147/pythonnet-3.0.2/src/runtime/MethodBinder.cs:line 392
at Python.Runtime.MethodBinder.Bind(BorrowedReference inst, BorrowedReference args, BorrowedReference kw, MethodBase info, MethodBase[] methodinfo) in /tmp/build-via-sdist-zkttv147/pythonnet-3.0.2/src/runtime/MethodBinder.cs:line 366
at Python.Runtime.MethodBinder.Invoke(BorrowedReference inst, BorrowedReference args, BorrowedReference kw, MethodBase info, MethodBase[] methodinfo) in /tmp/build-via-sdist-zkttv147/pythonnet-3.0.2/src/runtime/MethodBinder.cs:line 868
at Python.Runtime.MethodObject.Invoke(BorrowedReference target, BorrowedReference args, BorrowedReference kw, MethodBase info) in /tmp/build-via-sdist-zkttv147/pythonnet-3.0.2/src/runtime/Types/MethodObject.cs:line 77
at Python.Runtime.MethodBinding.tp_call(BorrowedReference ob, BorrowedReference args, BorrowedReference kw) in /tmp/build-via-sdist-zkttv147/pythonnet-3.0.2/src/runtime/Types/MethodBinding.cs:line 166
Aborted
Unhandled exception. Python.Runtime.PythonException: name must be a str, not a NoneType
File "/usr/lib/python3.11/inspect.py", line 2701, in __init__
raise TypeError(msg)
at Python.Runtime.PythonException.ThrowLastAsClrException() in /tmp/build-via-sdist-zkttv147/pythonnet-3.0.2/src/runtime/PythonException.cs:line 53
at Python.Runtime.PyObject.Invoke(PyTuple args, PyDict kw) in /tmp/build-via-sdist-zkttv147/pythonnet-3.0.2/src/runtime/PythonTypes/PyObject.cs:line 801
at Python.Runtime.MethodBinding.get_Signature() in /tmp/build-via-sdist-zkttv147/pythonnet-3.0.2/src/runtime/Types/MethodBinding.cs:line 103
at Python.Runtime.MethodBinding.tp_getattro(BorrowedReference ob, BorrowedReference key) in /tmp/build-via-sdist-zkttv147/pythonnet-3.0.2/src/runtime/Types/MethodBinding.cs:line 147
Address
, Get
and Set
are documented here: https://download.microsoft.com/download/7/3/3/733AD403-90B2-4064-A81E-01035A7FE13C/MS%20Partition%20II.pdf.