Skip to content

Assertion rewriting fails under Python 3.10.0a7+ #8539

Closed
@Zac-HD

Description

@Zac-HD
Traceback (most recent call last):
  ...
  File "_pytest/assertion/rewrite.py", line 161, in exec_module
    source_stat, co = _rewrite_test(fn, self.config)
  File "_pytest/assertion/rewrite.py", line 356, in _rewrite_test
    co = compile(tree, fn_, "exec", dont_inherit=True)
TypeError: required field "lineno" missing from alias
full traceback
Traceback (most recent call last):
  File "/home/runner/.cache/hypothesis-build-runtimes/python-versions/3.10-dev/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/runner/.cache/hypothesis-build-runtimes/python-versions/3.10-dev/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pytest/__main__.py", line 5, in <module>
    raise SystemExit(pytest.console_main())
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 185, in console_main
    code = main()
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 143, in main
    config = _prepareconfig(args, plugins)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 318, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/helpconfig.py", line 100, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1003, in pytest_cmdline_parse
    self.parse(args)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1283, in parse
    self._preparse(args, addopts=addopts)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1168, in _preparse
    self.pluginmanager.consider_preparse(args, exclude_only=False)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 635, in consider_preparse
    self.consider_pluginarg(parg)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 660, in consider_pluginarg
    self.import_plugin(arg, consider_entry_points=True)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 713, in import_plugin
    self.register(mod, modname)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 443, in register
    self.consider_module(plugin)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 669, in consider_module
    self._import_plugin_specs(getattr(mod, "pytest_plugins", []))
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 676, in _import_plugin_specs
    self.import_plugin(import_spec)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/config/__init__.py", line 703, in import_plugin
    __import__(importspec)
  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 "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 161, in exec_module
    source_stat, co = _rewrite_test(fn, self.config)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-full/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 356, in _rewrite_test
    co = compile(tree, fn_, "exec", dont_inherit=True)
TypeError: required field "lineno" missing from alias

I discovered this in the Hypothesis CI, with Pytest 6.2.3 on Ubuntu and python3.10-dev (alpha07) from pyenv. Unfortunately I don't have a smaller reproducing example than that, since my only copy of alpha07 is on that CI server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: rewriterelated to the assertion rewrite mechanismtype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions