You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue might be seen as a continuation of #1640, which introduced more elaborated error messages when parsing objects using the derived FromPyObject trait. However, the extended error messages are not properly passed to python when parsing arguments provided by python to a rust function fails.
Consider for example the following case. When passing a wrong type for the value field, the error message contains the fact that value cannot be parsed. However, it fails to explain why it failed to parse value. This is valuable information and thus I would like to get this information out.
Class ValueClass:
def __init__(self, value):
self.value = value
# Should be okay
module.function_to_call_with_value_class(ValueClass(0))
# Should tell that a string cannot be converted into a integer.
# Currently tells: argument 'struct_arg': failed to extract field ValueClass.value
module.function_to_call_with_value_class(ValueClass("unparsable string"))
# Should tell that a negative integer cannot be converted into an unsigned integer.
# Currently tells: argument 'struct_arg': failed to extract field ValueClass.value
module.function_to_call_with_value_class(ValueClass(-5))
The text was updated successfully, but these errors were encountered:
ricohageman
changed the title
Better Type error messages when FromPyObject fails on complex types
Pass detailed error message to python when parsing an argument fails
Feb 21, 2022
This issue might be seen as a continuation of #1640, which introduced more elaborated error messages when parsing objects using the derived FromPyObject trait. However, the extended error messages are not properly passed to python when parsing arguments provided by python to a rust function fails.
Consider for example the following case. When passing a wrong type for the
value
field, the error message contains the fact thatvalue
cannot be parsed. However, it fails to explain why it failed to parse value. This is valuable information and thus I would like to get this information out.Example rust code
Example python code
The text was updated successfully, but these errors were encountered: