Skip to content

Commit 5dd5d95

Browse files
author
Release Manager
committed
gh-41086: Fix doctests for Python 3.14 and support python 3.14 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 3.In cython 3.2, we should return a new reference because Cython expects an owned reference Now fix #41028 with cython 3.1.5 <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #41086 Reported by: Chenxin Zhong Reviewer(s): Chenxin Zhong, Dima Pasechnik, Tobias Diez
2 parents aa8778f + 0af32b8 commit 5dd5d95

34 files changed

+145
-130
lines changed

build/pkgs/python3/spkg-configure.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
SAGE_SPKG_CONFIGURE([python3], [
22
m4_pushdef([MIN_VERSION], [3.12.0])
33
m4_pushdef([MIN_NONDEPRECATED_VERSION], [3.12.0])
4-
m4_pushdef([LT_STABLE_VERSION], [3.14.0])
5-
m4_pushdef([LT_VERSION], [3.14.0])
4+
m4_pushdef([LT_STABLE_VERSION], [3.15.0])
5+
m4_pushdef([LT_VERSION], [3.15.0])
66
AC_ARG_WITH([python],
77
[AS_HELP_STRING([--with-python=PYTHON3],
88
[Python 3 executable to use for the Sage venv; default: python3])])

m4/pyproject_toml_metadata.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ classifiers = [
1313
"Programming Language :: Python :: Implementation :: CPython",
1414
"Topic :: Scientific/Engineering :: Mathematics",
1515
]
16-
requires-python = ">=3.9, <3.15"
16+
requires-python = ">=3.12, <3.15"
1717

1818
[project.urls]
1919
download = "https://doc.sagemath.org/html/en/installation/index.html"

pkgs/sage-setup/pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ classifiers = [
1515
"Operating System :: POSIX",
1616
"Operating System :: MacOS :: MacOS X",
1717
"Programming Language :: Python :: 3 :: Only",
18-
"Programming Language :: Python :: 3.9",
19-
"Programming Language :: Python :: 3.10",
20-
"Programming Language :: Python :: 3.11",
2118
"Programming Language :: Python :: 3.12",
19+
"Programming Language :: Python :: 3.13",
20+
"Programming Language :: Python :: 3.14",
2221
"Programming Language :: Python :: Implementation :: CPython",
2322
"Topic :: Scientific/Engineering :: Mathematics",
2423
]
2524
urls = {Homepage = "https://www.sagemath.org"}
26-
requires-python = ">=3.9, <3.14"
25+
requires-python = ">=3.12, <3.15"
2726
dependencies = []
2827
dynamic = ["version"]
2928

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ classifiers = [
3737
"Programming Language :: Python :: 3 :: Only",
3838
"Programming Language :: Python :: 3.12",
3939
"Programming Language :: Python :: 3.13",
40+
"Programming Language :: Python :: 3.14",
4041
"Programming Language :: Python :: Implementation :: CPython",
4142
"Topic :: Scientific/Engineering :: Mathematics",
4243
]
@@ -77,7 +78,7 @@ description = "Sage: Open Source Mathematics Software: Standard Python Library"
7778
dynamic = ["version"]
7879
license = { text = "GNU General Public License (GPL) v2 or later" }
7980
name = "sagemath"
80-
requires-python = ">=3.12, <3.14"
81+
requires-python = ">=3.12, <3.15"
8182
urls = { Homepage = "https://www.sagemath.org" }
8283

8384
[project.optional-dependencies]

src/doc/en/thematic_tutorials/tutorial-programming-python.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The *standard types* are :class:`bool`, :class:`int`, :class:`list`,
8787
sage: set([ [1], [2] ])
8888
Traceback (most recent call last):
8989
...
90-
TypeError: unhashable type: 'list'
90+
TypeError: ...unhashable type: 'list'...
9191

9292
* A *dictionary* is an association table, which associates values to
9393
keys. Keys must be hashable. One creates dictionaries using the
@@ -765,7 +765,7 @@ appear once and must be immutable::
765765
sage: d = {[1,2,3] : 12}
766766
Traceback (most recent call last):
767767
...
768-
TypeError: unhashable type: 'list'
768+
TypeError: ...unhashable type: 'list'...
769769

770770
Another way to add items to a dictionary is with the ``update()`` method which
771771
updates the dictionary from another dictionary::

src/sage/algebras/quantum_groups/quantum_group_gap.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,8 +2354,7 @@ def basis(self):
23542354
sage: Q = QuantumGroup(['A',2])
23552355
sage: B = Q.lower_half()
23562356
sage: basis = B.basis(); basis
2357-
Lazy family (monomial(i))_{i in The Cartesian product of
2358-
(Non negative integers, Non negative integers, Non negative integers)}
2357+
Lazy family (monomial(i))_{i in The Cartesian product of 3 copies of Non negative integers}
23592358
sage: basis[1,2,1]
23602359
F[a1]*F[a1+a2]^(2)*F[a2]
23612360
sage: basis[1,2,4]
@@ -2390,8 +2389,7 @@ def canonical_basis_elements(self):
23902389
sage: Q = QuantumGroup(['A',2])
23912390
sage: B = Q.lower_half()
23922391
sage: C = B.canonical_basis_elements(); C
2393-
Lazy family (Canonical basis(i))_{i in The Cartesian product of
2394-
(Non negative integers, Non negative integers)}
2392+
Lazy family (Canonical basis(i))_{i in The Cartesian product of 2 copies of Non negative integers}
23952393
sage: C[2,1]
23962394
[F[a1]^(2)*F[a2], F[a1]*F[a1+a2] + (q^2)*F[a1]^(2)*F[a2]]
23972395
sage: C[1,2]

src/sage/all.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@
9090
warnings.filterwarnings('default', category=DeprecationWarning,
9191
message=r'[\s\S]*See https?://trac\.sagemath\.org/[0-9]* for details.')
9292

93-
# Ignore Python 3.9 deprecation warnings
94-
warnings.filterwarnings('ignore', category=DeprecationWarning,
95-
module='ast')
96-
9793
# Ignore packaging 20.5 deprecation warnings
9894
warnings.filterwarnings('ignore', category=DeprecationWarning,
9995
module='(.*[.]_vendor[.])?packaging')
@@ -114,11 +110,6 @@
114110
message='The distutils(.sysconfig module| package) is deprecated',
115111
module='Cython|distutils|numpy|sage.env|sage.features')
116112

117-
# triggered by cython 0.29.32
118-
warnings.filterwarnings('ignore', category=DeprecationWarning,
119-
message="'cgi' is deprecated and slated for removal in Python 3.13",
120-
module='Cython')
121-
122113
# triggered by pyparsing 2.4.7
123114
warnings.filterwarnings('ignore', category=DeprecationWarning,
124115
message="module 'sre_constants' is deprecated",
@@ -152,11 +143,6 @@
152143
message=r"This process.* is multi-threaded, "
153144
r"use of .*\(\) may lead to deadlocks in the child.")
154145

155-
# pickling of itertools is deprecated in Python 3.12
156-
warnings.filterwarnings('ignore', category=DeprecationWarning,
157-
message=r"Pickle, copy, and deepcopy support will be "
158-
r"removed from itertools in Python 3.14.")
159-
160146
# rpy2>=3.6 emits warnings for R modifying LD_LIBRARY_PATH
161147
warnings.filterwarnings('ignore', category=UserWarning,
162148
message=r".*redefined by R and overriding existing variable.*",

src/sage/combinat/diagram_algebras.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def check(self):
357357
sage: pd2 = da.AbstractPartitionDiagram(pd, [[[1,2],[-1,-2]]]) # indirect doctest
358358
Traceback (most recent call last):
359359
...
360-
TypeError: unhashable type: 'list'
360+
TypeError: ...unhashable type: 'list'...
361361
"""
362362
if self._base_diagram:
363363
tst = frozenset(e for B in self._base_diagram for e in B)

src/sage/combinat/finite_state_machine.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ class FSMState(SageObject):
12991299
sage: A.determinisation()
13001300
Traceback (most recent call last):
13011301
...
1302-
TypeError: unhashable type: 'list'
1302+
TypeError: ...unhashable type: 'list'...
13031303
sage: A.state(0).color = ()
13041304
sage: A.determinisation()
13051305
Automaton with 1 state
@@ -6554,7 +6554,7 @@ def add_from_transition_function(self, function, initial_states=None,
65546554
sage: Transducer(transition, input_alphabet=[0], initial_states=[0])
65556555
Traceback (most recent call last):
65566556
...
6557-
TypeError: mutable vectors are unhashable
6557+
TypeError: ...mutable vectors are unhashable...
65586558
"""
65596559
if self.input_alphabet is None:
65606560
raise ValueError("No input alphabet is given. "
@@ -10951,7 +10951,7 @@ def determinisation(self):
1095110951
sage: A.determinisation()
1095210952
Traceback (most recent call last):
1095310953
...
10954-
TypeError: unhashable type: 'list'
10954+
TypeError: ...unhashable type: 'list'...
1095510955
sage: A.state(0).color = ()
1095610956
sage: A.determinisation()
1095710957
Automaton with 1 state

src/sage/combinat/words/word.py

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,16 @@ class InfiniteWord_iter_with_caching(WordDatatype_iter_with_caching, InfiniteWor
518518
519519
Pickle is not supported for infinite word defined by an iterator::
520520
521-
sage: dumps(w)
522-
Traceback (most recent call last):
523-
...
524-
TypeError: can...t...pickle...generator...object...
521+
sage: try:
522+
....: dumps(w)
523+
....: except TypeError as e:
524+
....: if "pickle" in str(e) and "generator" in str(e):
525+
....: print("TypeError raised in dumps() as expected")
526+
....: except Exception as e:
527+
....: print("Unexpected exception raised:", e)
528+
....: else:
529+
....: print("No exception raised, unexpected")
530+
TypeError raised in dumps() as expected
525531
"""
526532
pass
527533

@@ -557,10 +563,16 @@ class InfiniteWord_iter(WordDatatype_iter, InfiniteWord_class):
557563
558564
Pickle is not supported for infinite word defined by an iterator::
559565
560-
sage: dumps(w)
561-
Traceback (most recent call last):
562-
...
563-
TypeError: can...t...pickle...generator...object...
566+
sage: try:
567+
....: dumps(w)
568+
....: except TypeError as e:
569+
....: if "pickle" in str(e) and "generator" in str(e):
570+
....: print("TypeError raised in dumps() as expected")
571+
....: except Exception as e:
572+
....: print("Unexpected exception raised:", e)
573+
....: else:
574+
....: print("No exception raised, unexpected")
575+
TypeError raised in dumps() as expected
564576
"""
565577
pass
566578

@@ -659,10 +671,16 @@ class Word_iter_with_caching(WordDatatype_iter_with_caching, Word_class):
659671
660672
Pickle is not supported for word of unknown length defined by an iterator::
661673
662-
sage: dumps(w)
663-
Traceback (most recent call last):
664-
...
665-
TypeError: can...t...pickle...generator...object...
674+
sage: try:
675+
....: dumps(w)
676+
....: except TypeError as e:
677+
....: if "pickle" in str(e) and "generator" in str(e):
678+
....: print("TypeError raised in dumps() as expected")
679+
....: except Exception as e:
680+
....: print("Unexpected exception raised:", e)
681+
....: else:
682+
....: print("No exception raised, unexpected")
683+
TypeError raised in dumps() as expected
666684
"""
667685
pass
668686

@@ -696,10 +714,16 @@ class Word_iter(WordDatatype_iter, Word_class):
696714
697715
Pickle is not supported for word of unknown length defined by an iterator::
698716
699-
sage: dumps(w)
700-
Traceback (most recent call last):
701-
...
702-
TypeError: can...t...pickle...generator...object...
717+
sage: try:
718+
....: dumps(w)
719+
....: except TypeError as e:
720+
....: if "pickle" in str(e) and "generator" in str(e):
721+
....: print("TypeError raised in dumps() as expected")
722+
....: except Exception as e:
723+
....: print("Unexpected exception raised:", e)
724+
....: else:
725+
....: print("No exception raised, unexpected")
726+
TypeError raised in dumps() as expected
703727
"""
704728
pass
705729

0 commit comments

Comments
 (0)