| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
I'm really confused by this CI error. import mypy.fastparse fails on Python 3.3, but only when run from the runtests script (as opposed to directly with scripts/myunit) and only when the import statement is not at the top level. |
Sorry, something went wrong.
|
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?
|
Sorry, something went wrong.
|
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? |
Sorry, something went wrong.
|
I added sys.path and cwd printouts: sys.path remains unchanged from the top level, but the cwd changes from mypy to mypy/tmp-test-dirs/mypy-test-qhg83l -- that must be it somehow. |
Sorry, something went wrong.
|
Hmm. The mypy directory is in my sys.path, though: |
Sorry, something went wrong.
|
Maybe there's another subpackage named mypy that doesn't have fastparser? |
Sorry, something went wrong.
|
Try printing mypy.file. |
Sorry, something went wrong.
|
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.fastparseThe sys.path modifications I make here mirror those I see when runtests.py is invoked. Removing the empty string from the beginning of sys.path fixes the problem, so I'm going to try to make that change to the test runner. |
Sorry, something went wrong.
|
Making that change to the test runner doesn't seem to fix it. Ugh. |
Sorry, something went wrong.
|
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 python -m [module] (and not when you just run python [file]. |
Sorry, something went wrong.
|
The actual rule is that it prepends the directory where the file lives, or --Guido (mobile) |
Sorry, something went wrong.
|
That works! I'll try to write a good comment about it. |
Sorry, something went wrong.
|
... and now Travis is down. |
Sorry, something went wrong.
|
Checks pass! |
Sorry, something went wrong.
| # 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.
Worth filing an issue for.
Sorry, something went wrong.
There was a problem hiding this comment.
Looks like there's already one, actually: #1422
Sorry, something went wrong.
|
Whew! Epic. |
Sorry, something went wrong.
|
Thanks for the help! Definitely didn't expect this to be so hard. ._. |
Sorry, something went wrong.
|
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!
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Primarily tests #1600. New fixes to the fast parser will have tests added here.