[New-bugs-announce] [issue17339] bytes() TypeError message is misleadingly narrow

Terry J. Reedy report at bugs.python.org
Sat Mar 2 20:58:34 CET 2013


New submission from Terry J. Reedy:

If an object ob does not have a __bytes__ method or buffer interface and is not a string, integer, or iterable, bytes(ob) fails with 

TypeError: 'object' object is not iterable

This is misleadingly narror (similar to #17032). We should either list *all* the things that ob is not

'object' object is not a string, integer, or iterable and does not have a __bytes__ method or buffer interface

or simply say

'object' object cannot be converted to bytes

and let the programmer recheck what can be.

----------
components: Interpreter Core
messages: 183345
nosy: terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: bytes() TypeError message is misleadingly narrow
type: enhancement
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17339>
_______________________________________


More information about the New-bugs-announce mailing list