agronholm / exceptiongroup

Backport of PEP 654 (exception groups)
Other
42 stars 20 forks source link

AttributeError: 'TracebackException' object has no attribute '__cause__' on 1.1.3 #81

Closed catap closed 1 year ago

catap commented 1 year ago
:info:test During handling of the above exception, another exception occurred:
:info:test Traceback (most recent call last):
:info:test   File "/opt/local/bin/py.test-3.7", line 33, in <module>
:info:test     sys.exit(load_entry_point('pytest==7.4.0', 'console_scripts', 'py.test')())
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 189, in console_main
:info:test     code = main()
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 167, in main
:info:test     config=config
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/_hooks.py", line 433, in __call__
:info:test     return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/_manager.py", line 112, in _hookexec
:info:test     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/_callers.py", line 116, in _multicall
:info:test     raise exception.with_traceback(exception.__traceback__)
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/_callers.py", line 80, in _multicall
:info:test     res = hook_impl.function(*args)
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/main.py", line 317, in pytest_cmdline_main
:info:test     return wrap_session(config, _main)
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/main.py", line 290, in wrap_session
:info:test     config.notify_exception(excinfo, config.option)
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 1106, in notify_exception
:info:test     funcargs=True, showlocals=getattr(option, "showlocals", False), style=style
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/_code/code.py", line 686, in getrepr
:info:test     self.traceback[0]._rawentry if self.traceback else None,
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/traceback.py", line 121, in format_exception
:info:test     type(value), value, tb, limit=limit).format(chain=chain))
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/trio/_core/_multierror.py", line 423, in traceback_exception_format
:info:test     yield from traceback_exception_original_format(self, chain=chain)
:info:test   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/exceptiongroup/_formatting.py", line 226, in format
:info:test     if exc.__cause__ is not None:
:info:test AttributeError: 'TracebackException' object has no attribute '__cause__'
agronholm commented 1 year ago

How do I reproduce this? Is this a regression from a previous release?

catap commented 1 year ago

I try to run unit tests for pytest-asyncio via MacPorts. I have no idea regarding previous release :(

agronholm commented 1 year ago

How did you run the tests? Did you run them via tox? If not, please try that first.

catap commented 1 year ago

@agronholm I run it via pytest. Why is it wrong way?

agronholm commented 1 year ago

tox creates controlled virtualenvs to ensure that the correct dependencies are installed.

agronholm commented 1 year ago

Running pytest directly isn't wrong per se, but you need to know what you're doing.

catap commented 1 year ago

@agronholm yes, but how does venv affect to that issue?

agronholm commented 1 year ago

Without a virtualenv, pytest might pick up test plugins that adversely affect the test run. I've seen it happen many times before.

catap commented 1 year ago

@agronholm it happened on python-3.7 which is installed into MacPorts prefix. This is clean machine (virtual machine) and it has installed only this dependnecies => no wrong plugins.

At start of pytest it says:

:info:test platform darwin -- Python 3.7.17, pytest-7.4.0, pluggy-1.2.0
:info:test rootdir: /opt/local/var/macports/build/_Users_catap_src_macports-ports_python_py-pytest-asyncio/py37-pytest-asyncio/work/pytest-asyncio-0.21.1
:info:test configfile: setup.cfg
:info:test testpaths: tests
:info:test plugins: trio-0.8.0, hypothesis-6.79.4, flaky-3.7.0

All three plugins are required: https://github.com/pytest-dev/pytest-asyncio/blob/main/setup.cfg#L46-L51

agronholm commented 1 year ago

Which version of pytest-asyncio are you testing against?

catap commented 1 year ago

0.21.1

catap commented 1 year ago

Let me downgrade the version of exceptiongroup

agronholm commented 1 year ago

I just ran tox -e py37 on a fresh checkout of pytest-asyncio after checking out the v0.21.1 tag, and it passed just fine.

agronholm commented 1 year ago

Are you 100% sure you were running the latest exceptiongroup release? I've seen a traceback like that with previous versions.

catap commented 1 year ago

Yes, defently. Let me double check everything.

catap commented 1 year ago

What a wired things. If I install pytest-asyncio it works. Otherwise it fails.

Sorry for noise, it isn't a bug.