Skip to content

Error in example of datetime.time.fromisoformat  #112925

Description

@F-park

Documentation

>>> time.fromisoformat('04:23:01,000')
datetime.time(4, 23, 1, 384)

I consider the correct example should be below.

>>> time.fromisoformat('04:23:01,000384') 
datetime.time(4, 23, 1, 384) 

python docs version

  • 3.11
  • 3.12
  • 3.13

Linked PRs

Activity

  1. hugovk commented on Dec 10, 2023

    @hugovk
    Member

    Thanks for the report.

    Looks like a copy/paste error from the previous example:

    >>> time.fromisoformat('04:23:01.000384')
    datetime.time(4, 23, 1, 384)
    >>> time.fromisoformat('04:23:01,000')
    datetime.time(4, 23, 1, 384)

    The actual output (Python 3.11.7 and 3.12.1):

    >>> from datetime import time
    >>> time.fromisoformat('04:23:01.000384')
    datetime.time(4, 23, 1, 384)
    >>> time.fromisoformat('04:23:01,000')
    datetime.time(4, 23, 1)

    Would you like to open a PR to fix it?

    It would also be a good idea to add the doctest marker so these examples are actually tested.

    See .. doctest:: elsewhere in the file.

  2. added
    type-bugAn unexpected behavior, bug, or error
    3.11only security fixes
    3.12only security fixes
    3.13only security fixes
    on Dec 10, 2023
  3. added a commit that references this issue on Dec 23, 2023
  4. added 2 commits that reference this issue on Dec 23, 2023
  5. added 2 commits that reference this issue on Dec 23, 2023
  6. serhiy-storchaka commented on Dec 23, 2023

    @serhiy-storchaka
    Member

    Thank you for your contribution @F-park.

  7. added a commit that references this issue on Dec 26, 2023
  8. added a commit that references this issue on Jan 22, 2024
  9. added a commit that references this issue on Feb 11, 2024
  10. added a commit that references this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixes3.13only security fixesdocsDocumentation in the Doc direasytype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions