◐ Shell
reader mode source ↗
Skip to content

gh-109798: Normalize _datetime and datetime error messages#127345

Merged
pganssle merged 31 commits into
python:mainfrom
donbarbos:issue-109798
Feb 12, 2025
Merged

gh-109798: Normalize _datetime and datetime error messages#127345
pganssle merged 31 commits into
python:mainfrom
donbarbos:issue-109798

Conversation

@donbarbos

@donbarbos donbarbos commented Nov 27, 2024

Copy link
Copy Markdown
Contributor

I only updated the messages, I fixed everything I found.
From these errors:

ValueError: ('year must be in 1..9999', {year})
ValueError: Year is out of range: {year}
ValueError: year {year} is out of range
ValueError: Year {year} is out of range

i made this one error:

ValueError: year must be in 1..9999, not {year} 

and I made the same message template for the fields year, month, day, hour, minute, second, microsecond and fold because I decided that it was worth leaving the field that was received in the output and at the same time using one string instead of tuple.
with the rest of the error messages it's easier, I just reduced them to one type

@bedevere-app

bedevere-app Bot commented Nov 27, 2024

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@donbarbos donbarbos changed the title Update error messages to be the same in datetime Nov 27, 2024
@erlend-aasland

Copy link
Copy Markdown
Contributor

BTW, please do not force-push; it makes reviewing harder. Moreover, all commits are squashed upon merge anyway, so there's no need for the PR/branch to be cluttered with amendment commits. See also the devguide.

@donbarbos

Copy link
Copy Markdown
Contributor Author

@erlend-aasland sorry, i got it.
These are all the inconsistencies in error messages I have found so far.
I'm done with this and that's enough for now.

@erlend-aasland erlend-aasland changed the title gh-109798: Update error messages to be the same in datetime Nov 29, 2024
donbarbos and others added 6 commits November 29, 2024 13:30
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

Some nitpicks, and two notes:

  • I'm happy with doing this, but we do need to be aware that this is a slight breaking change for anybody relying on the exception messages. They shouldn't be doing that, but we need to be aware of it anyway.
  • It's fine right now, but PyErr_Format with %R can have unintended side effects if the __repr__ of the passed object is evil. Again, not a problem here as far as I can tell, but it's definitely worth noting.

24 hidden items Load more…
donbarbos and others added 6 commits November 30, 2024 04:17
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

Now, how far fetched is it to ask for some assertRaisesRegex tests 😄

@donbarbos

Copy link
Copy Markdown
Contributor Author

@ZeroIntensity i added tests ✅ ,
but if you need tests for the fromisoformat method - need to merge this PR #127242 because it solves many problems, for example, the rules for different implementations may seem different

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

Getting close to ready :)

donbarbos and others added 4 commits December 1, 2024 07:43
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
@donbarbos

donbarbos commented Dec 20, 2024

Copy link
Copy Markdown
Contributor Author

@erlend-aasland could you merge it? (if you have time :-)

@ZeroIntensity

Copy link
Copy Markdown
Member

FYI, most of the core devs are done for the holidays. You'll have to wait until after the new year probably.

@pganssle pganssle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

I strongly suspect that this is going to break people who are testing against exact error messages, but that's really not part of our public API, so that is fine.

@donbarbos

Copy link
Copy Markdown
Contributor Author

@pganssle CI successfully passed 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants