Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpreter crashes when using T[].Address, T[].Get or T[].Set #2262

Open
jorge0xdeadbeef opened this issue Oct 9, 2023 · 0 comments
Open
Labels

Comments

@jorge0xdeadbeef
Copy link

jorge0xdeadbeef commented Oct 9, 2023

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 use T[].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 use T[].Get and T[].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.

@filmor filmor added the bug label Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants