Skip to content

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

Merged
hauntsaninja merged 1 commit into
python:mainfrom
AlexWaygood:fromtimestamp
Dec 22, 2022
Merged

Conversation

@AlexWaygood

Copy link
Copy Markdown
Member

#85432 was closed slightly prematurely in my view. While #21712 fixes things for datetime.date.strftime, as mentioned in #85432 (comment), the problem also exists for datetime.time.strftime, as well as datetime.datetime.fromtimestamp:

Works with the C implementation:

>>> import time, datetime
>>> datetime.time().strftime(format="%f")
'000000'
>>> datetime.datetime.fromtimestamp(timestamp=time.time())
datetime.datetime(2022, 12, 4, 16, 23, 25, 69430)
>>> exit()

Not with the pure-Python implementation:

>>> import sys
>>> sys.modules["_datetime"] = None
>>> import time, datetime
>>> datetime.time().strftime(format="%f")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: time.strftime() got an unexpected keyword argument 'format'
>>> datetime.datetime.fromtimestamp(timestamp=time.time())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: datetime.fromtimestamp() got an unexpected keyword argument 'timestamp'

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants