| 1 | INTERNALERROR when exception in __repr__ |
| 2 | Minimal code to reproduce the issue: |
| 3 | ```python |
| 4 | class SomeClass: |
| 5 | def __getattribute__(self, attr): |
| 6 | raise |
| 7 | def __repr__(self): |
| 8 | raise |
| 9 | def test(): |
| 10 | SomeClass().attr |
| 11 | ``` |
| 12 | Session traceback: |
| 13 | ``` |
| 14 | ============================= test session starts ============================== |
| 15 | platform darwin -- Python 3.8.1, pytest-5.4.1, py-1.8.1, pluggy-0.13.1 -- /usr/local/opt/python@3.8/bin/python3.8 |
| 16 | cachedir: .pytest_cache |
| 17 | rootdir: ****** |
| 18 | plugins: asyncio-0.10.0, mock-3.0.0, cov-2.8.1 |
| 19 | collecting ... collected 1 item |
| 20 | |
| 21 | test_pytest.py::test |
| 22 | INTERNALERROR> Traceback (most recent call last): |
| 23 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/main.py", line 191, in wrap_session |
| 24 | INTERNALERROR> session.exitstatus = doit(config, session) or 0 |
| 25 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/main.py", line 247, in _main |
| 26 | INTERNALERROR> config.hook.pytest_runtestloop(session=session) |
| 27 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__ |
| 28 | INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs) |
| 29 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec |
| 30 | INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) |
| 31 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda> |
| 32 | INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( |
| 33 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall |
| 34 | INTERNALERROR> return outcome.get_result() |
| 35 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result |
| 36 | INTERNALERROR> raise ex[1].with_traceback(ex[2]) |
| 37 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall |
| 38 | INTERNALERROR> res = hook_impl.function(*args) |
| 39 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/main.py", line 272, in pytest_runtestloop |
| 40 | INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem) |
| 41 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__ |
| 42 | INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs) |
| 43 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec |
| 44 | INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) |
| 45 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda> |
| 46 | INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( |
| 47 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall |
| 48 | INTERNALERROR> return outcome.get_result() |
| 49 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result |
| 50 | INTERNALERROR> raise ex[1].with_traceback(ex[2]) |
| 51 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall |
| 52 | INTERNALERROR> res = hook_impl.function(*args) |
| 53 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/runner.py", line 85, in pytest_runtest_protocol |
| 54 | INTERNALERROR> runtestprotocol(item, nextitem=nextitem) |
| 55 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/runner.py", line 100, in runtestprotocol |
| 56 | INTERNALERROR> reports.append(call_and_report(item, "call", log)) |
| 57 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/runner.py", line 188, in call_and_report |
| 58 | INTERNALERROR> report = hook.pytest_runtest_makereport(item=item, call=call) |
| 59 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__ |
| 60 | INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs) |
| 61 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec |
| 62 | INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs) |
| 63 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda> |
| 64 | INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( |
| 65 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/callers.py", line 203, in _multicall |
| 66 | INTERNALERROR> gen.send(outcome) |
| 67 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/skipping.py", line 129, in pytest_runtest_makereport |
| 68 | INTERNALERROR> rep = outcome.get_result() |
| 69 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result |
| 70 | INTERNALERROR> raise ex[1].with_traceback(ex[2]) |
| 71 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall |
| 72 | INTERNALERROR> res = hook_impl.function(*args) |
| 73 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/runner.py", line 260, in pytest_runtest_makereport |
| 74 | INTERNALERROR> return TestReport.from_item_and_call(item, call) |
| 75 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/reports.py", line 294, in from_item_and_call |
| 76 | INTERNALERROR> longrepr = item.repr_failure(excinfo) |
| 77 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/python.py", line 1513, in repr_failure |
| 78 | INTERNALERROR> return self._repr_failure_py(excinfo, style=style) |
| 79 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/nodes.py", line 355, in _repr_failure_py |
| 80 | INTERNALERROR> return excinfo.getrepr( |
| 81 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/_code/code.py", line 634, in getrepr |
| 82 | INTERNALERROR> return fmt.repr_excinfo(self) |
| 83 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/_code/code.py", line 879, in repr_excinfo |
| 84 | INTERNALERROR> reprtraceback = self.repr_traceback(excinfo_) |
| 85 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/_code/code.py", line 823, in repr_traceback |
| 86 | INTERNALERROR> reprentry = self.repr_traceback_entry(entry, einfo) |
| 87 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/_code/code.py", line 784, in repr_traceback_entry |
| 88 | INTERNALERROR> reprargs = self.repr_args(entry) if not short else None |
| 89 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/_code/code.py", line 693, in repr_args |
| 90 | INTERNALERROR> args.append((argname, saferepr(argvalue))) |
| 91 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py", line 82, in saferepr |
| 92 | INTERNALERROR> return SafeRepr(maxsize).repr(obj) |
| 93 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py", line 51, in repr |
| 94 | INTERNALERROR> s = _format_repr_exception(exc, x) |
| 95 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py", line 23, in _format_repr_exception |
| 96 | INTERNALERROR> exc_info, obj.__class__.__name__, id(obj) |
| 97 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py", line 47, in repr |
| 98 | INTERNALERROR> s = super().repr(x) |
| 99 | INTERNALERROR> File "/usr/local/Cellar/python@3.8/3.8.1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/reprlib.py", line 52, in repr |
| 100 | INTERNALERROR> return self.repr1(x, self.maxlevel) |
| 101 | INTERNALERROR> File "/usr/local/Cellar/python@3.8/3.8.1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/reprlib.py", line 62, in repr1 |
| 102 | INTERNALERROR> return self.repr_instance(x, level) |
| 103 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py", line 60, in repr_instance |
| 104 | INTERNALERROR> s = _format_repr_exception(exc, x) |
| 105 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py", line 23, in _format_repr_exception |
| 106 | INTERNALERROR> exc_info, obj.__class__.__name__, id(obj) |
| 107 | INTERNALERROR> File "/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py", line 56, in repr_instance |
| 108 | INTERNALERROR> s = repr(x) |
| 109 | INTERNALERROR> File "/Users/stiflou/Documents/projets/apischema/tests/test_pytest.py", line 6, in __repr__ |
| 110 | INTERNALERROR> raise |
| 111 | INTERNALERROR> RuntimeError: No active exception to reraise |
| 112 | |
| 113 | ============================ no tests ran in 0.09s ============================ |
| 114 | ``` |