Skip to content

Crash on unpacking after invalid base class #2244

Description

@ilevkivskyi

Simplest way to reproduce:

class X(1):
    ...

x = X()
a, b = x

Output:

t_test6.py:1: error: Invalid base class
t_test6.py:5: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues
Traceback (most recent call last):
  File "/usr/local/bin/mypy", line 6, in <module>
    main(__file__)
  File "/usr/local/lib/python3.4/dist-packages/mypy/main.py", line 38, in main
    res = type_check_only(sources, bin_dir, options)
  File "/usr/local/lib/python3.4/dist-packages/mypy/main.py", line 79, in type_check_only
    options=options)
  File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 181, in build
    dispatch(sources, manager)
  File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 1470, in dispatch
    process_graph(graph, manager)
  File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 1650, in process_graph
    process_stale_scc(graph, scc)
  File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 1729, in process_stale_scc
    graph[id].type_check()
  File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 1415, in type_check
    manager.type_checker.visit_file(self.tree, self.xpath, self.options)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 165, in visit_file
    self.accept(d)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 217, in accept
    typ = node.accept(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/nodes.py", line 796, in accept
    return visitor.visit_assignment_stmt(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 1028, in visit_assignment_stmt
    self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 1044, in check_assignment
    infer_lvalue_type)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 1129, in check_assignment_to_multiple_lvalues
    self.check_multi_assignment(lvalues, rvalue, context, infer_lvalue_type)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 1165, in check_multi_assignment
    context, infer_lvalue_type)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 1257, in check_multi_assignment_from_iterable
    item_type = self.iterable_item_type(cast(Instance, rvalue_type))
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 2321, in iterable_item_type
    self.lookup_typeinfo('typing.Iterable'))
  File "/usr/local/lib/python3.4/dist-packages/mypy/maptype.py", line 23, in map_instance_to_supertype
    return map_instance_to_supertypes(instance, superclass)[0]
IndexError: list index out of range
t_test6.py:5: note: use --pdb to drop into pdb

This could be related to #1065

class_derivation_paths that finds all the paths up the hierarchy from a derived class to a given ancestor class. The code implicitly assumes that this function will only ever return a single path

But in this case there are no path, rather than two paths.

Metadata

Metadata

Assignees

Labels

bugmypy got something wrongcrash

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions