-
Notifications
You must be signed in to change notification settings - Fork 760
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
#[new] can silently fail when arguments to the function can't be constructed #4470
Comments
This has a crossover with #4465 which defines |
@Walter-Reactor can you provide a more complete minimal repro along with the proposed change to behaviour you would like to see? The problem, as I see it currently, is that you cannot create a |
That's accurate, but the inability to construct Foo seemed like it was being contagious. Now that I consider it, if there were some other way to construct My main issue here is one of diagnostsics. It was extremely confusing when I tried to write |
I can't reproduce this. Using the code you posted above: >>> Foo("a")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: argument 'param': 'str' object cannot be converted to 'Param'
>>> Param("a")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: No constructor defined Still, it could indeed be good to mention the type name in the "no constructor defined" message. |
Bug Description
When using
#[new]
on a function where one of the parameters can't be constructed by PyO3, the constructor silently fails and attempting to construct the object will at runtime trigger a "No constructor defined" exception.Steps to Reproduce
The following compiles with no warning or error, but attempting to create a
Foo
from python will fail.Backtrace
No response
Your operating system and version
Windows 11
Your Python version (
python --version
)Python 3.12.4
Your Rust version (
rustc --version
)rustc 1.80.1 (3f5fd8dd4 2024-08-06)
Your PyO3 version
0.22.1
How did you install python? Did you use a virtualenv?
System python, invoked via uv 0.3.0's
uv run
Additional Info
No response
The text was updated successfully, but these errors were encountered: