-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Add some initial tests for the fast parser #1648
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
Conversation
I'm really confused by this CI error. |
Weird. I recommend adding print() calls showing sys.path and os.getcwd() to
see where you are.
Another theory: typed_ast wasn't actually successfully built and installed
in 3.3 and that's causing it. Is it installed from a Linux wheel? What
Python version was present when you built the wheels?
|
I was able to repro locally, where I checked that typed_ast did get installed successfully, so it's not related to that. (Also the error happens well before fastparse tries to import typed_ast.) Also: there are no Linux wheels. Are Linux wheels even supported yet? |
I added sys.path and cwd printouts: sys.path remains unchanged from the top level, but the cwd changes from |
Hmm. The |
Maybe there's another subpackage named mypy that doesn't have fastparser? |
Try printing mypy.file. |
I figured it out. It's nothing to do with fastparse in particular (and everything to do with the fact that it's imported in a function). The final import in this code will fail in Python 3.3, but succeed in Python 3.4 and 3.5: import os
import sys
sys.path = ['', '/Users/ddfisher/src/mypy'] + sys.path
import mypy
os.chdir('tmp')
import mypy.fastparse The sys.path modifications I make here mirror those I see when |
Making that change to the test runner doesn't seem to fix it. Ugh. |
Python seems to be prepending an empty string to sys.path (and I think I'm filtering it out too late). Is there any way to prevent it from doing it? As far as I can tell, it only happens when you run |
The actual rule is that it prepends the directory where the file lives, or --Guido (mobile) |
That works! I'll try to write a good comment about it. |
... and now Travis is down. |
Checks pass! |
# fix that problem by fixing up the path to be absolute here. | ||
import os.path | ||
import mypy | ||
# User-defined packages always have __path__ attributes, but mypy doesn't know that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth filing an issue for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's already one, actually: #1422
Whew! Epic. |
Thanks for the help! Definitely didn't expect this to be so hard. ._. |
Or those delayed imports are somehow executed sooner. There's something
generally iffy about the way fastparse.py is handled. Fortunately that will
soon be behind us!
|
Primarily tests #1600. New fixes to the fast parser will have tests added here.