-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
gh-76075: Remove mentions of C's mktime in datetime.timestamp() #92796
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1364,14 +1364,8 @@ Instance methods: | |
|
|
||
| Return POSIX timestamp corresponding to the :class:`.datetime` | ||
| instance. The return value is a :class:`float` similar to that | ||
| returned by :func:`time.time`. | ||
|
|
||
| Naive :class:`.datetime` instances are assumed to represent local | ||
| time and this method relies on the platform C :c:func:`mktime` | ||
| function to perform the conversion. Since :class:`.datetime` | ||
| supports wider range of values than :c:func:`mktime` on many | ||
| platforms, this method may raise :exc:`OverflowError` for times far | ||
| in the past or far in the future. | ||
| returned by :func:`time.time`. Raises :exc:`OSError` for times far in the | ||
| past or far in the future. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is maybe too terse. All the core elements of the documentation are still true, IIRC,the only difference is that I think we want to replace the specific "calls mktime" with a more generic, "relies on system APIs, which may have a different valid range than Also, is it not still possible to get an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, it does make sense to give some explanation why As for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On WSL Ubuntu, Python 3.10: >>> datetime.datetime(9_999, 12, 31).timestamp()
253402214400.0
>>> datetime.datetime(1, 1, 1).timestamp()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: year 0 is out of range
>>> datetime.datetime(1, 1, 2).timestamp()
-62135510325.0The A There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think that's this.
Possibly this only occurs on 32-bit platforms? There's a comment here that indicates that might be the issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually on second glance, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This commit (need to expand the diff of |
||
|
|
||
| For aware :class:`.datetime` instances, the return value is computed | ||
| as:: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.