Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AttributeError doctests when output includes a suggestion (part of python 3.12 support) #36403

Merged
merged 2 commits into from
Oct 14, 2023

Conversation

tornaria
Copy link
Contributor

@tornaria tornaria commented Oct 4, 2023

In python 3.12, attribute errors add a suggestion at the end of the
usual error message ("Did you mean ...?").

We add ... at the end of these doctest outputs to fix it.

This PR is split in two commits:

  • The bulk of the changes, in the first commit, was obtained automatically with:
    git grep -l "AttributeError:" src | xargs sed -ie \
        's/^ *\(AttributeError: .*\)\?has no attribute.*$/&.../'
    
  • The second commit includes 3 changes not catched by the sed pattern above.

Since this changes a lot of files and is bound to get old, I'd appreciate a quick review + merge to avoid trouble (the PR is long but almost trivial and the review should be easy).

I'll soon make a separate PR (on top of this one) with the rest of the support python 3.12 changes, which are maybe not so trivial but much shorter than this one.

Related: #36181

@mkoeppe 🙏

@tornaria tornaria mentioned this pull request Oct 4, 2023
5 tasks
Copy link
Member

@mkoeppe mkoeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@github-actions
Copy link

github-actions bot commented Oct 5, 2023

Documentation preview for this PR (built with commit f1b77b1; changes) is ready! 🎉

@vbraun
Copy link
Member

vbraun commented Oct 8, 2023

merge conflict

mkoeppe and others added 2 commits October 8, 2023 13:09
In python 3.12, attribute errors add a suggestion at the end of the
usual error message ("Did you mean ...?").

We add ... at the end of these doctest outputs to fix it.

This commit has the bulk of the changes, obtained with:

    git grep -l "AttributeError:" src | xargs sed -ie \
        's/^ *\(AttributeError: .*\)\?has no attribute.*$/&.../'
In python 3.12, attribute errors add a suggestion at the end of the
usual error message ("Did you mean ...?").

We add ... at the end of these doctest outputs to fix it.

This commit has a few manual changes which didn't match the sed pattern
in the previous commit.
@vbraun vbraun merged commit e716501 into sagemath:develop Oct 14, 2023
11 of 20 checks passed
@mkoeppe mkoeppe added this to the sage-10.2 milestone Oct 14, 2023
@tornaria tornaria deleted the py312-attribute_error branch October 16, 2023 13:23
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 19, 2023
    
This PR adds support for running with python 3.12 from system. This has
been tested on the python 3.12 branch of void linux (x86_64, x86_64-musl
and i686).

The first two commits correspond to sagemath#36403. The rest is split is small
pieces and I tried to add reasonable explanations in the commit
messages. Reviewing by commit may be easier (ignoring the first two,
already reviewed).

See also: sagemath#36181

### ⌛ Dependencies

sagemath#36403
    
URL: sagemath#36407
Reported by: Gonzalo Tornaría
Reviewer(s): Matthias Köppe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants