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 in PEP 561 module resolution #6000

Merged
merged 1 commit into from Dec 4, 2018

Conversation

Projects
None yet
2 participants
@ethanhs
Copy link
Collaborator

ethanhs commented Dec 4, 2018

If there was a py.typed file in a stub-only package, and it didn't
contain partial, there would be an unbound local error. To fix this,
we treat it as a normal stub-only package if the py.typed file doesn't
contain partial.

Fixes #5999

@wcooley this should fix the crash.

Fix crash in PEP 561 module resoltion
If there was a py.typed file in a stub-only package, and it didn't
contain "partial", there would be an unbound local error. To fix this,
we treat it as a normal stub-only package instead.
@gvanrossum
Copy link
Member

gvanrossum left a comment

Definitely need to cherry-pick this. "Be liberal in what you accept" etc. (https://en.wikipedia.org/wiki/Robustness_principle)

@gvanrossum

This comment has been minimized.

Copy link
Member

gvanrossum commented Dec 4, 2018

Does it make sense to print a warning in the edge case? (Not sure if that would make things worse, since except if you're the package author, there's not much you can do about that warning.)

@ethanhs

This comment has been minimized.

Copy link
Collaborator

ethanhs commented Dec 4, 2018

Yeah I thought about that, but if

@ethanhs

This comment has been minimized.

Copy link
Collaborator

ethanhs commented Dec 4, 2018

Bah phones. The above should read:
"Yeah I thought about that but if we silently treat it as a normal package it will just not resolve the Python package, which we will report. Therefore the natural debugging check is to check if you included partial. Though maybe we should mention partial packages in the module not found message? "

@gvanrossum

This comment has been minimized.

Copy link
Member

gvanrossum commented Dec 4, 2018

Oh, it would be easy to add that to https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports (where that message no redirects). So go ahead and merge now!

@ethanhs ethanhs merged commit 3a89c8a into python:master Dec 4, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@ethanhs ethanhs deleted the ethanhs:fixpep561crash branch Dec 4, 2018

JukkaL added a commit that referenced this pull request Dec 4, 2018

Fix crash in PEP 561 module resoltion (#6000)
If there was a py.typed file in a stub-only package, and it didn't
contain "partial", there would be an unbound local error. To fix this,
we treat it as a normal stub-only package instead.

@JukkaL JukkaL referenced this pull request Dec 4, 2018

Closed

Release 0.650 planning #5960

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment