-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
agronholm/exceptiongroup
#58Description
pytest >= 7.2 uses the exceptiongroup library while rendering tracebacks.
If the exception is a urllib.error.HTTPError python/cpython#90113 occurs causing an INTERNALERROR.
(pytest < 7.2 does not have this problem.)
Minimal example:
from urllib.error import HTTPError
def test_HTTPError():
raise HTTPError(
'http://localhost', '500', 'Internal Server Error', hdrs=(), fp=None)Traceback
$ bin/pytest
============================= test session starts ==============================
platform darwin -- Python 3.9.16, pytest-7.2.2, pluggy-1.0.0
rootdir: /.../pt72
collected 1 item
test_httperror.py
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/main.py", line 270, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/main.py", line 324, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/main.py", line 349, in pytest_runtestloop
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/runner.py", line 112, in pytest_runtest_protocol
INTERNALERROR> runtestprotocol(item, nextitem=nextitem)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/runner.py", line 131, in runtestprotocol
INTERNALERROR> reports.append(call_and_report(item, "call", log))
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/runner.py", line 222, in call_and_report
INTERNALERROR> report: TestReport = hook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_callers.py", line 55, in _multicall
INTERNALERROR> gen.send(outcome)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/skipping.py", line 265, in pytest_runtest_makereport
INTERNALERROR> rep = outcome.get_result()
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/runner.py", line 366, in pytest_runtest_makereport
INTERNALERROR> return TestReport.from_item_and_call(item, call)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/reports.py", line 349, in from_item_and_call
INTERNALERROR> longrepr = item.repr_failure(excinfo)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/python.py", line 1823, in repr_failure
INTERNALERROR> return self._repr_failure_py(excinfo, style=style)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/nodes.py", line 484, in _repr_failure_py
INTERNALERROR> return excinfo.getrepr(
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/_code/code.py", line 669, in getrepr
INTERNALERROR> return fmt.repr_excinfo(self)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/_code/code.py", line 944, in repr_excinfo
INTERNALERROR> reprtraceback = self.repr_traceback(excinfo_)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/_code/code.py", line 871, in repr_traceback
INTERNALERROR> reprentry = self.repr_traceback_entry(entry, einfo)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/_code/code.py", line 822, in repr_traceback_entry
INTERNALERROR> s = self.get_source(source, line_index, excinfo, short=short)
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/_code/code.py", line 760, in get_source
INTERNALERROR> lines.extend(self.get_exconly(excinfo, indent=indent, markall=True))
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/_code/code.py", line 772, in get_exconly
INTERNALERROR> exlines = excinfo.exconly(tryshort=True).split("\n")
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/_pytest/_code/code.py", line 588, in exconly
INTERNALERROR> lines = format_exception_only(self.type, self.value)
INTERNALERROR> File "/.../lib/python3.9/traceback.py", line 140, in format_exception_only
INTERNALERROR> return list(TracebackException(etype, value, None).format_exception_only())
INTERNALERROR> File "/.../pt72/lib/python3.9/site-packages/exceptiongroup/_formatting.py", line 106, in __init__
INTERNALERROR> self.__notes__ = getattr(exc_value, "__notes__", None)
INTERNALERROR> File "/.../lib/python3.9/tempfile.py", line 472, in __getattr__
INTERNALERROR> file = self.__dict__['file']
INTERNALERROR> KeyError: 'file'$ bin/pip list
Package Version
-------------- -------
attrs 22.2.0
exceptiongroup 1.1.0
iniconfig 2.0.0
packaging 23.0
pip 23.0.1
pluggy 1.0.0
pytest 7.2.2
setuptools 58.1.0
tomli 2.0.1
Using pytest 7.2.2 on Python 3.9.16
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels