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 crash when a dataclass with a no init InitVar is inherited #7390

Merged
merged 3 commits into from Aug 27, 2019

Conversation

@onlined
Copy link
Contributor

commented Aug 26, 2019

Fixes #7320.

Copy link
Collaborator

left a comment

Thanks for fixing the crash! Looks good (just a few nits) but it would be nice to have a test case. Test cases for dataclasses live in test-data/unit/check-dataclasses.test.

if info[attr.name].type is None:
try:
node = info[attr.name]
except KeyError:

This comment has been minimized.

Copy link
@JukkaL

JukkaL Aug 26, 2019

Collaborator

I think that it would be slightly cleaner if you'd use a if info.get(attr.name) is None check instead of try/except here.

This comment has been minimized.

Copy link
@onlined

onlined Aug 27, 2019

Author Contributor

Fixed.

del info.names[attr.name]
try:
del info.names[attr.name]
except KeyError:

This comment has been minimized.

Copy link
@JukkaL

JukkaL Aug 26, 2019

Collaborator

Similar to above, I'd slightly prefer an if statement instead of try/except here.

This comment has been minimized.

Copy link
@onlined

onlined Aug 27, 2019

Author Contributor

Fixed.

@onlined

This comment has been minimized.

Copy link
Contributor Author

commented Aug 27, 2019

Thanks for the review! I updated the code and added a test.

@JukkaL
JukkaL approved these changes Aug 27, 2019
Copy link
Collaborator

left a comment

Thanks for the updates! Looks good now.

@JukkaL JukkaL merged commit ddec163 into python:master Aug 27, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.