Skip to content

Python 3.10: required field "lineno" missing from alias #2061

@tianon

Description

@tianon

Python 3.10 has introduced a change that breaks Hy (feeling like a case of "This Is The Way" with Python pre-releases :trollface:).

It seems to be related to https://bugs.python.org/issue43798 (some potentially useful discussion in pytest-dev/pytest#8539).

Here's the full backtrace (on latest master; specifically e1150cf):

$ python --version
Python 3.10.0b1
$ hy
Traceback (most recent call last):
  File "/opt/hylang/hy/hy/compiler.py", line 1648, in compile_eval_and_compile
    hy_eval(new_expr + body,
  File "/opt/hylang/hy/hy/compiler.py", line 1977, in hy_eval
    eval(ast_compile(_ast, filename, "exec"),
  File "/opt/hylang/hy/hy/compiler.py", line 62, in ast_compile
    return compile(a, filename, mode, hy_ast_compile_flags)
TypeError: required field "lineno" missing from alias

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/hy", line 8, in <module>
    from hy.cmdline import hy_main
  File "/opt/hylang/hy/hy/__init__.py", line 14, in <module>
    hy.importer._inject_builtins()
  File "/opt/hylang/hy/hy/importer.py", line 178, in _inject_builtins
    core = importlib.import_module('hy.core')
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/hylang/hy/hy/core/__init__.py", line 1, in <module>
    from .shadow import *
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 879, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1017, in get_code
  File "/opt/hylang/hy/hy/importer.py", line 130, in _hy_source_to_code
    data = hy_compile(hy_tree, module)
  File "/opt/hylang/hy/hy/compiler.py", line 2066, in hy_compile
    stdlib_ast = compiler.compile(mkexpr("eval-and-compile", mkexpr("import", "hy")))
  File "/opt/hylang/hy/hy/compiler.py", line 379, in compile
    raise e
  File "/opt/hylang/hy/hy/compiler.py", line 370, in compile
    ret = self.compile_atom(tree)
  File "/opt/hylang/hy/hy/compiler.py", line 364, in compile_atom
    return Result() + _model_compilers[type(atom)](self, atom)
  File "/opt/hylang/hy/hy/compiler.py", line 1730, in compile_expression
    return Result() + build_method(
  File "/opt/hylang/hy/hy/compiler.py", line 1665, in compile_eval_and_compile
    raise HyEvalError(str(e), self.filename, body, self.source)
hy.errors.HyEvalError: 
  File "[hy.models.Expression([
  hy.models.Symbol('import'),
  hy.models.Symbol('hy')])]", line 1
    ;; Copyright 2021 the authors.
    ^----------------------------^
required field "lineno" missing from alias

(I'm testing with the Dockerfile here in the repo by changing python:3 to python:3.10-rc, but any way of getting a recent Python 3.10 pre-release should reproduce similarly.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions