GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-64376: Use Argument Clinic for datetime.date classmethods by hauntsaninja · Pull Request #20208 · python/cpython

Conversation

@hauntsaninja

@hauntsaninja hauntsaninja commented May 19, 2020 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

https://bugs.python.org/issue20177

  • Issue: Derby #8: Convert 28 sites to Argument Clinic across 2 files #64376

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
hauntsaninja added 4 commits May 18, 2020 23:02
hauntsaninja
datetime.date.fromordinal
ee232ca
hauntsaninja
datetime.date.fromisoformat
78e71d0
hauntsaninja
datetime.date.fromisocalendar
d0eac8d
Note that this will now throw OverflowError instead of ValueError when
using the C version of datetime. There is precedent for this, e.g.,
datetime.date.fromordinal will throw an OverflowError with the C module
but ValueError with the Python.
hauntsaninja
datetime.today
5d9b7de
@hauntsaninja
hauntsaninja requested review from abalkin and pganssle as code owners May 19, 2020 06:28
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label May 19, 2020
@bedevere-bot bedevere-bot added the awaiting review label May 19, 2020
@hauntsaninja

hauntsaninja commented May 19, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Re: datetime.date.fromisocalendar
Note that this now can throw OverflowError instead of ValueError when
using the C version of datetime. There is precedent for this, e.g.,
datetime.date.fromordinal will throw an OverflowError with the C module
but ValueError with the Python.
Also, prior to this PR, the C version fromisocalendar would throw a ValueError while the Python version throws TypeError for issues with e.g, missing arguments.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hauntsaninja

hauntsaninja commented May 19, 2020

Copy link
Copy Markdown
Contributor Author

Two small notes:

  1. Let me know if this diff size is too small and piece-meal-y!
  2. I like the docstrings in Lib/datetime.py better, but unless otherwise told, I'll save that for another issue.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

blurb-it Bot and others added 3 commits May 19, 2020 06:32
@blurb-it
📜🤖 Added by blurb_it.
0497383
hauntsaninja
Merge remote-tracking branch 'upstream/master' into datetime
13ad7c7
hauntsaninja
re-run argument clinic
c1a2b1e
@taleinat

taleinat commented Oct 3, 2020

Copy link
Copy Markdown
Contributor
  1. I like the docstrings in Lib/datetime.py better, but unless otherwise told, I'll save that for another issue.

Indeed, it's good to keep these Argument Clinic conversions as straightforward as possible.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@taleinat

taleinat commented Oct 3, 2020

Copy link
Copy Markdown
Contributor

Closing and re-opening to restart the hanged Travis-CI check.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@taleinat taleinat closed this Oct 3, 2020
@taleinat taleinat reopened this Oct 3, 2020
@hauntsaninja

hauntsaninja commented Oct 5, 2020

Copy link
Copy Markdown
Contributor Author

Thanks, looks like everything's green :-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@taleinat taleinat added the skip news label Jan 20, 2022
taleinat
taleinat suggested changes Jan 21, 2022
View reviewed changes

@taleinat taleinat left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for this!

Needs a few tweaks but overall looks good.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/datetimetester.py
Comment on lines -1912 to -1914
(2<<32, 1, 1),
(2019, 2<<32, 1),
(2019, 1, 2<<32),

@taleinat taleinat Jan 20, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Why are these removed?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hauntsaninja hauntsaninja Jan 21, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I mentioned this in a PR comment:

Re: datetime.date.fromisocalendar
Note that this now can throw OverflowError instead of ValueError when
using the C version of datetime. There is precedent for this, e.g.,
datetime.date.fromordinal will throw an OverflowError with the C module
but ValueError with the Python.
Also, prior to this PR, the C version fromisocalendar would throw a ValueError while the Python version throws TypeError for issues with e.g, missing arguments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@taleinat taleinat Jan 21, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Ah, thanks, I didn't make the connection! I'll take another look at that.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Misc/NEWS.d/next/Library/2020-05-19-06-32-11.bpo-20177.BwGrIX.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_datetimemodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_datetimemodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added awaiting changes and removed awaiting review labels Jan 21, 2022
@bedevere-bot

bedevere-bot commented Jan 21, 2022

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hauntsaninja @taleinat
Update Modules/_datetimemodule.c
e6f7572
Co-authored-by: Tal Einat <[email protected]>
taleinat
taleinat reviewed Jan 21, 2022
View reviewed changes
Comment thread Modules/_datetimemodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

hauntsaninja added 3 commits January 21, 2022 01:13
hauntsaninja
Remove NEWS entry
11f83fd
hauntsaninja
Fix datetime.date.today docstring
188130b
hauntsaninja
Re-run clinic
0528066
hauntsaninja
hauntsaninja commented Jan 21, 2022
View reviewed changes

@hauntsaninja hauntsaninja left a comment

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for the review! :-)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
hauntsaninja
Use dtstr instead of date_string
d6c8759
@taleinat

taleinat commented Jan 21, 2022

Copy link
Copy Markdown
Contributor
  1. Let me know if this diff size is too small and piece-meal-y!

In my opinion this is fine, huge PRs can be hard to work with.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

taleinat
taleinat reviewed Jan 21, 2022
View reviewed changes
Comment thread Modules/_datetimemodule.c
Comment on lines -3020 to -3024
if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
PyErr_Format(PyExc_ValueError,
"ISO calendar component out of range");
year: int
week: int
day: int

}

@taleinat taleinat Jan 21, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Now I see that before this PR we have code in fromisocalendar() to raise ValueError rather than OverflowError. Raising a ValueError seems like better behavior to me. Also, changing this would be considered backwards-incompatible, would require NEWS and What's New entries, and couldn't be backported.

I think we should find a way to retain this behavior, even if that means not using Argument Clinic for this method right now.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@taleinat

taleinat commented Jan 21, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

To respond to all points re. types of exceptions raised:

Note that this now can throw OverflowError instead of ValueError when using the C version of datetime.

As I stated above, I suggest keeping the behavior of raising ValueError rather than OverflowError.

There is precedent for this, e.g., datetime.date.fromordinal will throw an OverflowError with the C module but ValueError with the Python.

Changing this to raise ValueError instead of OverflowError would be an improvement IMO.

Also, prior to this PR, the C version fromisocalendar would throw a ValueError while the Python version throws TypeError for issues with e.g, missing arguments.

These inconsistencies are unfortunate, but relatively minor. If this PR fixes that, adding a test for it would be great!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka serhiy-storchaka added the topic-argument-clinic label Apr 30, 2022
@ezio-melotti ezio-melotti removed the CLA signed label Jul 13, 2022
@larryhastings larryhastings mentioned this pull request Apr 10, 2022
Derby #8: Convert 28 sites to Argument Clinic across 2 files #64376
Closed
@arhadthedev arhadthedev changed the title bpo-20177: Use Argument Clinic for datetime.date classmethods gh-64376: Use Argument Clinic for datetime.date classmethods Apr 19, 2023
@arhadthedev

arhadthedev commented Apr 19, 2023

Copy link
Copy Markdown
Member

@hauntsaninja could you fix merge conflicts, please?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hauntsaninja hauntsaninja closed this Mar 6, 2024
@hauntsaninja
hauntsaninja deleted the datetime branch March 6, 2024 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@abalkin abalkin Awaiting requested review from abalkin
@pganssle pganssle Awaiting requested review from pganssle pganssle is a code owner
1 more reviewer
@taleinat taleinat taleinat requested changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting changes skip news topic-argument-clinic

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@hauntsaninja @taleinat @bedevere-bot @arhadthedev @serhiy-storchaka @the-knights-who-say-ni @ezio-melotti
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.