Skip to content

Verbose Information on TypeError runtime crashes? #514

Open

Description

@matanox

Thank you for pyo3.

Using pyo3, when my python code sends the wrong shape (can typically happen given python's dynamic typing during any development work) I get a python backtrace going down to my line of code calling into my rust, and a text error description like:

TypeError: 'float64' object cannot be converted to 'PyArray<T, D>'

Is there a more verbose mode to pyo3 runtime for cases like this?

Of course if my dev workflow is linear enough, I know I should check my types at that line and have good context in mind for quickly resolving it even without re-running with try-except for logging more details.

However it would be nice to have more information already in the error description if possible:

  • What are the type values of T and D?
  • Which function argument is the error arising for?

Of course, user code can always try-except the offending python call and we can work to reproduce that crash in repeat runs, even if it's outside the development cycle. But having more information by default provides more peace of mind knowing that before you have managed to reproduce you have some more details than the line of user code. All-in-all this is an enhancement which some may object if it adds runtime cost, especially for release builds.


Consider that when we expose rust code to python, some python developers would much appreciate knowing more about the expected types than those developers who understand pyo3 or can directly work with the rust code.

Activity

  1. changed the title [-]Verbose iIformation on TypeError runtime crashes?[/-] [+]Verbose Information on TypeError runtime crashes?[/+] on Sep 18, 2025
  2. matanox commented on Sep 18, 2025

    @matanox
    Author

    This is quite in the same category as PyO3/pyo3#5412 which was recently opened, though they are radically different runtime situations.

  3. transferred this issue fromPyO3/pyo3on Sep 18, 2025
  4. davidhewitt commented on Sep 18, 2025

    @davidhewitt
    Member

    Transferred this to rust-numpy, as the error message is originating from this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions