-
-
Notifications
You must be signed in to change notification settings - Fork 679
Fix doctests for Python 3.14 #41086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cxzhong
wants to merge
4
commits into
sagemath:develop
Choose a base branch
from
cxzhong:fix-unhashable-doctests-develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix doctests for Python 3.14 #41086
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… use ellipsis pattern Python 3.14 changed the format of TypeError messages for unhashable types from: TypeError: unhashable type: 'list' to: TypeError: cannot use 'list' as a dict key (unhashable type: 'list') Updated all doctests to use ellipsis pattern (e.g., 'TypeError: ...unhashable...') to match both old and new error message formats. Modified 25 files across multiple modules including: - Documentation (tutorial-programming-python.rst) - Graph modules (graph.py, generic_graph.py, c_graph.pyx, bipartite_graph.py) - Combinatorics (diagram_algebras.py, finite_state_machine.py) - Sets (disjoint_set.pyx, set.py) - Geometry (polyhedron modules) - Structure (sage_object.pyx, unique_representation.py) - Matrix (matrix0.pyx) - Misc utilities (weak_dict.pyx, cachefunc.pyx) - P-adic rings (qadic_flint_*.pyx, padic_ZZ_pX_CR_element.pyx) - Polynomials (multi_polynomial.pyx, polynomial_element.pyx) - Modules (indexed_element.pyx, tutorial_free_modules.py) - Topology (simplicial_complex.py)
|
Documentation preview for this PR (built with commit 32899be; changes) is ready! 🎉 |
Python 3.14 changed several error message formats: - ZeroDivisionError: 'float division' -> '...division' - ValueError list.index: '5 is not in list' -> '...not in list' - TypeError pickle generator: Added exception chaining, use try-except Files fixed: - src/sage/plot/colors.py: ZeroDivisionError message - src/sage/structure/list_clone.pyx: ValueError message - src/sage/combinat/words/word.py: TypeError with pickle (4 occurrences)
Python 3.14 changed the format of PicklingError messages. Use try-except blocks instead of matching exact error output for more robust testing. Files fixed: - src/sage/structure/sage_object.pyx: _test_pickling() - src/sage/sets/set_from_iterator.py: DummyExampleForPicklingTest - src/sage/misc/sage_unittest.py: TestSuite Blah example class
Instead of using try-except to catch unpicklable iterators like itertools.count (which can't be pickled in Python 3.14), changed the doctests to use list iterators which ARE picklable. This properly tests that the __reduce__ method works correctly while being compatible with Python 3.14's removal of pickle support for itertools objects.
bd24622 to
32899be
Compare
Seems in python 3.14 we can not pickle itertools.count in python 3.14 So we have to change the doctest in lazy_list. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix all doctests exceptions raise changes in python 3.14.
1.Just for lazy_list, The from itertools import count is not picklable. It seems a new change in python 3.14.
2.In python 3.14, the error of PicklingError changes a lot. I have to use try.. except to detect it
Now fix #41028 with cython 3.1.5
📝 Checklist
⌛ Dependencies