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

RuntimeError: 'ExceptHandler(...)' has non-Name name. #3772

Closed
stygstra opened this Issue Jul 27, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@stygstra

stygstra commented Jul 27, 2017

try:
    raise IOError(12, 'asdf')
except IOError as (errno, msg):
    print errno, msg
$ python2 --version
Python 2.7.11+
$ python2 asdf.py
12 asdf
$ mypy --version
mypy 0.521
$ mypy --show-traceback -2 asdf.py
asdf.py: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.521
Traceback (most recent call last):
  File "/home/d/.local/bin/mypy", line 11, in <module>
    sys.exit(console_entry())
  File "/home/d/.local/lib/python3.5/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/main.py", line 50, in main
    res = type_check_only(sources, bin_dir, options)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/main.py", line 97, in type_check_only
    options=options)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/build.py", line 196, in build
    graph = dispatch(sources, manager)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/build.py", line 1793, in dispatch
    graph = load_graph(sources, manager)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/build.py", line 1876, in load_graph
    root_source=True)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/build.py", line 1440, in __init__
    self.parse_file()
  File "/home/d/.local/lib/python3.5/site-packages/mypy/build.py", line 1632, in parse_file
    self.ignore_all or self.options.ignore_errors)
  File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/build.py", line 1528, in wrap_context
    yield
  File "/home/d/.local/lib/python3.5/site-packages/mypy/build.py", line 1632, in parse_file
    self.ignore_all or self.options.ignore_errors)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/build.py", line 571, in parse_file
    tree = parse(source, path, self.errors, options=self.options)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/parse.py", line 31, in parse
    options=options)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/fastparse2.py", line 95, in parse
    ).visit(ast)
  File "/home/d/.local/lib/python3.5/site-packages/typed_ast/ast27.py", line 255, in visit
    return visitor(node)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/fastparse2.py", line 268, in visit_Module
    body = self.fix_function_overloads(self.translate_stmt_list(mod.body))
  File "/home/d/.local/lib/python3.5/site-packages/mypy/fastparse2.py", line 166, in translate_stmt_list
    stmt = self.visit(e)
  File "/home/d/.local/lib/python3.5/site-packages/typed_ast/ast27.py", line 255, in visit
    return visitor(node)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/fastparse2.py", line 112, in wrapper
    node = f(self, ast)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/fastparse2.py", line 559, in visit_TryExcept
    return self.try_handler(n.body, n.handlers, n.orelse, [], n.lineno)
  File "/home/d/.local/lib/python3.5/site-packages/mypy/fastparse2.py", line 582, in try_handler
    vs = [produce_name(h) for h in handlers]
  File "/home/d/.local/lib/python3.5/site-packages/mypy/fastparse2.py", line 582, in <listcomp>
    vs = [produce_name(h) for h in handlers]
  File "/home/d/.local/lib/python3.5/site-packages/mypy/fastparse2.py", line 580, in produce_name
    raise RuntimeError("'{}' has non-Name name.".format(ast27.dump(item)))
RuntimeError: 'ExceptHandler(type=Name(id='IOError', ctx=Load()), name=Tuple(elts=[Name(id='errno', ctx=Store()), Name(id='msg', ctx=Store())], ctx=Store()), body=[Print(dest=None, values=[Name(id='errno', ctx=Load()), Name(id='msg', ctx=Load())], nl=True)])' has non-Name name.
asdf.py: note: use --pdb to drop into pdb
@gvanrossum

This comment has been minimized.

Show comment
Hide comment
@gvanrossum

gvanrossum Jul 28, 2017

Member

FWIW this syntax is no longer supported in Python 3 (and I have never before seen in in Python 2 :-).

Member

gvanrossum commented Jul 28, 2017

FWIW this syntax is no longer supported in Python 3 (and I have never before seen in in Python 2 :-).

@ilevkivskyi

This comment has been minimized.

Show comment
Hide comment
@ilevkivskyi

ilevkivskyi Jul 28, 2017

Collaborator

FWIW this syntax is no longer supported in Python 3 (and I have never before seen in in Python 2 :-).

I think in any case it is better to give a normal error and not crash.

Collaborator

ilevkivskyi commented Jul 28, 2017

FWIW this syntax is no longer supported in Python 3 (and I have never before seen in in Python 2 :-).

I think in any case it is better to give a normal error and not crash.

@gvanrossum

This comment has been minimized.

Show comment
Hide comment
@gvanrossum

gvanrossum Sep 26, 2017

Member

OK have a look at #4011. If this is acceptable I'll add some tests.

Member

gvanrossum commented Sep 26, 2017

OK have a look at #4011. If this is acceptable I'll add some tests.

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