Skip to content

bpo-36782: Created C API wrappers and added missing tests for functions in the PyDateTimeAPI.#13088

Merged
vstinner merged 47 commits intopython:masterfrom
edison12a:bpo-36782
May 17, 2019
Merged

bpo-36782: Created C API wrappers and added missing tests for functions in the PyDateTimeAPI.#13088
vstinner merged 47 commits intopython:masterfrom
edison12a:bpo-36782

Conversation

@edison12a
Copy link
Copy Markdown
Contributor

@edison12a edison12a commented May 4, 2019

Copy link
Copy Markdown
Member

@pganssle pganssle left a comment

Choose a reason for hiding this comment

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

Thank you for this contribution! I'm very excited to have these added to the datetime test suite!

The Python portion of the code looks good to me, but I have some formatting notes on the C functions.

{"test_incref_doesnt_leak", test_incref_doesnt_leak, METH_NOARGS},
{"test_xdecref_doesnt_leak",test_xdecref_doesnt_leak, METH_NOARGS},
{"test_decref_doesnt_leak", test_decref_doesnt_leak, METH_NOARGS},
{"raise_exception", raise_exception, METH_VARARGS},
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.

Are these formatting changes deliberate? I know some editors will be somewhat aggressive with making formatting changes.

I think it would be best to leave the original formatting intact, if only to make the diff easier to review.

@edison12a
Copy link
Copy Markdown
Contributor Author

I have made the changes that you requested. @pganssle Please review.

Copy link
Copy Markdown
Member

@pganssle pganssle left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks @SimiCode!

Copy link
Copy Markdown
Member

@matrixise matrixise left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution, please read my comments with @pganssle and add you to the Misc/ACKS file.

with self.subTest(macro=macro):
d = _testcapi.get_date_fromdate(year, month, day, macro)

self.assertEqual(d, date(1993, 8, 26))
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.

and because I don't like the duplicated code, you could use that.

self.assertEqual(d, date(year, month, day))

I think you could also compute one time the expected date. and because I like to be explicit...

def test_date_from_date(self):
    expected_date = date(1993, 8, 26)
    for macro in (0, 1):
        with self.subTest(macro=macro):
            new_date = _testcapi.get_date_fromdate(expected_date.year, expected_date.month, expected_date.day, macro)
            self.assertEqual(new_date, expected_date)

@pganssle ?

@bedevere-bot
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.

@edison12a
Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link
Copy Markdown

Thanks for making the requested changes!

@matrixise: please review the changes made to this pull request.

@@ -0,0 +1,2 @@
Created a test C API wrapper for PyDate_FromDate and added a test for PyDate_FromDate.
Copy link
Copy Markdown
Member

@matrixise matrixise May 6, 2019

Choose a reason for hiding this comment

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

@pganssle Could you help @SimiCode for the blurb entry? Add tests for the C-API wrapper of PyDate_FromDate ? I am not a native speaker. or Add tests for PyDate_FromDate

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.

Talked to Edison in the room, he will have an updated blurb that I have looked at. The current one is grammatically fine but could be tightened up and could use RST directives.

@bedevere-bot
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.

Copy link
Copy Markdown
Member

@pganssle pganssle left a comment

Choose a reason for hiding this comment

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

New changes look good to me.

@vstinner
Copy link
Copy Markdown
Member

@pganssle: Would you mind to review this PR again? @SimiCode updated it. Once you approve it, I'm ok to review it to maybe merge it ;-)

Copy link
Copy Markdown
Member

@pganssle pganssle left a comment

Choose a reason for hiding this comment

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

I've suggested changing all the int macro = 0 to int macro; now that macro is required, but otherwise this PR looks good and we can merge it.

edison12a and others added 6 commits May 11, 2019 16:53
change all the int macro = 0 to int macro; now that macro is required

Co-Authored-By: Paul Ganssle <pganssle@users.noreply.github.com>
change all the `int macro = 0` to `int macro`; now that macro is required

Co-Authored-By: Paul Ganssle <pganssle@users.noreply.github.com>
change all the `int macro = 0` to `int macro`; now that macro is required

Co-Authored-By: Paul Ganssle <pganssle@users.noreply.github.com>
change all the `int macro = 0` to `int macro`; now that macro is required

Co-Authored-By: Paul Ganssle <pganssle@users.noreply.github.com>
change all the `int macro = 0` to `int macro`; now that macro is required

Co-Authored-By: Paul Ganssle <pganssle@users.noreply.github.com>
change all the `int macro = 0` to `int macro`; now that macro is required

Co-Authored-By: Paul Ganssle <pganssle@users.noreply.github.com>
@edison12a
Copy link
Copy Markdown
Contributor Author

@vstinner @pganssle
I have added the suggested changes. Please review.

Copy link
Copy Markdown
Member

@matrixise matrixise left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution. 🎉

Copy link
Copy Markdown
Member

@pganssle pganssle left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks Edison!

@vstinner
Copy link
Copy Markdown
Member

Well done @SimiCode, modifying C code and tests is not trivial!

@vstinner vstinner merged commit 98ff4d5 into python:master May 17, 2019
@bedevere-bot
Copy link
Copy Markdown

@vstinner: Please replace # with GH- in the commit message next time. Thanks!

@vstinner
Copy link
Copy Markdown
Member

Crap. I modified the commit message, but the merge failed. I click on Retry, and then it lost all my changes on the commit message :-(

@vstinner
Copy link
Copy Markdown
Member

@pganssle: Do we need to backport the change to 3.7?

@pganssle
Copy link
Copy Markdown
Member

@vstinner It only adds tests, so while I don't think it would hurt to backport the change to 3.7, it's not really necessary.

@miss-islington
Copy link
Copy Markdown
Contributor

Thanks @SimiCode for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@miss-islington
Copy link
Copy Markdown
Contributor

Thanks @SimiCode for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@miss-islington
Copy link
Copy Markdown
Contributor

Sorry, @SimiCode and @vstinner, I could not cleanly backport this to 3.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 98ff4d5fb6a9d01b0176b7786db61346952e5295 3.7

@edison12a edison12a deleted the bpo-36782 branch June 6, 2020 13:04
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.

7 participants