Skip to content

New incremental mode (-i) crasher #3232

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

Closed
gvanrossum opened this issue Apr 24, 2017 · 15 comments
Closed

New incremental mode (-i) crasher #3232

gvanrossum opened this issue Apr 24, 2017 · 15 comments

Comments

@gvanrossum
Copy link
Member

gvanrossum commented Apr 24, 2017

I've seen this a few times myself and now it's being reported. The traceback ends with

  File "/Users/x/src/server/.mypy/venv/lib/python3.6/site-packages/mypy/types.py", line 388, in accept
    return visitor.visit_instance(self)
  File "/Users/x/src/server/.mypy/venv/lib/python3.6/site-packages/mypy/fixup.py", line 153, in visit_instance
    node = lookup_qualified(self.modules, type_ref, self.quick_and_dirty)
  File "/Users/x/src/server/.mypy/venv/lib/python3.6/site-packages/mypy/fixup.py", line 237, in lookup_qualified
    stnode = lookup_qualified_stnode(modules, name, quick_and_dirty)
  File "/Users/x/src/server/.mypy/venv/lib/python3.6/site-packages/mypy/fixup.py", line 252, in lookup_qualified_stnode
    assert '.' in head, "Cannot find %s" % (name,)
AssertionError: Cannot find _importlib_modulespec.ModuleType
@gvanrossum gvanrossum self-assigned this Apr 24, 2017
@ilevkivskyi
Copy link
Member

Probably this is a "leftover" that is still not fixed by #3203
@pkch Could you please take a look?

@gvanrossum
Copy link
Member Author

Oh, I'll also check if the user who reported this had a sufficiently recent mypy version.

@gvanrossum
Copy link
Member Author

gvanrossum commented 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
Copy link
Contributor

pkch commented 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
Copy link
Member Author

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 gvanrossum reopened this Apr 24, 2017
@gvanrossum
Copy link
Member Author

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.

@gvanrossum
Copy link
Member Author

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.

@gvanrossum
Copy link
Member Author

Also important: Python 2 mode!

@ilevkivskyi
Copy link
Member

Also important: Python 2 mode!

This is the key I think.

@ilevkivskyi
Copy link
Member

@pkch maybe the solution is just to skip the reverse renaming in the PY2 mode?

@pkch
Copy link
Contributor

pkch commented Apr 24, 2017

Yup, python 2 doesn't use _importlib_modulespec at all.

@gvanrossum
Copy link
Member Author

Do you have time to make a fix?

@pkch
Copy link
Contributor

pkch commented 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
Copy link
Member Author

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
Copy link
Contributor

pkch commented Apr 24, 2017

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.

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

No branches or pull requests

3 participants