This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: datetime.time.strftime: use the same function signature for C and Python implementations
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.11
process
Status: closed Resolution: duplicate
Dependencies: Superseder: datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C)
View: 41260
Assigned To: Nosy List: belopolsky, hyzyla, p-ganssle, xtreak
Priority: normal Keywords:

Created on 2021-11-16 10:40 by hyzyla, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg406395 - (view) Author: Yevhenii Hyzyla (hyzyla) * Date: 2021-11-16 10:40
Method datetime.time.strftime in Python and C implementation has different signature. Python implementation use `fmt` as argument and C implementation use `format` as argument. 

Python implementation:
```python
def strftime(self, fmt):
  ...
```

C implementation
```C
static PyObject *
time_strftime(PyDateTime_Time *self, PyObject *args, PyObject *kw)
{
    PyObject *result;
    PyObject *tuple;
    PyObject *format;
    static char *keywords[] = {"format", NULL};

    if (! PyArg_ParseTupleAndKeywords(args, kw, "U:strftime", keywords,
                                      &format))
        return NULL;
```

My suggestion to use the same argument name for both implementations, for example to use `format` as in C implementation.
msg406417 - (view) Author: Paul Ganssle (p-ganssle) * (Python committer) Date: 2021-11-16 16:55
I think this is mostly a duplicate of bpo-41260, which has an open PR on it. I think that got lost in the shuffle, I'm sad we didn't fix it in Python 3.10. I think we should migrate all of these signatures that differ to whichever one the C implementation is using (I believe that's 3.11).

I'm going to close that one and edit the other one to cover `time` and `date` as well. Thanks for the report Yevhenii!
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 89972
2021-11-16 16:55:25p-gansslesetstatus: open -> closed
superseder: datetime, date and time: strftime method takes different keyword argument: fmt (pure) or format (C)
messages: + msg406417

resolution: duplicate
stage: resolved
2021-11-16 12:48:15AlexWaygoodsettitle: Use the same function signature for datetime.time.strftime -> datetime.time.strftime: use the same function signature for C and Python implementations
2021-11-16 12:22:06xtreaksetnosy: + belopolsky, p-ganssle, xtreak
2021-11-16 10:41:24hyzylasettitle: Use same function signature for datetime.time.strftime -> Use the same function signature for datetime.time.strftime
2021-11-16 10:40:29hyzylacreate