#30162 closed enhancement (fixed)

Make doctests accept Python 3.8.x respellings of some error messages

Reported by: mkoeppe Owned by:
Priority: major Milestone: sage-9.2
Component: python3 Keywords:
Cc: jhpalmieri, thansen, chapoton, arojas, fbissey Merged in:
Authors: Matthias Koeppe Reviewers: Antonio Rojas
Report Upstream: N/A Work issues:
Branch: c43343c (Commits, GitHub, GitLab) Commit: c43343c3b767e0029b1f1d3c3fdc102dc1e8cd31
Dependencies: Stopgaps:

Status badges

Description (last modified by mkoeppe)

Inspired by https://salsa.debian.org/science-team/sagemath/-/blob/master/debian/patches/u0-version-python-3.8.patch we do

git grep -l ^\ \*[A-Za-z]\*Error.\*can\'t | xargs sed -i.bak s/Error:\ \\\(.*\\\)an\'t/Error:\ \\1an...t/ 

Change History (17)

comment:1 Changed 15 months ago by mkoeppe

  • Description modified (diff)

comment:2 Changed 15 months ago by mkoeppe

  • Branch set to u/mkoeppe/make_doctests_accept_python_3_8_x_respellings_of_some_error_messages

comment:3 Changed 15 months ago by mkoeppe

  • Authors set to Matthias Koeppe
  • Commit set to 60a8922223959424b9e89140c9c5258fa23cb826
  • Status changed from new to needs_review

New commits:

60a8922In doctests, accept both can't and cannot in error messages

comment:4 Changed 15 months ago by mkoeppe

  • Cc arojas fbissey added

comment:5 Changed 15 months ago by arojas

The one in src/doc/en/faq/faq-usage.rst is not a test, should be changed to one of the two variants but not to the wildcard IMO

comment:6 Changed 15 months ago by git

  • Commit changed from 60a8922223959424b9e89140c9c5258fa23cb826 to 71da37b486fed8c95fe5e303d62030d0de8086d9

Branch pushed to git repo; I updated commit sha1. New commits:

71da37bFixup

comment:7 Changed 15 months ago by mkoeppe

Thanks for catching this; fixed.

comment:8 Changed 15 months ago by arojas

  • Status changed from needs_review to needs_work

Some errors need further wildcarding

File "src/sage/combinat/words/word.py", line 511, in sage.combinat.words.word.InfiniteWord_iter_with_caching
Failed example:
    dumps(w)
Expected:
    Traceback (most recent call last):
    ...
    TypeError: can...t pickle generator objects
Got:
    <BLANKLINE>
    Traceback (most recent call last):
      File "sage/misc/persist.pyx", line 290, in sage.misc.persist.dumps (build/cythonized/sage/misc/persist.c:4285)
        return obj.dumps(compress)
      File "sage/structure/sage_object.pyx", line 476, in sage.structure.sage_object.SageObject.dumps (build/cythonized/sage/structure/sage_object.c:3788)
        return _base_dumps(self, compress=compress)
      File "sage/misc/persist.pyx", line 263, in sage.misc.persist._base_dumps (build/cythonized/sage/misc/persist.c:4013)
        gherkin = SagePickler.dumps(obj)
      File "sage/misc/persist.pyx", line 878, in sage.misc.persist.SagePickler.dumps (build/cythonized/sage/misc/persist.c:6802)
        pickler.dump(obj)
    TypeError: cannot pickle 'generator' object

comment:9 Changed 15 months ago by git

  • Commit changed from 71da37b486fed8c95fe5e303d62030d0de8086d9 to 2727aa8a97da050c3a0702a66aa37723a940ee09

Branch pushed to git repo; I updated commit sha1. New commits:

2727aa8src/sage/combinat/words/word.py: More wildcarding for respelled error messages

comment:10 Changed 15 months ago by mkoeppe

  • Status changed from needs_work to needs_review

comment:11 Changed 15 months ago by arojas

Some further error message changes that you may want to address here (taken from my downstream patch):

diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
index 0e4f9a4969..54310a6e8c 100644
--- a/src/sage/cpython/getattr.pyx
+++ b/src/sage/cpython/getattr.pyx
@@ -319,7 +319,7 @@ cpdef getattr_from_other_class(self, cls, name):
         Traceback (most recent call last):
         ...
         TypeError: descriptor '__weakref__' for 'A' objects doesn't apply
-        to 'sage.rings.integer.Integer' object
+        to a 'sage.rings.integer.Integer' object
 
     When this occurs, an ``AttributeError`` is raised::
 
diff --git a/src/sage/cpython/wrapperdescr.pyx b/src/sage/cpython/wrapperdescr.pyx
index c25d955fa0..ba1092dd81 100644
--- a/src/sage/cpython/wrapperdescr.pyx
+++ b/src/sage/cpython/wrapperdescr.pyx
@@ -79,7 +79,7 @@ def wrapperdescr_call(slotwrapper, self, *args, **kwds):
         sage: wrapperdescr_call(Integer.__mul__, 1, 2, 3)
         Traceback (most recent call last):
         ...
-        TypeError: expected 1 arguments, got 2
+        TypeError: expected 1 argument, got 2
         sage: wrapperdescr_call(Integer.__mul__, 6, other=9)
         Traceback (most recent call last):
         ...
diff --git a/src/sage/repl/preparse.py b/src/sage/repl/preparse.py
index 6a9c2b4fe4..ab4a83ec83 100644
--- a/src/sage/repl/preparse.py
+++ b/src/sage/repl/preparse.py
@@ -804,7 +804,7 @@ def preparse_numeric_literals(code, extract=False):
         sage: 123__45 # py3
         Traceback (most recent call last):
         ...
-        SyntaxError: invalid token
+        SyntaxError: invalid decimal literal
 
         sage: preparse_numeric_literals('3040_1_')
         '3040_1_'
@@ -815,7 +815,7 @@ def preparse_numeric_literals(code, extract=False):
         sage: 3040_1_ # py3
         Traceback (most recent call last):
         ...
-        SyntaxError: invalid token
+        SyntaxError: invalid decimal literal
     """
     literals = {}
     last = 0
diff --git a/src/sage/sets/real_set.py b/src/sage/sets/real_set.py
index 537501f526..b6842fbcda 100644
--- a/src/sage/sets/real_set.py
+++ b/src/sage/sets/real_set.py
@@ -20,7 +20,7 @@ half-open intervals does not work::
     sage: RealSet([0,1))
     Traceback (most recent call last):
     ...
-    SyntaxError: invalid syntax
+    SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
     
 Instead, you can use the following construction functions::
 

comment:12 Changed 15 months ago by mkoeppe

Thank you! Will do.

comment:13 Changed 15 months ago by git

  • Commit changed from 2727aa8a97da050c3a0702a66aa37723a940ee09 to c43343c3b767e0029b1f1d3c3fdc102dc1e8cd31

Branch pushed to git repo; I updated commit sha1. New commits:

c43343cEven more wildcarding for respelled error messages; remove some py2-only tests

comment:14 Changed 15 months ago by mkoeppe

The pyflakes warning is a flake. Otherwise green. Needs review

comment:15 Changed 15 months ago by arojas

  • Reviewers set to Antonio Rojas
  • Status changed from needs_review to positive_review

comment:16 Changed 15 months ago by mkoeppe

Thanks!

comment:17 Changed 15 months ago by vbraun

  • Branch changed from u/mkoeppe/make_doctests_accept_python_3_8_x_respellings_of_some_error_messages to c43343c3b767e0029b1f1d3c3fdc102dc1e8cd31
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.