From dcb03d189c517d6ce0404b362a477d86dc805116 Mon Sep 17 00:00:00 2001 From: Antonio Rojas Date: Sun, 22 Dec 2024 12:20:17 +0100 Subject: [PATCH 1/2] Fix tests output for Python 3.13 --- src/doc/de/tutorial/tour_linalg.rst | 2 +- src/doc/en/tutorial/tour_linalg.rst | 2 +- src/doc/fr/tutorial/tour_linalg.rst | 2 +- src/doc/ja/tutorial/tour_linalg.rst | 2 +- src/doc/pt/tutorial/tour_linalg.rst | 2 +- src/doc/ru/tutorial/tour_linalg.rst | 2 +- src/sage/categories/map.pyx | 4 ++-- src/sage/misc/bindable_class.py | 2 +- src/sage/misc/sagedoc.py | 13 +++++++------ src/sage/misc/sageinspect.py | 2 +- src/sage/modular/modsym/modsym.py | 2 +- src/sage/repl/attach.py | 4 ++-- src/sage/repl/rich_output/pretty_print.py | 2 +- 13 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/doc/de/tutorial/tour_linalg.rst b/src/doc/de/tutorial/tour_linalg.rst index 1be6540c89e..abd47d2c488 100644 --- a/src/doc/de/tutorial/tour_linalg.rst +++ b/src/doc/de/tutorial/tour_linalg.rst @@ -245,4 +245,4 @@ Beachten Sie, dass Python zwischen Klein- und Großschreibung unterscheidet: sage: M = MatrixSpace(QQ, 10,10, Sparse=True) Traceback (most recent call last): ... - TypeError: ...__init__() got an unexpected keyword argument 'Sparse' + TypeError: ...__init__() got an unexpected keyword argument 'Sparse'... diff --git a/src/doc/en/tutorial/tour_linalg.rst b/src/doc/en/tutorial/tour_linalg.rst index 84a45f4931b..d1dde6a485e 100644 --- a/src/doc/en/tutorial/tour_linalg.rst +++ b/src/doc/en/tutorial/tour_linalg.rst @@ -239,4 +239,4 @@ Note that Python is case sensitive: sage: M = MatrixSpace(QQ, 10,10, Sparse=True) Traceback (most recent call last): ... - TypeError: ...__init__() got an unexpected keyword argument 'Sparse' + TypeError: ...__init__() got an unexpected keyword argument 'Sparse'... diff --git a/src/doc/fr/tutorial/tour_linalg.rst b/src/doc/fr/tutorial/tour_linalg.rst index 582a915edef..0dcdf044453 100644 --- a/src/doc/fr/tutorial/tour_linalg.rst +++ b/src/doc/fr/tutorial/tour_linalg.rst @@ -241,4 +241,4 @@ Notez que Python distingue les majuscules des minuscules : sage: M = MatrixSpace(QQ, 10,10, Sparse=True) Traceback (most recent call last): ... - TypeError: ...__init__() got an unexpected keyword argument 'Sparse' + TypeError: ...__init__() got an unexpected keyword argument 'Sparse'... diff --git a/src/doc/ja/tutorial/tour_linalg.rst b/src/doc/ja/tutorial/tour_linalg.rst index 227f879136e..263c5d7943a 100644 --- a/src/doc/ja/tutorial/tour_linalg.rst +++ b/src/doc/ja/tutorial/tour_linalg.rst @@ -252,4 +252,4 @@ Pythonでは,大文字小文字が区別されることに注意: sage: M = MatrixSpace(QQ, 10,10, Sparse=True) Traceback (most recent call last): ... - TypeError: ...__init__() got an unexpected keyword argument 'Sparse' + TypeError: ...__init__() got an unexpected keyword argument 'Sparse'... diff --git a/src/doc/pt/tutorial/tour_linalg.rst b/src/doc/pt/tutorial/tour_linalg.rst index 806a36c6446..79eb3ac7a9c 100644 --- a/src/doc/pt/tutorial/tour_linalg.rst +++ b/src/doc/pt/tutorial/tour_linalg.rst @@ -220,4 +220,4 @@ Note que o Python é sensível a maiúsculas e minúsculas: sage: M = MatrixSpace(QQ, 10,10, Sparse=True) Traceback (most recent call last): ... - TypeError: ...__init__() got an unexpected keyword argument 'Sparse' + TypeError: ...__init__() got an unexpected keyword argument 'Sparse'... diff --git a/src/doc/ru/tutorial/tour_linalg.rst b/src/doc/ru/tutorial/tour_linalg.rst index bf2a1084544..6ed95084d90 100644 --- a/src/doc/ru/tutorial/tour_linalg.rst +++ b/src/doc/ru/tutorial/tour_linalg.rst @@ -214,4 +214,4 @@ Sage поддерживает разреженную линейную алгеб sage: M = MatrixSpace(QQ, 10,10, Sparse=True) Traceback (most recent call last): ... - TypeError: ...__init__() got an unexpected keyword argument 'Sparse' + TypeError: ...__init__() got an unexpected keyword argument 'Sparse'... diff --git a/src/sage/categories/map.pyx b/src/sage/categories/map.pyx index 43e476847d0..0007555326a 100644 --- a/src/sage/categories/map.pyx +++ b/src/sage/categories/map.pyx @@ -275,7 +275,7 @@ cdef class Map(Element): maps:: sage: phi.domain # needs sage.rings.number_field - + sage: phi._make_strong_references() # needs sage.rings.number_field sage: print(phi.domain) # needs sage.rings.number_field The constant function (...) -> Number Field in a @@ -343,7 +343,7 @@ cdef class Map(Element): maps:: sage: phi.domain # needs sage.rings.number_field - + sage: phi._make_strong_references() # needs sage.rings.number_field sage: print(phi.domain) # needs sage.rings.number_field The constant function (...) -> Number Field in a diff --git a/src/sage/misc/bindable_class.py b/src/sage/misc/bindable_class.py index 743b5a19da6..c23ba0c2c43 100644 --- a/src/sage/misc/bindable_class.py +++ b/src/sage/misc/bindable_class.py @@ -113,7 +113,7 @@ class BindableClass(metaclass=ClasscallMetaclass): Still, documentation works as usual:: sage: outer.Inner.__doc__ - ' some documentation ' + '...some documentation ' TESTS:: diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py index 0505f6039a9..539d90c0f0e 100644 --- a/src/sage/misc/sagedoc.py +++ b/src/sage/misc/sagedoc.py @@ -694,7 +694,7 @@ def format(s, embedded=False): We check that the todo Sphinx extension is correctly activated:: sage: sage.misc.sagedoc.format(sage.combinat.ranker.on_fly.__doc__) # needs sphinx - " Return ... Todo: add tests as in combinat::rankers\n" + "...Return ...Todo: add tests as in combinat::rankers\n" In the following use case, the ``nodetex`` directive would have been ignored prior to :issue:`11815`:: @@ -1135,10 +1135,11 @@ def search_src(string, extra1='', extra2='', extra3='', extra4='', The following produces an error because the string 'fetch(' is a malformed regular expression:: - sage: print(search_src(" fetch(", "def", interact=False)) - Traceback (most recent call last): - ... - error: missing ), unterminated subpattern at position 6 + sage: try: + ....: print(search_src(" fetch(", "def", interact=False)) + ....: except Exception as e: + ....: print(e) + missing ), unterminated subpattern at position 6 To fix this, *escape* the parenthesis with a backslash:: @@ -1456,7 +1457,7 @@ class _sage_doc: sage: browse_sage_doc._open("reference", testing=True)[0] # needs sagemath_doc_html 'http://localhost:8000/doc/live/reference/index.html' sage: browse_sage_doc(identity_matrix, 'rst')[-107:-47] # needs sage.modules - 'Full MatrixSpace of 3 by 3 sparse matrices over Integer Ring' + '...Full MatrixSpace of 3 by 3 sparse matrices...' """ def __init__(self): """ diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index 585112b5061..12f319fc8e3 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -1986,7 +1986,7 @@ def sage_getdoc(obj, obj_name='', embedded=False): sage: from sage.misc.sageinspect import sage_getdoc sage: sage_getdoc(identity_matrix)[87:124] # needs sage.modules - 'Return the n x n identity matrix over' + '...the n x n identity matrix...' sage: def f(a, b, c, d=1): return a+b+c+d ... sage: import functools diff --git a/src/sage/modular/modsym/modsym.py b/src/sage/modular/modsym/modsym.py index fb46d0edafa..ed7c9285169 100644 --- a/src/sage/modular/modsym/modsym.py +++ b/src/sage/modular/modsym/modsym.py @@ -369,7 +369,7 @@ def ModularSymbols(group=1, {} sage: M = ModularSymbols(11,use_cache=True) sage: sage.modular.modsym.modsym._cache - {(Congruence Subgroup Gamma0(11), 2, 0, Rational Field): } + {(Congruence Subgroup Gamma0(11), 2, 0, Rational Field): } sage: M is ModularSymbols(11,use_cache=True) True sage: M is ModularSymbols(11,use_cache=False) diff --git a/src/sage/repl/attach.py b/src/sage/repl/attach.py index b3e20fe61d8..b9997d8f2df 100644 --- a/src/sage/repl/attach.py +++ b/src/sage/repl/attach.py @@ -40,7 +40,7 @@ ....: traceback.print_exc(file=sys.stdout) Traceback (most recent call last): ... - exec(preparse_file(f.read()) + "\n", globals) + exec(preparse_file(f.read()) + "\n", globals)... File "", line 3, in ValueError: third sage: detach(src) @@ -52,7 +52,7 @@ ....: traceback.print_exc(file=sys.stdout) Traceback (most recent call last): ... - exec(code, globals) + exec(code, globals)... File ".../foobar...sage.py", line ..., in raise ValueError("third") # this should appear in the source snippet... ValueError: third diff --git a/src/sage/repl/rich_output/pretty_print.py b/src/sage/repl/rich_output/pretty_print.py index 93833e01cd8..8e00e3d70e4 100644 --- a/src/sage/repl/rich_output/pretty_print.py +++ b/src/sage/repl/rich_output/pretty_print.py @@ -160,7 +160,7 @@ def pretty_print(self): sage: seq._concatenate_graphs().show(edge_labels=True) # needs sage.graphs sage.plot Traceback (most recent call last): ... - TypeError: ...matplotlib() got an unexpected keyword argument 'edge_labels' + TypeError: ...matplotlib() got an unexpected keyword argument 'edge_labels'... """ try: from sage.plot.plot import Graphics From fd108891c041e010efc279939fa5ac81a37b4c4b Mon Sep 17 00:00:00 2001 From: Antonio Rojas Date: Sun, 22 Dec 2024 19:55:31 +0100 Subject: [PATCH 2/2] Fix meta-test broken by previous commit --- src/sage/misc/sagedoc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py index 539d90c0f0e..6147ec4983b 100644 --- a/src/sage/misc/sagedoc.py +++ b/src/sage/misc/sagedoc.py @@ -1187,7 +1187,6 @@ def search_src(string, extra1='', extra2='', extra3='', extra4='', misc/sagedoc.py:... len(search_src("matrix", interact=False).splitlines())... misc/sagedoc.py:... len(search_src("matrix", module="sage.calculus", interact=False).splitlines())... misc/sagedoc.py:... len(search_src("matrix", path_re="calc"... - misc/sagedoc.py:... print(search_src(" fetch(", "def", interact=False))... misc/sagedoc.py:... print(search_src(r" fetch\(", "def", interact=False))... misc/sagedoc.py:... print(search_src(r" fetch\(", "def", "pyx", interact=False))... misc/sagedoc.py:... s = search_src('Matrix', path_re='matrix', interact=False); s.find('x') > 0...