You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately, this is the recent version (after my fix). I can see from the line numbers. Is there any information about the crash (command line, whether it's intermittent, warm/cold cache, etc)?
Well, actually the user reported they got the crash after upgrading to mypy 1d1c62d (and they have the Terminal window logs to prove it to me :-) so I'm afraid I need to reopen this. Sorry for the quick cycling.
The user also reported: It [mypy -i] worked the first two times, then he added # type: ignore to the (previously empty) __init__.py of a very commonly used toplevel package, then it crashed.
Maybe also important, we have a script that computes the list of files to pass to mypy, and the offending __init__.py file (let's call it dropbox/__init__.py) was previously empty, so the result of adding # type: ignore to it was to include it in the command line. Many submodules of dropbox do have type annotations and are included in both runs.
Also, we run with --follow-imports=skip --ignore-missing-imports . This implies that the dropbox.__init__.py file was not analyzed in any way in the runs before the crash, but it was analyzed in the crashing run.
I used the simplest fix I could (just check that _importlib_modulespec exists before redirecting). But I guess it's fine, since this is a very low-level implementation detail.
Activity
ilevkivskyi commentedon Apr 24, 2017
Probably this is a "leftover" that is still not fixed by #3203
@pkch Could you please take a look?
gvanrossum commentedon Apr 24, 2017
Oh, I'll also check if the user who reported this had a sufficiently recent mypy version.
gvanrossum commentedon Apr 24, 2017
The user who reported this was running an older version of mypy, so there's nothing to see and nothing to do here.[UPDATE: I was wrong there]
pkch commentedon Apr 24, 2017
Unfortunately, this is the recent version (after my fix). I can see from the line numbers. Is there any information about the crash (command line, whether it's intermittent, warm/cold cache, etc)?
gvanrossum commentedon Apr 24, 2017
Well, actually the user reported they got the crash after upgrading to mypy 1d1c62d (and they have the Terminal window logs to prove it to me :-) so I'm afraid I need to reopen this. Sorry for the quick cycling.
gvanrossum commentedon Apr 24, 2017
The user also reported: It [mypy -i] worked the first two times, then he added
# type: ignoreto the (previously empty)__init__.pyof a very commonly used toplevel package, then it crashed.gvanrossum commentedon Apr 24, 2017
Maybe also important, we have a script that computes the list of files to pass to mypy, and the offending
__init__.pyfile (let's call itdropbox/__init__.py) was previously empty, so the result of adding# type: ignoreto it was to include it in the command line. Many submodules ofdropboxdo have type annotations and are included in both runs.Also, we run with
--follow-imports=skip --ignore-missing-imports. This implies that thedropbox.__init__.pyfile was not analyzed in any way in the runs before the crash, but it was analyzed in the crashing run.gvanrossum commentedon Apr 24, 2017
Also important: Python 2 mode!
ilevkivskyi commentedon Apr 24, 2017
This is the key I think.
ilevkivskyi commentedon Apr 24, 2017
@pkch maybe the solution is just to skip the reverse renaming in the PY2 mode?
pkch commentedon Apr 24, 2017
Yup, python 2 doesn't use
_importlib_modulespecat all.gvanrossum commentedon Apr 24, 2017
Do you have time to make a fix?
pkch commentedon Apr 24, 2017
Yes. I can't reproduce the crash, but I'm pretty sure what @ilevkivskyi said is sufficient. If it still crashes, we'll just have to look further.
gvanrossum commentedon Apr 24, 2017
Please send a PR -- I have a repro but I can't publish it, so I'll test your PR against it once I have it.
pkch commentedon Apr 24, 2017
I used the simplest fix I could (just check that
_importlib_modulespecexists before redirecting). But I guess it's fine, since this is a very low-level implementation detail.