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.

Author kermode
Recipients
Date 2004-02-26.21:19:49
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
For str.join(), if it is passed an iterator and that 
iterator raises a TypeError, that exception is caught 
by the join method and replaced by its own 
TypeError exception. SyntaxError and IndexError 
exceptions are uneffected.

Example:

Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC 
v.1200 32 bit (Intel)] on win32
...
IDLE 1.0.2      
>>> def gen(n):
	if not isinstance(n, int):
		raise TypeError, "gen() TypeError"
	if n<0:
		raise IndexError,  "gen() 
IndexError"
	for i in range(n):
		yield str(i)

		
>>> ''.join(gen(5))
'01234'
>>> ''.join(gen(-1))

Traceback (most recent call last):
  File "<pyshell#9>", line 1, in -toplevel-
    ''.join(gen(-1))
  File "<pyshell#7>", line 5, in gen
    raise IndexError, "gen() IndexError"
IndexError: gen() IndexError
>>> ''.join(gen(None))

Traceback (most recent call last):
  File "<pyshell#10>", line 1, in -toplevel-
    ''.join(gen(None))
TypeError: sequence expected, generator found
>>> 
History
Date User Action Args
2007-08-23 14:20:14adminlinkissue905389 messages
2007-08-23 14:20:14admincreate