Visitar URL original
Fix documentation for time.ctime() by Shooter23 · Pull Request #123045 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20251004111221/https://github.com/python/cpython/pull/123045
Skip to content

Conversation

Shooter23
Copy link

The previous documentation had text copied from the documentation for time.asctime() which does not apply to time.ctime().

Added square brackets around "seconds" to indicate an optional argument.

The previous documentation had text copied from the documentation for time.asctime() which does not apply to time.ctime().

Added square brackets around "seconds" to indicate an optional argument.
@ghost
Copy link

ghost commented Aug 15, 2024 •

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Aug 15, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@hugovk hugovk changed the title Fix documentation for time.ctime(). Fix documentation for time.ctime() Aug 16, 2024
@hugovk hugovk added the docs Documentation in the Doc dir label Aug 16, 2024
Comment on lines +1032 to +1033
This is equivalent to asctime(localtime(seconds)). When 'seconds' is not\n\
passed in, the current time as returned by time() is used.");
Copy link
Member

Choose a reason for hiding this comment

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

According to https://docs.python.org/3/library/time.html#time.ctime, it should be

Suggested change
This is equivalent to asctime(localtime(seconds)). When 'seconds' is not\n\
passed in, the current time as returned by time() is used.");
This is equivalent to asctime(localtime(seconds)). When 'seconds' is not\n\
specified or None, the current time as returned by time() is used.");

Copy link
Author

Choose a reason for hiding this comment

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

Good catch on the None option. I intended to correct the ctime() doc entry by matching the language found in the docs for localtime() and gmtime(), which can also take None as an argument but make no mention of it.

Copy link
Member

@vstinner vstinner Sep 18, 2024 •

Choose a reason for hiding this comment

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

The docstring should be similar to the doc https://docs.python.org/dev/library/time.html#time.ctime which says:

If secs is not provided or None, the current time as returned by time() is used.

I agree with @picnixz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

4 participants