Skip to content

mypy locks up while processing a nested object containing strings with apostrophes #9780

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
mikegashler opened this issue Dec 5, 2020 · 1 comment
Labels
bug mypy got something wrong

Comments

@mikegashler
Copy link

MyPy locks up when I try to process the file below.

To Reproduce

  1. Save the following snip of code as 'bug.py':
    import json
    config = {'x':{ 't': 'cat', 'z': 'e', 'c': [{ 't': 'cat', 'z': 'p', 'c': [{ 't': 'op', 'a': 0, 't': '', 'c': [{ 't': 'pod', 'a': 0, 'z': 'o', 'c': [{ 't': 'rp', 'a': 3, 'z': '', 'c': [{ 't': 'rp', 'a': 0, 'z': '', 'c': [{ 't': 'rp', 'a': 3, 'z': 'pes\' moy.', 'c': [{ 't': 'rp', 'a': 0, 'z': 'Ye!he s!', 'c': [{ 't': 'rp', 'a': 3, 'z': 'Wtht?', 'c': [{ 't': 'rp', 'a': 0, 'z': 'Sey? Yoon\'t vit?', 'c': [{ 't': 'rp', 'a': 3, 'z': 'Idn\'tn.', 'c': [{ 't': 'rp', 'a': 0, 'z': 'Weou\'reI\'mre.', 'c': [] },] },] },] },] },] },] },] },] },] },] },] },}
  2. mypy bug.py
  3. Observe that it never finishes. Observe that cpu is at 100%. Observe that after a while, Ctrl-C does not stop it. But you can open another terminal and do "kill -15 [pid]" to stop it.

Expected Behavior

It should terminate in a timely manner.

Actual Behavior

It has not terminated after nearly 20 minutes.

`$ time mypy bug.py
^C^C^C^C^C^C^C^C^C^C^C^CTerminated

real 18m4.112s
user 17m55.106s
sys 0m8.776s`

If I remove the strings containing apostrophes from the file, it no longer repros. If I remove some of the nested objects, it also no longer repros. The file above is as simplified as I could make it while still reproducing the issue. When it locks up, my CPU runs at 100% capacity. If I press Ctrl-C soon after, it stops. But if I wait a while, then Ctrl-C will not interrupt it anymore, and I have to do "kill -15 [pid]" to stop it.

Your Environment

MyPy version 0.790. (It also repro'd with an earlier version of MyPy, so this does not appear to be a recent issue.)
Ubuntu 20.04.1 LTS

@mikegashler mikegashler added the bug mypy got something wrong label Dec 5, 2020
@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Dec 7, 2020

Thanks for the report. This is fixed in #9477 by huguesb (unrelated to apostrophes, you may also be interested in #3796)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants