[issue34955] passing a dict to bytes() gives unhelpful error message

2018-10-10 Thread Raymond Hettinger
Change by Raymond Hettinger : -- stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing

[issue34955] passing a dict to bytes() gives unhelpful error message

2018-10-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I'm not sure the error message can be improved, so I suggest closing this > issue. I concur. -- assignee: -> rhettinger nosy: +rhettinger resolution: -> not a bug ___ Python tracker

[issue34955] passing a dict to bytes() gives unhelpful error message

2018-10-10 Thread Eric V. Smith
Eric V. Smith added the comment: You can in fact pass a dict to bytes(), as long as the keys are ints in the correct range: >>> bytes({0:10, 1:20}) b'\x00\x01' I'm not claiming it's very useful, but it does conform to the docs. I'm not sure the error message can be improved, so I suggest

[issue34955] passing a dict to bytes() gives unhelpful error message

2018-10-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: bytes() accepts: 1. An integer. 2. An object supporting the buffer protocol. 3. An iterable of integers in the range 0 to 255. Dict is an iterable. But iterating it produces string object which cannot be interpreted as an integer. -- nosy:

[issue34955] passing a dict to bytes() gives unhelpful error message

2018-10-10 Thread Marnanel Thurman
New submission from Marnanel Thurman : bytes() doesn't accept a dict as parameter. If you attempt to pass one, you receive a TypeError with the baffling message "'str' object cannot be interpreted as an integer". >> bytes({'a':1}) Traceback (most recent call last): File "", line 1, in