From f27d9eaaf747eeb0bc40d0d8f371b827bd60a09e Mon Sep 17 00:00:00 2001 From: mmatera Date: Mon, 27 Jan 2025 23:48:30 -0300 Subject: [PATCH 1/5] since Python 3.13, get_functions must check if the method is callable --- mathics/core/builtin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mathics/core/builtin.py b/mathics/core/builtin.py index 269300b2d..4450f70bb 100644 --- a/mathics/core/builtin.py +++ b/mathics/core/builtin.py @@ -468,6 +468,8 @@ def get_functions(self, prefix="eval", is_pymodule=False): for name in dir(self): if name.startswith(prefix): function = getattr(self, name) + if not hasattr(function, "__call__"): + continue pattern = function.__doc__ if pattern is None: # Fixes PyPy bug continue From bcd883ab8625b8eb98c12bbcdddde5cad9c4722c Mon Sep 17 00:00:00 2001 From: mmatera Date: Tue, 28 Jan 2025 15:25:34 -0300 Subject: [PATCH 2/5] In Python 3.13 margin spaces in docstrings are trimmed --- mathics/doc/doc_entries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathics/doc/doc_entries.py b/mathics/doc/doc_entries.py index 201d4ae19..b5043faec 100644 --- a/mathics/doc/doc_entries.py +++ b/mathics/doc/doc_entries.py @@ -93,7 +93,7 @@ r"""(?mx)^ # re.MULTILINE (multi-line match) # and re.VERBOSE (readable regular expressions ((?:.|\n)*?) - ^\s+([>#SX])>[ ](.*) # test-code indicator + ^\s*([>#SX])>[ ](.*) # test-code indicator ((?:\n\s*(?:[:|=.][ ]|\.).*)*) # test-code results""" ) TESTCASE_OUT_RE = re.compile(r"^\s*([:|=])(.*)$") From eb2232e12360c587ec6ee889c877cb89b49945c3 Mon Sep 17 00:00:00 2001 From: mmatera Date: Tue, 28 Jan 2025 16:44:26 -0300 Subject: [PATCH 3/5] Python 3.13 converts tabs into simple spaces in docstrings --- .github/workflows/ubuntu.yml | 2 +- mathics/builtin/files_io/importexport.py | 20 ++++++++++---------- mathics/doc/doc_entries.py | 12 +++++++----- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d886d5b64..bd0672df9 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.12', '3.11', '3.8', '3.9', '3.10'] + python-version: ['3.13', '3.12', '3.11', '3.8', '3.9', '3.8'] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/mathics/builtin/files_io/importexport.py b/mathics/builtin/files_io/importexport.py index e91f20179..9b0033230 100644 --- a/mathics/builtin/files_io/importexport.py +++ b/mathics/builtin/files_io/importexport.py @@ -1060,16 +1060,16 @@ class RegisterImport(Builtin): >> FilePrint["ExampleData/ExampleData.txt"] | Example File Format | Created by Angus - | 0.629452 0.586355 - | 0.711009 0.687453 - | 0.246540 0.433973 - | 0.926871 0.887255 - | 0.825141 0.940900 - | 0.847035 0.127464 - | 0.054348 0.296494 - | 0.838545 0.247025 - | 0.838697 0.436220 - | 0.309496 0.833591 + | 0.629452 0.586355 + | 0.711009 0.687453 + | 0.246540 0.433973 + | 0.926871 0.887255 + | 0.825141 0.940900 + | 0.847035 0.127464 + | 0.054348 0.296494 + | 0.838545 0.247025 + | 0.838697 0.436220 + | 0.309496 0.833591 >> Import["ExampleData/ExampleData.txt", {"ExampleFormat1", "Elements"}] = {Data, Header} diff --git a/mathics/doc/doc_entries.py b/mathics/doc/doc_entries.py index b5043faec..e91d88af7 100644 --- a/mathics/doc/doc_entries.py +++ b/mathics/doc/doc_entries.py @@ -216,10 +216,7 @@ def parse_docstring_to_DocumentationEntry_items( logging.warning("``key_part`` is deprecated. Its value is discarded.") # Remove commented lines. - doc = filter_comments(doc).strip(r"\s") - - # Remove leading
...
- # doc = DL_RE.sub("", doc) + doc = filter_comments(doc) # .strip("\s") # pre-substitute Python code because it might contain tests doc, post_substitutions = pre_sub( @@ -394,11 +391,16 @@ def compare_out(self, outs: tuple = tuple()) -> bool: # Mismatched number of output lines, and we don't have "..." return False + # Python 3.13 replaces tabs by a single space in docstrings. + # In doctests we replace tabs by sequences of four spaces. + def tabs_to_spaces(val): + return val.text.replace("\t", 4 * " ") + # Need to check all output line by line for got, wanted in zip(outs, wanted_outs): if wanted.text == "...": return True - if not got == wanted: + if not tabs_to_spaces(got) == tabs_to_spaces(wanted): return False return True From f73364b5326a931212656a58d9778467b3b9bb84 Mon Sep 17 00:00:00 2001 From: mmatera Date: Tue, 28 Jan 2025 19:21:36 -0300 Subject: [PATCH 4/5] push workflows --- .github/workflows/macos.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- .github/workflows/windows.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 5bdcf7d0e..936886042 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [macOS] - python-version: ['3.10', '3.11'] + python-version: ['3.13', '3.12'] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index bd0672df9..ee770cba9 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.13', '3.12', '3.11', '3.8', '3.9', '3.8'] + python-version: ['3.13', '3.12', '3.11', '3.10', '3.9'] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ad2ffffae..d409e9578 100755 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -14,7 +14,7 @@ jobs: os: [windows] # "make doctest" on MS Windows fails without showing much of a # trace of where things went wrong on Python before 3.11. - python-version: ['3.12'] + python-version: ['3.13', '3.12'] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} From 29706ae321a24cbc457956fe88940273cea374af Mon Sep 17 00:00:00 2001 From: Juan Mauricio Matera Date: Tue, 28 Jan 2025 19:36:39 -0300 Subject: [PATCH 5/5] Update windows.yml --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index d409e9578..ad2ffffae 100755 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -14,7 +14,7 @@ jobs: os: [windows] # "make doctest" on MS Windows fails without showing much of a # trace of where things went wrong on Python before 3.11. - python-version: ['3.13', '3.12'] + python-version: ['3.12'] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }}