-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-30302 Make timedelta.__repr__ more informative. #1493
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
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
1cb7b91
Make timedelta.__repr__ more informative.
musically-ut 84241de
Make C impl of timedelta.__repr__ more informative
musically-ut 2e61096
Fix tests.
musically-ut e6970c8
Add more tests.
musically-ut f5dd914
Do not show args which are 0.
musically-ut e1c33ab
Fix bug to run tests on both C and Python code.
musically-ut 345557b
Use append/join instead of concatenating strings.
musically-ut e79d223
Remove unsed tests.
musically-ut 312b81b
Use append/join in C implementation.
musically-ut 1ca30ee
Remove documentation of `repr`.
musically-ut f643b40
Do stricter reference management, remove refleaks.
musically-ut 194bfde
Inline simple expression.
musically-ut a40e0c1
Add checks for C-API failures.
musically-ut 69213f7
Make DECREFs more concise.
musically-ut c939f81
Add more tests.
musically-ut 9e7bd21
Update documentation for repr.
musically-ut 863485c
timedelta(seconds=0) -> timedelta(0)
musically-ut 5d5a92e
Make the code more DRY.
musically-ut 16516a4
Remove empty lines and use idiomatic methods.
musically-ut 2fa3e20
Revert white-space regression in documentation.
musically-ut 10817a8
Update ACKS and NEWS.d.
musically-ut e26ab32
Use PyUnicode_* instead of PyList_*.
musically-ut 83ea587
Make the invariant in case of repr explicit.
musically-ut 23eb9ec
Place name at the correct alphabetical position.
musically-ut ae93f8e
Update documentation.
musically-ut 3d327f4
char * -> const char*
musically-ut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Library/2017-06-30-23-05-47.bpo-30302.itwK_k.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Use keywords in the ``repr`` of ``datetime.timedelta``. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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 don't think that it's worth it to add so many test cases. Just keep 3 examples, 1 negative value, the timedelta(0), and you're done no?
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.
Some of the tests were added to differentiate the current implementation from the old one: i.e. no leading
days=0
orseconds=0
and to highlight the current handling of negative values (i.e. the normalization of the attributes, as described in the docs). I'll remove the ones which don't test anything unique not covered elsewhere.