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
time.strptime should reject bytes arguments on Py3 #49486
Comments
On Python3 time.strptime(string[, format]) accepts bytes as arguments >>> 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 (With Py2.x both str and unicode args work.) |
I believe this shouldn't be tagged as part of the Lib component... Also, I am happy to work on this issue, developing tests and a patch. |
My mistake, it is part of the Lib component ... I failed to see the In any case, I'm happy to work on this. |
If you want to work on it, Tennesse, then go for it! |
Python implementation to raise this exception if a bytes argument is Test case added to test_time |
Please remove the whitespace changes in the patch |
Thanks for the comments all and sorry for the delay -- life! |
I am going to do a review at http://codereview.appspot.com/28147 ; not |
Applied in r70755 for py3k. I am not backporting as I changed it to |
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: