Skip to content

Commit b5b3ac2

Browse files
committed
Update package versions and improve error handling in download module
- Update flit_core version to 3.12.0 and adjust checksums - Update Python version requirements to <3.15 in pyproject.toml - Enhance error handling in transfer.py for HTTP errors - Modify SpecialJordanAlgebra to handle infinite sets correctly - Improve atexit callback error messages for version detection - Clean up unnecessary code in external.py and forker.py - Update error messages in DiGraph class for clarity - Refactor SageArgSpecVisitor to use new Constant node representation
1 parent 47bce83 commit b5b3ac2

File tree

12 files changed

+77
-102
lines changed

12 files changed

+77
-102
lines changed

build/pkgs/flit_core/checksums.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
tarball=flit_core-VERSION-py3-none-any.whl
2-
sha1=cf044db53e986d0735ad708cce9eba0b71684168
3-
sha256=7aada352fb0c7f5538c4fafeddf314d3a6a92ee8e2b1de70482329e42de70301
2+
sha1=9c5a446c78248128451f107c5ec857f6c1d005fb
3+
sha256=e7a0304069ea895172e3c7bb703292e992c5d1555dd1233ab7b5621b5b69e62c
44
upstream_url=https://files.pythonhosted.org/packages/py3/f/flit_core/flit_core-VERSION-py3-none-any.whl
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.9.0
1+
3.12.0

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.11.0])
33
m4_pushdef([MIN_NONDEPRECATED_VERSION], [3.11.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])])

build/sage_bootstrap/download/transfer.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
from sage_bootstrap.stdio import flush
2323
from sage_bootstrap.compat import urllib
24+
import urllib.request
25+
import urllib.error
2426

2527

2628
class ProgressBar(object):
@@ -99,13 +101,6 @@ def __init__(self, url, destination=None, progress=True, ignore_errors=False):
99101
self.progress_stream = sys.stderr if isinstance(progress, bool) else progress
100102
self.ignore_errors = ignore_errors
101103

102-
def http_error_default(self, url, fp, errcode, errmsg, headers):
103-
"""
104-
Callback for the URLopener to raise an exception on HTTP errors
105-
"""
106-
fp.close()
107-
raise DownloadError(errcode, errmsg, url)
108-
109104
def start_progress_bar(self):
110105
if self.progress:
111106
self.progress_bar = ProgressBar(self.progress_stream)
@@ -120,19 +115,22 @@ def error_progress_bar(self):
120115
self.progress_bar.error_stop()
121116

