[issue17339] bytes() TypeError message is misleadingly narrow

2016-04-14 Thread Martin Panter

Martin Panter added the comment:

The int.from_bytes() behaviour seems to have been documented from the 
beginning, so maybe it was intended.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17339] bytes() TypeError message is misleadingly narrow

2016-04-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
versions:  -Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17339] bytes() TypeError message is misleadingly narrow

2016-04-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17339] bytes() TypeError message is misleadingly narrow

2016-04-10 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 6b16eec56854 by Serhiy Storchaka in branch 'default':
Issue #17339: Improved TypeError message in bytes constructor.
https://hg.python.org/cpython/rev/6b16eec56854

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17339] bytes() TypeError message is misleadingly narrow

2016-04-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Martin.

Interesting, int.from_bytes() accepts lists (and other iterables):

>>> int.from_bytes([1, 2, 3], "little")
197121

Is it intentional?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17339] bytes() TypeError message is misleadingly narrow

2016-04-09 Thread Martin Panter

Martin Panter added the comment:

I think this patch is okay.

I would have suggested “Cannot construct bytes from [. . .]” to avoid the 
problem with “convert”, but this message is produced in places other than the 
constructor, e.g.

>>> int.from_bytes("str", "little")
TypeError: cannot convert unicode object to bytes

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17339] bytes() TypeError message is misleadingly narrow

2016-04-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch.

--
keywords: +patch
nosy: +serhiy.storchaka
stage: needs patch -> patch review
versions: +Python 3.6 -Python 3.4
Added file: http://bugs.python.org/file42413/bytes_from_object_error_msg.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17339] bytes() TypeError message is misleadingly narrow

2013-03-04 Thread Ezio Melotti

Ezio Melotti added the comment:

 'object' object cannot be converted to bytes

This is not entirely accurate for the bytes(int) case though, since it's not 
converting the int to bytes.  OTOH if we want to keep the message short we have 
to make compromises about accuracy and completeness.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17339
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17339] bytes() TypeError message is misleadingly narrow

2013-03-02 Thread Terry J. Reedy

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 rep...@bugs.python.org
http://bugs.python.org/issue17339
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17339] bytes() TypeError message is misleadingly narrow

2013-03-02 Thread Ezio Melotti

Ezio Melotti added the comment:

See also #16518.

--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17339
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17339] bytes() TypeError message is misleadingly narrow

2013-03-02 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Do you prefer the long or short form?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17339
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17339] bytes() TypeError message is misleadingly narrow

2013-03-02 Thread Éric Araujo

Éric Araujo added the comment:

Short form for me.

--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17339
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com