Skip to content

Catch missing self argument in overloads constructor #2914

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

Merged
merged 1 commit into from
Apr 2, 2021

Conversation

rhaschke
Copy link
Contributor

@rhaschke rhaschke commented Mar 21, 2021

The following unittest code was segfaulting due to missing self argument in call to __init__

class BrokenTF6(m.TestFactory6):
    def __init__(self):
        m.TestFactory6.__init__()

Fixed now, by catching this edge case and throwing an appropriate exception.

Suggested changelog entry:

Catch a missing ``self`` argument in calls to ``__init__()``.

Copy link
Collaborator

@henryiii henryiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good idea to me.

@henryiii
Copy link
Collaborator

henryiii commented Apr 2, 2021

Could you please re-add the changlog entry to the issue description? Those get auto-processed into the changelog draft.

@henryiii henryiii added the bug label Apr 2, 2021
@rhaschke
Copy link
Contributor Author

rhaschke commented Apr 2, 2021

@henryiii, I added a changelog suggestion. Hope this is in line with the desired verbosity and formatting.

@henryiii
Copy link
Collaborator

henryiii commented Apr 2, 2021

Formatting gets auto applied (bullets and periods if missing), and I can tweak it, but it helps to have a starting point. Thanks! (I will change it to be RST though ;) )

Copy link
Collaborator

@YannickJadoul YannickJadoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, how has this never been seen/caught before!?

Good catch, @rhaschke!

@henryiii
Copy link
Collaborator

henryiii commented Apr 2, 2021

Probably because the normal way to call this is with super, and there you have to supply self (or it gets automatically picked up in Python 3).

@henryiii henryiii merged commit c2db53d into pybind:master Apr 2, 2021
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Apr 2, 2021
@YannickJadoul
Copy link
Collaborator

Probably because the normal way to call this is with super, and there you have to supply self (or it gets automatically picked up in Python 3).

Hmmm, though pybind11 actually explicitly warns not to use super, since it won't fit with the way multiple inheritance currently works.

@rhaschke rhaschke deleted the catch-missing-self branch May 19, 2021 21:32
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants