[issue20507] TypeError from str.join has no message

2014-02-15 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti

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



[issue20507] TypeError from str.join has no message

2014-02-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b9947b68ab61 by Benjamin Peterson in branch '3.3':
give non-iterable TypeError a message (closes #20507)
http://hg.python.org/cpython/rev/b9947b68ab61

New changeset f8e1fdf79823 by Benjamin Peterson in branch '2.7':
give non-iterable TypeError a message (closes #20507)
http://hg.python.org/cpython/rev/f8e1fdf79823

New changeset b077ee45f14f by Benjamin Peterson in branch 'default':
merge 3.3 (#20507)
http://hg.python.org/cpython/rev/b077ee45f14f

--
nosy: +python-dev
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue20507] TypeError from str.join has no message

2014-02-15 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There are similar issues in Objects/dictobject.c:1893, 
Modules/_elementtree.c:1045 and Modules/_elementtree.c:1662.

--
nosy: +serhiy.storchaka

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



[issue20507] TypeError from str.join has no message

2014-02-04 Thread Gareth Rees

New submission from Gareth Rees:

If you pass an object of the wrong type to str.join, Python raises a
TypeError with no error message:

Python 3.4.0b3 (default, Jan 27 2014, 02:26:41) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type help, copyright, credits or license for more information.
 ''.join(1)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError

It is unnecessarily hard to understand from this error what the
problem actually was. Which object had the wrong type? What type
should it have been? Normally a TypeError is associated with a message
explaining which type was wrong, and what it should have been. For
example:

 b''.join(1)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: can only join an iterable

It would be nice if the TypeError from ''.join(1) included a message
like this.

The reason for the lack of message is that PyUnicode_Join starts out
by calling PySequence_Fast(seq, ) which suppresses the error message
from PyObject_GetIter. This commit by Tim Peters is responsible:
http://hg.python.org/cpython/rev/8579859f198c. The commit message
doesn't mention the suppression of the message so I can assume that it
was an oversight.

I suggest replacing the line:

fseq = PySequence_Fast(seq, );

in PyUnicode_Join in unicodeobject.c with:

fseq = PySequence_Fast(seq, can only join an iterable);

for consistency with bytes_join in stringlib/join.h. Patch attached.

--
components: Interpreter Core
files: join.patch
keywords: patch
messages: 210200
nosy: Gareth.Rees
priority: normal
severity: normal
status: open
title: TypeError from str.join has no message
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file33900/join.patch

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



[issue20507] TypeError from str.join has no message

2014-02-04 Thread Srinivas Reddy T

Srinivas  Reddy T added the comment:

The exact behavior is present in 2.7 version too. So tagging 2.7 to 3.4

--
nosy: +thatiparthy
versions: +Python 2.7, Python 3.1, Python 3.2, Python 3.3

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



[issue20507] TypeError from str.join has no message

2014-02-04 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy: +pitrou
stage:  - patch review
versions:  -Python 3.1, Python 3.2

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



[issue20507] TypeError from str.join has no message

2014-02-04 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Looks good to me.

--

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