Skip to content

Reporting an INTERNAL ERROR crash #2835

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
joell opened this issue Feb 9, 2017 · 7 comments
Closed

Reporting an INTERNAL ERROR crash #2835

joell opened this issue Feb 9, 2017 · 7 comments

Comments

@joell
Copy link

joell commented Feb 9, 2017

I'm sorry that I can't provide too much more context at this point, but I'm reporting the following INTERNAL ERROR as mypy (version requested:

$ MYPYPATH=<redacted local library path> mypy --strict-optional -p <redacted> --show-traceback --pdb
<file#1>:42: error: Class has two incompatible bases derived from tuple
<file#1>:42: error: List or tuple literal expected as the second argument to namedtuple()
<path to file#1>:123: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues
Dropping into pdb
> <working directory...>/mypy-env/lib/python3.6/site-packages/mypy/join.py(308)join_instances()
-> args.append(join_types(t.args[i], s.args[i]))
(Pdb) p t.args
[Any, Any, Any]
(Pdb) p s.args
[]
(Pdb) p i
0

The virtualenv I was operating out of has the following mypy related packages at these versions:

$ pip freeze
mypy==0.470
typed-ast==0.6.3
typing==3.5.3.0
@gvanrossum
Copy link
Member

gvanrossum commented Feb 9, 2017 via email

@joell
Copy link
Author

joell commented Feb 9, 2017

Here's the traceback and exception. If it helps both s and t are Tuple types. The source line it's triggering on is vaguely of the form

result = var1 if isinstance(var1, type1) else var2

where type1 and the types of var1 and var2 are all classes which inherit from namedtuple.

(Once again, I apologize that I can't share the actual code. Though I work on it I don't own it, and am not at liberty to share it sadly. I'm just reporting the bug in case you find it helpful; I'm not expecting a solution.)

Regarding MYPYPATH, I've been using that environment assignment for a few months now with this codebase without any issues, so if it is at fault it hasn't triggered until now.

Traceback (most recent call last):
  File "<working directory...>/mypy-env/bin/mypy", line 6, in <module>
    main(__file__)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/main.py", line 42, in main
    res = type_check_only(sources, bin_dir, options)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/main.py", line 87, in type_check_only
    options=options)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/build.py", line 183, in build
    dispatch(sources, manager)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/build.py", line 1526, in dispatch
    process_graph(graph, manager)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/build.py", line 1762, in process_graph
    process_stale_scc(graph, scc)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/build.py", line 1841, in process_stale_scc
    graph[id].type_check_first_pass()
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/build.py", line 1451, in type_check_first_pass
    self.type_checker.check_first_pass()
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 175, in check_first_pass
    self.accept(d)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 247, in accept
    typ = node.accept(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/nodes.py", line 713, in accept
    return visitor.visit_class_def(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 996, in visit_class_def
    self.accept(defn.defs)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 247, in accept
    typ = node.accept(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/nodes.py", line 774, in accept
    return visitor.visit_block(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 1091, in visit_block
    self.accept(s)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 247, in accept
    typ = node.accept(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/nodes.py", line 597, in accept
    return visitor.visit_decorator(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 1956, in visit_decorator
    e.func.accept(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/nodes.py", line 532, in accept
    return visitor.visit_func_def(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 459, in visit_func_def
    self.check_func_item(defn, name=defn.name())
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 522, in check_func_item
    self.check_func_def(defn, typ, name)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 652, in check_func_def
    self.accept(item.body)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 247, in accept
    typ = node.accept(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/nodes.py", line 774, in accept
    return visitor.visit_block(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 1091, in visit_block
    self.accept(s)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 247, in accept
    typ = node.accept(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/nodes.py", line 815, in accept
    return visitor.visit_assignment_stmt(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 1099, in visit_assignment_stmt
    self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 1170, in check_assignment
    self.infer_variable_type(inferred, lvalue, self.accept(rvalue),
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 247, in accept
    typ = node.accept(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/nodes.py", line 1639, in accept
    return visitor.visit_conditional_expr(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checker.py", line 2235, in visit_conditional_expr
    return self.expr_checker.visit_conditional_expr(e)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/checkexpr.py", line 1958, in visit_conditional_expr
    res = join.join_types(if_type, else_type)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/join.py", line 90, in join_types
    return t.accept(TypeJoinVisitor(s))
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/types.py", line 874, in accept
    return visitor.visit_tuple_type(self)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/join.py", line 240, in visit_tuple_type
    fallback = join_instances(self.s.fallback, t.fallback)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/join.py", line 319, in join_instances
    return join_instances_via_supertype(s, t)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/join.py", line 335, in join_instances_via_supertype
    res = join_instances(mapped, s)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/join.py", line 319, in join_instances
    return join_instances_via_supertype(s, t)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/join.py", line 335, in join_instances_via_supertype
    res = join_instances(mapped, s)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/join.py", line 319, in join_instances
    return join_instances_via_supertype(s, t)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/join.py", line 335, in join_instances_via_supertype
    res = join_instances(mapped, s)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/join.py", line 319, in join_instances
    return join_instances_via_supertype(s, t)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/join.py", line 335, in join_instances_via_supertype
    res = join_instances(mapped, s)
  File "<working directory...>/mypy-env/lib/python3.6/site-packages/mypy/join.py", line 308, in join_instances
    args.append(join_types(t.args[i], s.args[i]))
IndexError: list index out of range

@gvanrossum
Copy link
Member

gvanrossum commented Feb 9, 2017 via email

@joell
Copy link
Author

joell commented Feb 9, 2017

The same failure occurs with mypy-lang 0.4.6, mypy 0.470, and with mypy's master branch at commit ae47a3e (which is versioned as 0.480.dev0 when I install it).

@gvanrossum
Copy link
Member

gvanrossum commented Feb 9, 2017 via email

@joell
Copy link
Author

joell commented Feb 9, 2017

You have no need to apologize at all! I realized diagnosing the error with so little information would probably be a long shot, but since the error requested that I submit an issue I figured I'd at least pass along what I had.

It's not immediately clear to me how this error is triggering, as the typing of the surrounding code gets pretty complex. If I'm able to squeeze in the time to dig through it enough to repro with a small code sample I could share, I'll pass it along, but I can't promise I'll be able to.

Thanks for your help, and since I have you here in the moment, thank you also for all the great work you've done in creating and advancing Python!

@ilevkivskyi
Copy link
Member

I think this should be also fixed by #3952, several scenarios with this traceback were caused by various types not being analysed in the third pass. However, the code is private, so I can't check, @joell please reopen if this crash still happens on master.

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

No branches or pull requests

3 participants