-
-
Couldn't load subscription status.
- Fork 682
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
base: develop
Are you sure you want to change the base?
Fix doctests for Python 3.14 #41086
Conversation
… 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 2ef51cb; 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. |
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