[ python-Bugs-1748292 ] str.join() intercepts UnicodeDecodeError raised by iterator

SourceForge.net noreply at sourceforge.net
Thu Jul 5 12:10:38 CEST 2007


Bugs item #1748292, was opened at 2007-07-05 12:10
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1748292&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Unicode
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Christoph Zwerschke (cito)
Assigned to: M.-A. Lemburg (lemburg)
Summary: str.join() intercepts UnicodeDecodeError raised by iterator

Initial Comment:
This is somewhat similar to #905389 which has already been fixed.

If you run the following two lines,

def gen(): raise UnicodeDecodeError
''.join(gen())

then instead of UnicodeDecodeError, you get:
TypeError: function takes exactly 5 arguments (0 given)

I found this bug in Python 2.3.5, 2.4.4 and 2.5.1 on Windows and Linux.

The bug appears exactly for UnicodeDecodeError,
UnicodeEncodeError, UnicodeTranslateError; all other exceptions work as expected. You can verify this with the following program:

import exceptions

def gen(e): raise e

for e in dir(exceptions):
    e = getattr(exceptions, e)
    if type(e) != type(Exception):
        continue
    try:
        ''.join(gen(e))
    except BaseException, f:
        e = e.__name__
        f = f.__class__.__name__
        if e != f:
            print e, f


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1748292&group_id=5470


More information about the Python-bugs-list mailing list