GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C) · Issue #85432 · python/cpython

datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C) #85432

New issue
Copy link
New issue
Copy link
Closed
Closed
datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C)#85432
Copy link
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.9 (EOL)end of lifeend of lifeextension-modulesC modules in the Modules dirC modules in the Modules dirstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

asottile
mannequin
opened on Jul 9, 2020
Issue body actions
BPO 41260
Nosy @srittau, @abalkin, @asottile, @pganssle, @ZackerySpytz, @AlexWaygood
PRs
  • bpo-41260: C impl of datetime.date.strftime() takes different keyword arg #21712
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2020-07-09.17:01:48.789>
    labels = ['type-bug', '3.9', '3.10', '3.11', 'extension-modules', 'library']
    title = 'datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C)'
    updated_at = <Date 2021-11-16.19:27:41.778>
    user = 'https://github.com/asottile'

    bugs.python.org fields:

    activity = <Date 2021-11-16.19:27:41.778>
    actor = 'AlexWaygood'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Extension Modules', 'Library (Lib)']
    creation = <Date 2020-07-09.17:01:48.789>
    creator = 'Anthony Sottile'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41260
    keywords = ['patch']
    message_count = 6.0
    messages = ['373407', '373421', '373424', '406418', '406421', '406424']
    nosy_count = 6.0
    nosy_names = ['srittau', 'belopolsky', 'Anthony Sottile', 'p-ganssle', 'ZackerySpytz', 'AlexWaygood']
    pr_nums = ['21712']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue41260'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Linked PRs

    • gh-85432: Harmonise parameter names between C and pure-Python implementations of datetime.time.strftime, datetime.datetime.fromtimestamp #99993

    Activity

    1. asottile commented on Jul 9, 2020

      @asottile
      asottilemannequin
      on Jul 9, 2020
      MannequinAuthor
      More actions

      C:

      cpython/Modules/_datetimemodule.c

      Line 3183 in 8b33961

      static char *keywords[] = {"format", NULL};

      pure python:

      cpython/Lib/datetime.py

      Line 927 in 8b33961

      def strftime(self, fmt):

      this makes it difficult to properly type in mypy:

      https://github.com/python/typeshed/blob/209b6bb127f61fe173a60776e23883ac450cf1c8/stdlib/2and3/datetime.pyi#L55

      and calling with .strftime(fmt=...) or .strftime(format=...) is inconsistent

      (that said, it should _probably_ be a positional-only argument)

    2. asottile
      added
      3.10 (EOL)end of lifeend of life
      extension-modulesC modules in the Modules dirC modules in the Modules dir
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      on Jul 9, 2020
    3. pganssle commented on Jul 9, 2020

      @pganssle
      pganssle
      on Jul 9, 2020
      Member
      More actions

      I think a positional-only argument would be the best option if we could do it, but it would be a backwards-incompatible change and it's probably not worth the hassle.

      If anyone is using the keyword argument, they're probably using format= rather than fmt=, since it's pretty rare for anyone to use the pure python version of datetime. PyPy uses it, but I think they tend to aim for consistency with the C API of CPython, and it seems like they already patch s/fmt/format/ themselves: https://foss.heptapod.net/pypy/pypy/-/blob/branch/default/lib_pypy/datetime.py#L781

      If anyone wants to make a PR I think we can fix this for 3.10, though unfortunately because it is an API change it can't be backported. I think in typeshed they can safely change from fmt to format even today (which would almost certainly be more accurate to end user use cases).

    4. asottile commented on Jul 9, 2020

      @asottile
      asottilemannequin
      on Jul 9, 2020
      MannequinAuthor
      More actions

      awesome, I'm going to work through this with someone in my discord as a demo / mentorship opportunity -- hope that's ok!

    5. pganssle commented on Nov 16, 2021

      @pganssle
      pganssle
      on Nov 16, 2021
      Member
      More actions

      Updating this issue to cover the problem in date, time and datetime.

    6. pganssle
      changed the title [-]datetime: strftime method takes different keyword argument: fmt (pure) or format (C)[/-] [+]datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C)[/+] on Nov 16, 2021
    7. pganssle
      changed the title [-]datetime: strftime method takes different keyword argument: fmt (pure) or format (C)[/-] [+]datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C)[/+] on Nov 16, 2021
    8. AlexWaygood
      added
      3.9 (EOL)end of lifeend of life
      3.11only security fixesonly security fixes
      on Nov 16, 2021
    9. srittau commented on Nov 16, 2021

      @srittau
      srittaumannequin
      on Nov 16, 2021
      Mannequin
      More actions

      Ref python/typeshed#6317 for a discussion about this in typeshed.

    10. AlexWaygood commented on Nov 16, 2021

      @AlexWaygood
      AlexWaygood
      on Nov 16, 2021
      Member
      More actions

      In addition to date.strftime and time.strftime, there is also a discrepancy in datetime.fromtimestamp. In the C implementation, the first parameter is called "timestamp"; in the pure-Python implementation, the first parameter is called "t".

    11. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    12. serhiy-storchaka
      added this to Date and time issues 🕰️on May 21, 2022
    13. iritkatriel
      closed this as completedon Nov 25, 2022
    14. iritkatriel
      moved this to Done in Date and time issues 🕰️on Nov 25, 2022
    15. AlexWaygood
      added 2 commits that reference this issue on Dec 4, 2022

      pythongh-85432: harmonise parameter names between C and pure-Python i…

      7b4de3b

      pythongh-85432: harmonise parameter names between C and pure-Python i…

      bcb065d
    16. hauntsaninja
      added a commit that references this issue on Dec 22, 2022

      gh-85432: Harmonise parameter names between C and pure-Python impleme…

      9cdb642
    17. iritkatriel
      added a commit that references this issue on Dec 28, 2022

      Merged main into regmachine branch (#50)

      fdc73cb
    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.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.9 (EOL)end of lifeend of lifeextension-modulesC modules in the Modules dirC modules in the Modules dirstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

      Projects

      • Date and time issues 🕰️
        Status
        Done
        Show more project fields

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.