diff options
author | slateny <46876382+slateny@users.noreply.github.com> | 2022-03-11 19:05:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-11 19:05:51 (GMT) |
commit | c83fc9c02c9846ec3a2d0123999c98e02f00b3f5 (patch) | |
tree | 8e15cfc44f9e8848b3e123bc0e20026ffcaa8ebb /Doc | |
parent | 6f3b9e2243d8c5b6cf1be988eb5d2bd3da65a422 (diff) | |
download | cpython-c83fc9c02c9846ec3a2d0123999c98e02f00b3f5.zip cpython-c83fc9c02c9846ec3a2d0123999c98e02f00b3f5.tar.gz cpython-c83fc9c02c9846ec3a2d0123999c98e02f00b3f5.tar.bz2 |
bpo-31327: Update time documentation to reflect possible errors (GH-31460)
As per the comments, this mirrors the [datetime documentation](https://docs.python.org/3/library/datetime.html#datetime.datetime.fromtimestamp).
```
>>> import time
>>> time.localtime(999999999999999999999)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: timestamp out of range for platform time_t
>>> time.localtime(-3600)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument
```
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/time.rst | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Doc/library/time.rst b/Doc/library/time.rst index d524f4f..be17fa6 100644 --- a/Doc/library/time.rst +++ b/Doc/library/time.rst @@ -257,6 +257,12 @@ Functions :const:`None`, the current time as returned by :func:`.time` is used. The dst flag is set to ``1`` when DST applies to the given time. + :func:`localtime` may raise :exc:`OverflowError`, if the timestamp is + outside the range of values supported by the platform C :c:func:`localtime` + or :c:func:`gmtime` functions, and :exc:`OSError` on :c:func:`localtime` or + :c:func:`gmtime` failure. It's common for this to be restricted to years + between 1970 and 2038. + .. function:: mktime(t) |