Skip to content
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

bpo-31327: Update time documentation to reflect possible errors #31460

Merged
merged 3 commits into from Mar 11, 2022

Conversation

Copy link
Contributor

@slateny slateny commented Feb 21, 2022

As per the comments, this mirrors the datetime documentation.

>>> 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 

https://bugs.python.org/issue31327

Automerge-Triggered-By: GH:pganssle

Copy link
Member

@zooba zooba left a comment

Approved with the CI fixes

Doc/library/time.rst Outdated Show resolved Hide resolved
Doc/library/time.rst Outdated Show resolved Hide resolved
@slateny
Copy link
Contributor Author

@slateny slateny commented Feb 27, 2022

@zooba Fixed trailing spaces, could you take another look?

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 in
Copy link
Contributor

@akulakov akulakov Feb 27, 2022

Choose a reason for hiding this comment

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

Suggested change
It's common for this to be restricted to years in
It's common for this to be restricted to years in the range of

Copy link
Contributor Author

@slateny slateny Feb 28, 2022

Choose a reason for hiding this comment

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

I just copied-pasted from datetime, but if we're to change the wording then there's some shorter options as well:

"... to be restricted to the years 1970 through 2038."

or

"... years in the range 1970 to 2038."

Though difficult for me to say which one of the three is the best here.

@slateny slateny changed the title bpo-31327: Updated time documentation to reflect possible errors bpo-31327: Update time documentation to reflect possible errors Mar 4, 2022
Copy link
Member

@pganssle pganssle left a comment

Looks good, thanks @slateny!

@pganssle pganssle added the 🤖 automerge label Mar 11, 2022
@miss-islington miss-islington merged commit c83fc9c into python:main Mar 11, 2022
12 checks passed
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Mar 11, 2022

Thanks @slateny for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9, 3.10.
🐍🍒🤖

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Mar 11, 2022

GH-31825 is a backport of this pull request to the 3.10 branch.

miss-islington added a commit to miss-islington/cpython that referenced this issue Mar 11, 2022
…onGH-31460)

As per the comments, this mirrors the [datetime documentation](https://docs.python.org/3/library/datetime.htmlGH-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
```
(cherry picked from commit c83fc9c)

Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Mar 11, 2022

GH-31826 is a backport of this pull request to the 3.9 branch.

miss-islington added a commit to miss-islington/cpython that referenced this issue Mar 11, 2022
…onGH-31460)

As per the comments, this mirrors the [datetime documentation](https://docs.python.org/3/library/datetime.htmlGH-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
```
(cherry picked from commit c83fc9c)

Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
miss-islington added a commit that referenced this issue Mar 11, 2022
…1460)

As per the comments, this mirrors the [datetime documentation](https://docs.python.org/3/library/datetime.htmlGH-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
```
(cherry picked from commit c83fc9c)

Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
miss-islington added a commit that referenced this issue Mar 11, 2022
…1460)

As per the comments, this mirrors the [datetime documentation](https://docs.python.org/3/library/datetime.htmlGH-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
```
(cherry picked from commit c83fc9c)

Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
@slateny slateny deleted the s/time branch Mar 12, 2022
@iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Mar 13, 2022

@pganssle Did you intend to add the backport to 3.8 label?

@pganssle
Copy link
Member

@pganssle pganssle commented Mar 14, 2022

@iritkatriel It's a doc fix, not sure how far we usually backport those since they are not critical bit also not likely to cause any problems, so I went with backporting as far as it would go. If you think there's no reason to go that far back I don't feel strongly about it at all.

@iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Mar 14, 2022

@iritkatriel It's a doc fix, not sure how far we usually backport those since they are not critical bit also not likely to cause any problems, so I went with backporting as far as it would go. If you think there's no reason to go that far back I don't feel strongly about it at all.

I don’t have a view on this (and I didn’t know we backport doc fixes to 3.8). In this particular case it seems like the 3.8 backport did not happen - maybe the bots don’t do them based on labels?

ambv pushed a commit that referenced this issue Mar 16, 2022
…1460) (GH-31827)

As per the comments, this mirrors the [datetime documentation](https://docs.python.org/3/library/datetime.htmlGH-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
```
(cherry picked from commit c83fc9c)

Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
asvetlov added a commit to YvesDup/cpython that referenced this issue Mar 25, 2022
…onGH-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 
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA signed docs needs backport to 3.8 🤖 automerge skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants