Skip to content

Assertion rewriting fails under Python 3.10.0a7+ #8539

Closed

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.

Activity

  1. added
    type: bugproblem that needs to be addressed
    topic: rewriterelated to the assertion rewrite mechanism
    on Apr 11, 2021
  2. RonnyPfannschmidt commented on Apr 11, 2021

    @RonnyPfannschmidt
    Member

    as first enhancement assertion rewrite should raise a ImportError that tells the file at least

  3. hauntsaninja commented on Apr 11, 2021

    @hauntsaninja
    Contributor

    Looks like this is a result of https://bugs.python.org/issue43798

  4. changed the title [-]Assertion rewriting fails under Python 3.10-alpha07[/-] [+]Assertion rewriting fails under Python 3.10.0a7+[/+] on Apr 15, 2021
  5. hroncok commented on Apr 15, 2021

    @hroncok
    Member

    I've renamed the issue a bit to be less confusing.

  6. The-Compiler commented on Apr 19, 2021

    @The-Compiler
    Member

    Taking the freedom to pin this issue due to #8540 (comment)

  7. pinned this issue on Apr 19, 2021
  8. unpinned this issue on Apr 24, 2021
  9. 27 remaining items

  10. added a commit that references this issue on Dec 23, 2021
  11. added a commit that references this issue on Apr 14, 2022
  12. alirezatheh commented on May 30, 2022

    @alirezatheh

    I'm still experiencing this issue in Python 3.10.4 and pytest 7.1.2

  13. added a commit that references this issue on Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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