122117
def run(self):
123-
opener = urllib.FancyURLopener()
124-
opener.http_error_default = self.http_error_default
125118
self.start_progress_bar()
126119
try:
127120
if self.progress:
128-
filename, info = opener.retrieve(
121+
filename, info = urllib.request.urlretrieve(
129122
self.url, self.destination, self.progress_bar)
130123
else:
131-
filename, info = opener.retrieve(
124+
filename, info = urllib.request.urlretrieve(
132125
self.url, self.destination)
133126
except IOError as error:
134127
self.error_progress_bar()
135128
log.error(error)
136129
if not self.ignore_errors:
137130
raise error
131+
except urllib.error.HTTPError as error:
132+
self.error_progress_bar()
133+
log.error(error)
134+
if not self.ignore_errors:
135+
raise DownloadError(error.code, error.reason, self.url)
138136
self.success_progress_bar()

pkgs/sage-setup/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ classifiers = [
2323
"Topic :: Scientific/Engineering :: Mathematics",
2424
]
2525
urls = {Homepage = "https://www.sagemath.org"}
26-
requires-python = ">=3.9, <3.14"
26+
requires-python = ">=3.9, <3.15"
2727
dependencies = []
2828
dynamic = ["version"]
2929

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ description = "Sage: Open Source Mathematics Software: Standard Python Library"
8282
dynamic = ["version"]
8383
license = { text = "GNU General Public License (GPL) v2 or later" }
8484
name = "sagemath"
85-
requires-python = ">=3.11, <3.14"
85+
requires-python = ">=3.11, <3.15"
8686
urls = { Homepage = "https://www.sagemath.org" }
8787

8888
[project.optional-dependencies]

src/sage/algebras/jordan_algebra.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,14 @@ def basis(self):
325325
B = self._A.basis()
326326
return Family(B.keys(), lambda x: self.element_class(self, B[x]), name="Term map")
327327

328-
algebra_generators = basis
328+
def algebra_generators(self):
329+
B = self._A.basis()
330+
K = B.keys()
331+
try:
332+
len(K)
333+
except NotImplementedError:
334+
raise NotImplementedError("infinite set")
335+
return Family(K, lambda x: self.element_class(self, B[x]), name="Term map")
329336

330337
# TODO: Keep this until we can better handle R.<...> shorthand
331338
def gens(self) -> tuple:
@@ -347,7 +354,13 @@ def gens(self) -> tuple:
347354
...
348355
NotImplementedError: infinite set
349356
"""
350-
return tuple(self.algebra_generators())
357+
G = self.algebra_generators()
358+
# If G is infinite, len(G) will raise NotImplementedError('infinite set')
359+
try:
360+
len(G)
361+
except NotImplementedError:
362+
raise
363+
return tuple(G)
351364

352365
@cached_method
353366
def zero(self):

src/sage/cpython/atexit.pyx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,11 @@ cdef extern from *:
171171
return state.callbacks;
172172
}
173173
174-
// Dummy function for Python 3.14+ (never called)
174+
// Dummy function for Python 3.14+ (should never be called)
175175
static atexit_callback_struct** get_atexit_callbacks_array(PyObject *self) {
176+
PyErr_SetString(PyExc_RuntimeError,
177+
"get_atexit_callbacks_array() called on Python 3.14+. "
178+
"This is a bug in sage.cpython.atexit version detection.");
176179
return NULL;
177180
}
178181
#else
@@ -188,8 +191,11 @@ cdef extern from *:
188191
return (atexit_callback_struct**)state.callbacks;
189192
}
190193
191-
// Dummy function for Python < 3.14 (never called)
194+
// Dummy function for Python < 3.14 (should never be called)
192195
static PyObject* get_atexit_callbacks_list(PyObject *self) {
196+
PyErr_SetString(PyExc_RuntimeError,
197+
"get_atexit_callbacks_list() called on Python < 3.14. "
198+
"This is a bug in sage.cpython.atexit version detection.");
193199
return NULL;
194200
}
195201
#endif
@@ -216,7 +222,8 @@ def _get_exithandlers():
216222
if sys.version_info >= (3, 14):
217223
callbacks_list = <object>get_atexit_callbacks_list(atexit)
218224
if callbacks_list is None:
219-
return exithandlers
225+
# An error occurred (shouldn't happen unless there's a version detection bug)
226+
raise RuntimeError("Failed to get atexit callbacks list")
220227
# callbacks is a list of tuples: [(func, args, kwargs), ...]
221228
# Normalize kwargs to ensure it's always a dict (not None)
222229
# Note: In Python 3.14+, atexit stores callbacks in LIFO order
@@ -230,6 +237,9 @@ def _get_exithandlers():
230237
else:
231238
# Python < 3.14 uses C array
232239
callbacks = get_atexit_callbacks_array(atexit)
240+
if callbacks is NULL:
241+
# An error occurred (shouldn't happen unless there's a version detection bug)
242+
raise RuntimeError("Failed to get atexit callbacks array")
233243
for idx in range(atexit._ncallbacks()):
234244
callback = callbacks[idx][0]
235245
if callback.kwargs:

src/sage/doctest/external.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
# With OS X, Python 3.8 defaults to use 'spawn' instead of 'fork' in
3838
# multiprocessing, and Sage doctesting doesn't work with 'spawn'. See
3939
# trac #27754.
40-
if platform.system() == 'Darwin':
41-
multiprocessing.set_start_method('fork', force=True)
40+
multiprocessing.set_start_method('fork', force=True)
4241
Array = multiprocessing.Array
4342

4443
# Functions in this module whose name is of the form 'has_xxx' tests if the

src/sage/doctest/forker.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@
9191
# With OS X, Python 3.8 defaults to use 'spawn' instead of 'fork' in
9292
# multiprocessing, and Sage doctesting doesn't work with 'spawn'. See
9393
# trac #27754.
94-
if platform.system() == 'Darwin':
95-
multiprocessing.set_start_method('fork', force=True)
94+
multiprocessing.set_start_method('fork', force=True)
9695

9796

9897
def _sorted_dict_pprinter_factory(start, end):

0 commit comments

Comments
 (0)