New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datetime/date strftime() method and time.strftime() inconsistency #47031
Comments
datetime and date strftime() method does additional check on input
Here is a traceback for a more complete overview: Python 2.6a2+ (trunk:62762, May 6 2008, 14:37:27)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime, date
>>> import time
>>> uformat = u'%Y-%m-%D %H-%M-%S'
>>> format = '%Y-%m-%D %H-%M-%S'
>>> datetime.today().strftime(uformat)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: strftime() argument 1 must be str, not unicode
>>> datetime.today().strftime(format)
'2008-05-05/07/08 17-19-03'
>>> time.strftime(uformat)
'2008-05-05/07/08 17-19-10'
>>> time.strftime(format)
'2008-05-05/07/08 17-19-16'
>>> date.today()
datetime.date(2008, 5, 7)
>>> date.today().strftime(format)
'2008-05-05/07/08 00-00-00'
>>> date.today().strftime(uformat)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: strftime() argument 1 must be str, not unicode |
Yes, sounds like a bug. I'll fix it. But should time.strftime allow a unicode format string as input in the there's an amusing comment in Modules/datetimemodule.c: /* I sure don't want to reproduce the strftime code from the time module,
|
Fixed in trunk (2.6) r63887. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: