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.

Author ezio.melotti
Recipients ezio.melotti
Date 2009-02-12.22:50:31
SpamBayes Score 2.091845e-08
Marked as misclassified No
Message-id <1234479034.17.0.353291380083.issue5236@psf.upfronthosting.co.za>
In-reply-to
Content
On Python3 time.strptime(string[, format]) accepts bytes as arguments
and then fails:

>>> strptime(b"2009", "%Y")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Programs\Python30\lib\_strptime.py", line 454, in _strptime_time
    return _strptime(data_string, format)[0]
  File "C:\Programs\Python30\lib\_strptime.py", line 322, in _strptime
    found = format_regex.match(data_string)
TypeError: can't use a string pattern on a bytes-like object

time.strftime already rejects bytes arguments:
>>> strftime(b'%Y')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: strftime() argument 1 must be str, not bytes

time.strptime should do the same and reject bytes for both the arguments
(string and format).

(With Py2.x both str and unicode args work.)
History
Date User Action Args
2009-02-12 22:50:34ezio.melottisetrecipients: + ezio.melotti
2009-02-12 22:50:34ezio.melottisetmessageid: <1234479034.17.0.353291380083.issue5236@psf.upfronthosting.co.za>
2009-02-12 22:50:32ezio.melottilinkissue5236 messages
2009-02-12 22:50:31ezio.melotticreate