Opened 3 years ago
Closed 3 years ago
#27073 closed defect (fixed)
py3: fix artificial exception test in sphinxbuild.py
Reported by: | jdemeyer | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-8.7 |
Component: | python3 | Keywords: | |
Cc: | chapoton | Merged in: | |
Authors: | Jeroen Demeyer | Reviewers: | Erik Bray |
Report Upstream: | N/A | Work issues: | |
Branch: | 03a5413 (Commits, GitHub, GitLab) | Commit: | 03a54134f0d624c53eb7db774231a9c3da4cffba |
Dependencies: | Stopgaps: |
Description (last modified by )
This test is raising an exception and then it tries to display the traceback, long after the exception has been handled by the doctest framework. In Python 3 (and also after #24986), exceptions do not stay alive forever. The solution is fixing the test to construct the traceback in an except Exception
block.
sage -t src/sage_setup/docbuild/sphinxbuild.py ********************************************************************** File "src/sage_setup/docbuild/sphinxbuild.py", line 212, in sage_setup.docbuild.sphinxbuild.SageSphinxLogger._log_line Failed example: for line in traceback.format_exc().split('\n'): logger._log_line(line) Expected: [#25160 ] Traceback (most recent call last): [#25160 ] File ... [#25160 ] self.compile_and_execute(example, compiler, test.globs) [#25160 ] File ... [#25160 ] exec(compiled, globs) [#25160 ] File ... [#25160 ] raise Exception("artificial exception") [#25160 ] Exception: artificial exception Got: [#25160 ] NoneType: None **********************************************************************
While I was at it, I fixed one more trivial doctest failure. All tests in src/sage_setup/docbuild
now pass on Python 3.
Change History (10)
comment:1 Changed 3 years ago by
- Description modified (diff)
comment:2 follow-up: ↓ 3 Changed 3 years ago by
comment:3 in reply to: ↑ 2 Changed 3 years ago by
Replying to embray:
Just because of the
sys.exc_clear()
?
Indeed. Python 3 effectively does sys.exc_clear()
when leaving the try
/except
block.
comment:4 Changed 3 years ago by
- Branch set to u/jdemeyer/py3__fix_artificial_exception_test_in_sphinxbuild_py
comment:5 Changed 3 years ago by
- Commit set to 03a54134f0d624c53eb7db774231a9c3da4cffba
Branch pushed to git repo; I updated commit sha1. New commits:
03a5413 | Test type(logger) for py3 compatibility
|
comment:6 Changed 3 years ago by
- Description modified (diff)
- Status changed from new to needs_review
comment:7 Changed 3 years ago by
- Cc chapoton added
- Milestone changed from sage-8.6 to sage-8.7
comment:8 Changed 3 years ago by
- Status changed from needs_review to positive_review
Makes sense, thank you.
comment:9 Changed 3 years ago by
- Reviewers set to Erik Bray
comment:10 Changed 3 years ago by
- Branch changed from u/jdemeyer/py3__fix_artificial_exception_test_in_sphinxbuild_py to 03a54134f0d624c53eb7db774231a9c3da4cffba
- Resolution set to fixed
- Status changed from positive_review to closed
That makes sense--I agree the test is not good in the first place. Though I don't exactly understand why this changed. Just because of the
sys.exc_clear()
?It makes sense though--the Python 2 behavior of keeping exception objects and tracebacks around long past their applicability was not great to begin with.