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

Fix handling of overloaded __new__ that takes no arguments #789

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

oremanj
Copy link
Contributor

@oremanj oremanj commented Nov 14, 2024

Fixes #786. We now consider whether it's possible to invoke the overload with no arguments, rather than just whether it is declared with no parameters; the difference is relevant in the presence of nb::args/nb::kwargs and default values. The previous logic didn't work anyway - it checked whether there was an overload with zero args, but (a) this couldn't distinguish the auto-added wrapper overload from a user-specified one and (b) neither would have zero args, because new always takes at least the type arg.

src/nb_func.cpp Outdated Show resolved Hide resolved
@wjakob
Copy link
Owner

wjakob commented Nov 14, 2024

Thank you very much for the fix! I added two small comments.

@wjakob wjakob merged commit c2e394e into wjakob:master Nov 14, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Custom __new__ with no arguments
2 participants