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: Add negative tests for passing str to hmac.HMAC and hmac.new
Type: behavior Stage: resolved
Components: Library (Lib), Tests Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Marc.Abramowitz, pitrou, python-dev
Priority: normal Keywords: patch

Created on 2012-06-29 18:49 by Marc.Abramowitz, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_hmac.py.patch Marc.Abramowitz, 2012-06-29 18:49 review
hmac.py.patch Marc.Abramowitz, 2012-06-29 18:53 review
hmac.py.patch Marc.Abramowitz, 2012-06-30 15:24 review
test_hmac.py.patch Marc.Abramowitz, 2012-06-30 15:25 review
Messages (6)
msg164348 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-06-29 18:49
I had been thinking of improving the error message for this case slightly -- and then couldn't find a test for this case so I'm adding one in the attached patch...
msg164349 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-06-29 18:53
And here is the tiny patch to make it clear in the error message which of the 3 arguments had the wrong type -- I follow the convention followed in some TypeErrors raised in Lib/zipfile.py
msg164361 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-06-29 22:21
You don't need to call self.fail(), assertRaises() will do it for you.
msg164386 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-06-30 15:24
Updating patch
msg164387 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-06-30 15:29
New changeset b0605b34b2de by Antoine Pitrou in branch 'default':
Issue #15225: improve error message when hmac is passed a wrong key type.
http://hg.python.org/cpython/rev/b0605b34b2de
msg164390 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-06-30 15:35
Thank you Marc, your patches are now committed!
History
Date User Action Args
2022-04-11 14:57:32adminsetgithub: 59430
2012-06-30 15:35:33pitrousetstatus: open -> closed
type: enhancement -> behavior
messages: + msg164390

components: + Library (Lib)
resolution: fixed
stage: resolved
2012-06-30 15:29:20python-devsetnosy: + python-dev
messages: + msg164387
2012-06-30 15:25:55Marc.Abramowitzsetfiles: + test_hmac.py.patch
type: enhancement
2012-06-30 15:24:33Marc.Abramowitzsetfiles: + hmac.py.patch

messages: + msg164386
2012-06-29 22:21:10pitrousetnosy: + pitrou
messages: + msg164361
2012-06-29 18:53:40Marc.Abramowitzsetfiles: + hmac.py.patch

messages: + msg164349
2012-06-29 18:49:39Marc.Abramowitzcreate