| 13 | "hints_text": "This only happens when both `__repr__` and `__getattribute__` are broken, which is a very odd scenario.\n```\r\nclass SomeClass:\r\n def __getattribute__(self, attr):\r\n raise Exception()\r\n\r\n def bad_method(self):\r\n raise Exception()\r\n\r\ndef test():\r\n SomeClass().bad_method()\r\n\r\n```\r\n\r\n```\r\n============================================================================================== test session starts ===============================================================================================\r\nplatform linux -- Python 3.7.7, pytest-5.4.1.dev154+gbe6849644, py-1.8.1, pluggy-0.13.1\r\nrootdir: /home/k/pytest, inifile: tox.ini\r\nplugins: asyncio-0.11.0, hypothesis-5.10.4\r\ncollected 1 item \r\n\r\ntest_internal.py F [100%]\r\n\r\n==================================================================================================== FAILURES ====================================================================================================\r\n______________________________________________________________________________________________________ test ______________________________________________________________________________________________________\r\n\r\n def test():\r\n> SomeClass().bad_method()\r\n\r\ntest_internal.py:12: \r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\n\r\nself = <test_internal.SomeClass object at 0x7fa550a8f6d0>, attr = 'bad_method'\r\n\r\n def __getattribute__(self, attr):\r\n> raise Exception()\r\nE Exception\r\n\r\ntest_internal.py:6: Exception\r\n============================================================================================ short test summary info =============================================================================================\r\nFAILED test_internal.py::test - Exception\r\n=============================================================================================== 1 failed in 0.07s ================================================================================================\r\n```\r\n\r\n```\r\nclass SomeClass:\r\n def __repr__(self):\r\n raise Exception()\r\n\r\n def bad_method(self):\r\n raise Exception()\r\n\r\ndef test():\r\n SomeClass().bad_method()\r\n\r\n```\r\n\r\n\r\n```\r\n============================================================================================== test session starts ===============================================================================================\r\nplatform linux -- Python 3.7.7, pytest-5.4.1.dev154+gbe6849644, py-1.8.1, pluggy-0.13.1\r\nrootdir: /home/k/pytest, inifile: tox.ini\r\nplugins: asyncio-0.11.0, hypothesis-5.10.4\r\ncollected 1 item \r\n\r\ntest_internal.py F [100%]\r\n\r\n==================================================================================================== FAILURES ====================================================================================================\r\n______________________________________________________________________________________________________ test ______________________________________________________________________________________________________\r\n\r\n def test():\r\n> SomeClass().bad_method()\r\n\r\ntest_internal.py:9: \r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\n\r\nself = <[Exception() raised in repr()] SomeClass object at 0x7f0fd38ac910>\r\n\r\n def bad_method(self):\r\n> raise Exception()\r\nE Exception\r\n\r\ntest_internal.py:6: Exception\r\n============================================================================================ short test summary info =============================================================================================\r\nFAILED test_internal.py::test - Exception\r\n=============================================================================================== 1 failed in 0.07s ================================================================================================\r\n```\n> This only happens when both `__repr__` and `__getattribute__` are broken, which is a very odd scenario.\r\n\r\nIndeed, I admit that's a very odd scenario (I've faced it when working on some black magic mocking stuff). However, I've opened this issue because I haven't dived into pytest code and maybe it will be understood better by someone who could see in it a more important underlying issue.\nThe problem is most likely here:\r\n\r\n```\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py\", line 23, in _format_repr_exception\r\nINTERNALERROR> exc_info, obj.__class__.__name__, id(obj)\r\n```\r\n\r\nspecifically, `obj.__class__` raises, but this isn't expected or handled by `saferepr`. Changing this to `type(obj).__name__` should work.", |
| 17 | "problem_statement": "INTERNALERROR when exception in __repr__\nMinimal code to reproduce the issue: \r\n```python\r\nclass SomeClass:\r\n def __getattribute__(self, attr):\r\n raise\r\n def __repr__(self):\r\n raise\r\ndef test():\r\n SomeClass().attr\r\n```\r\nSession traceback:\r\n```\r\n============================= test session starts ==============================\r\nplatform 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\r\ncachedir: .pytest_cache\r\nrootdir: ******\r\nplugins: asyncio-0.10.0, mock-3.0.0, cov-2.8.1\r\ncollecting ... collected 1 item\r\n\r\ntest_pytest.py::test \r\nINTERNALERROR> Traceback (most recent call last):\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/main.py\", line 191, in wrap_session\r\nINTERNALERROR> session.exitstatus = doit(config, session) or 0\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/main.py\", line 247, in _main\r\nINTERNALERROR> config.hook.pytest_runtestloop(session=session)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/hooks.py\", line 286, in __call__\r\nINTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/manager.py\", line 93, in _hookexec\r\nINTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/manager.py\", line 84, in <lambda>\r\nINTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/callers.py\", line 208, in _multicall\r\nINTERNALERROR> return outcome.get_result()\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/callers.py\", line 80, in get_result\r\nINTERNALERROR> raise ex[1].with_traceback(ex[2])\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/callers.py\", line 187, in _multicall\r\nINTERNALERROR> res = hook_impl.function(*args)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/main.py\", line 272, in pytest_runtestloop\r\nINTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/hooks.py\", line 286, in __call__\r\nINTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/manager.py\", line 93, in _hookexec\r\nINTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/manager.py\", line 84, in <lambda>\r\nINTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/callers.py\", line 208, in _multicall\r\nINTERNALERROR> return outcome.get_result()\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/callers.py\", line 80, in get_result\r\nINTERNALERROR> raise ex[1].with_traceback(ex[2])\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/callers.py\", line 187, in _multicall\r\nINTERNALERROR> res = hook_impl.function(*args)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/runner.py\", line 85, in pytest_runtest_protocol\r\nINTERNALERROR> runtestprotocol(item, nextitem=nextitem)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/runner.py\", line 100, in runtestprotocol\r\nINTERNALERROR> reports.append(call_and_report(item, \"call\", log))\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/runner.py\", line 188, in call_and_report\r\nINTERNALERROR> report = hook.pytest_runtest_makereport(item=item, call=call)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/hooks.py\", line 286, in __call__\r\nINTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/manager.py\", line 93, in _hookexec\r\nINTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/manager.py\", line 84, in <lambda>\r\nINTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/callers.py\", line 203, in _multicall\r\nINTERNALERROR> gen.send(outcome)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/skipping.py\", line 129, in pytest_runtest_makereport\r\nINTERNALERROR> rep = outcome.get_result()\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/callers.py\", line 80, in get_result\r\nINTERNALERROR> raise ex[1].with_traceback(ex[2])\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/pluggy/callers.py\", line 187, in _multicall\r\nINTERNALERROR> res = hook_impl.function(*args)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/runner.py\", line 260, in pytest_runtest_makereport\r\nINTERNALERROR> return TestReport.from_item_and_call(item, call)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/reports.py\", line 294, in from_item_and_call\r\nINTERNALERROR> longrepr = item.repr_failure(excinfo)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/python.py\", line 1513, in repr_failure\r\nINTERNALERROR> return self._repr_failure_py(excinfo, style=style)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/nodes.py\", line 355, in _repr_failure_py\r\nINTERNALERROR> return excinfo.getrepr(\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_code/code.py\", line 634, in getrepr\r\nINTERNALERROR> return fmt.repr_excinfo(self)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_code/code.py\", line 879, in repr_excinfo\r\nINTERNALERROR> reprtraceback = self.repr_traceback(excinfo_)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_code/code.py\", line 823, in repr_traceback\r\nINTERNALERROR> reprentry = self.repr_traceback_entry(entry, einfo)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_code/code.py\", line 784, in repr_traceback_entry\r\nINTERNALERROR> reprargs = self.repr_args(entry) if not short else None\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_code/code.py\", line 693, in repr_args\r\nINTERNALERROR> args.append((argname, saferepr(argvalue)))\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py\", line 82, in saferepr\r\nINTERNALERROR> return SafeRepr(maxsize).repr(obj)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py\", line 51, in repr\r\nINTERNALERROR> s = _format_repr_exception(exc, x)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py\", line 23, in _format_repr_exception\r\nINTERNALERROR> exc_info, obj.__class__.__name__, id(obj)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py\", line 47, in repr\r\nINTERNALERROR> s = super().repr(x)\r\nINTERNALERROR> 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\r\nINTERNALERROR> return self.repr1(x, self.maxlevel)\r\nINTERNALERROR> 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\r\nINTERNALERROR> return self.repr_instance(x, level)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py\", line 60, in repr_instance\r\nINTERNALERROR> s = _format_repr_exception(exc, x)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py\", line 23, in _format_repr_exception\r\nINTERNALERROR> exc_info, obj.__class__.__name__, id(obj)\r\nINTERNALERROR> File \"/usr/local/lib/python3.8/site-packages/_pytest/_io/saferepr.py\", line 56, in repr_instance\r\nINTERNALERROR> s = repr(x)\r\nINTERNALERROR> File \"/Users/stiflou/Documents/projets/apischema/tests/test_pytest.py\", line 6, in __repr__\r\nINTERNALERROR> raise\r\nINTERNALERROR> RuntimeError: No active exception to reraise\r\n\r\n============================ no tests ran in 0.09s ============================\r\n```\n", |