trio icon indicating copy to clipboard operation
trio copied to clipboard

Make TracebackException work with Python 3.10.

Open nascheme opened this issue 4 years ago • 7 comments

Pass '_seen' argument as None if empty (on first call). Pass 'compact' kwarg as needed.

nascheme avatar Jun 04 '21 20:06 nascheme

This might fix #1899.

nascheme avatar Jun 04 '21 20:06 nascheme

Codecov Report

Merging #2030 (5b33786) into master (2195763) will decrease coverage by 6.43%. The diff coverage is 60.00%.

@@            Coverage Diff             @@
##           master    #2030      +/-   ##
==========================================
- Coverage   99.56%   93.12%   -6.44%     
==========================================
  Files         114      114              
  Lines       14618    14584      -34     
  Branches     1117     1117              
==========================================
- Hits        14554    13582     -972     
- Misses         43      937     +894     
- Partials       21       65      +44     
Impacted Files Coverage Δ
trio/_core/_multierror.py 88.88% <60.00%> (-9.99%) :arrow_down:
trio/_windows_pipes.py 0.00% <0.00%> (-100.00%) :arrow_down:
trio/_wait_for_object.py 0.00% <0.00%> (-100.00%) :arrow_down:
trio/_core/_windows_cffi.py 0.00% <0.00%> (-100.00%) :arrow_down:
trio/_subprocess_platform/windows.py 0.00% <0.00%> (-100.00%) :arrow_down:
...tests/test_multierror_scripts/apport_excepthook.py 0.00% <0.00%> (-100.00%) :arrow_down:
trio/_core/_io_windows.py 0.00% <0.00%> (-98.77%) :arrow_down:
trio/tests/test_wait_for_object.py 10.37% <0.00%> (-89.63%) :arrow_down:
trio/_core/tests/test_windows.py 17.82% <0.00%> (-82.18%) :arrow_down:
trio/tests/test_windows_pipes.py 25.33% <0.00%> (-74.67%) :arrow_down:
... and 37 more

codecov[bot] avatar Jun 04 '21 20:06 codecov[bot]

Is this covered in https://github.com/python-trio/trio/pull/1921?

altendky avatar Jun 11 '21 13:06 altendky

Is this covered in #1921?

I don't think so. It fixes the issue with the keyword argument. However there is a more subtle problem with Python 3.10. I believe the key commit is 6dfd1734f5b230bb8fbd2a9df806c1333b6652a8 in the cpython repo: bpo-42848: remove recursion from TracebackException (GH-24158)

The meaning of _seen = None is now different than from _seen = set(). If you pass _seen=set(), the __init__ method will not correctly initialize the TracebackException object.

nascheme avatar Jun 11 '21 23:06 nascheme

I believe we have just implemented different means of passing None or set(), but that they are the same result?

https://github.com/altendky/trio/blob/c079d3cfdf4b91c76cd9aa376d1ddb76db4d40d7/trio/_core/_multierror.py#L405-L423

I tried a GitHub compare but it isn't showing what I expect. https://github.com/altendky/trio/compare/c079d3cfdf4b91c76cd9aa376d1ddb76db4d40d7...5b3378629c492e5cc458c760d5d3b4df57f75218 So, here is a screenshot of my local diff. This PR on the left and https://github.com/python-trio/trio/pull/1921 on the right.

image

Aside from the _seen bit, it seems like the kwargs in this PR are unused.

altendky avatar Jun 14 '21 18:06 altendky

fixed in https://github.com/python-trio/trio/pull/1921 ?

graingert avatar Jul 22 '21 15:07 graingert

ah no this is different

graingert avatar Jul 22 '21 15:07 graingert

I think this has been fixed by the recent change to exceptiongroup, @agronholm can reopen if I'm wrong.

Zac-HD avatar Oct 30 '22 08:10 Zac-HD