[Python-bugs-list] [ python-Bugs-762985 ] str.split seems to eat exception

SourceForge.net noreply@sourceforge.net
Mon, 30 Jun 2003 02:36:00 -0700


Bugs item #762985, was opened at 2003-06-30 05:18
Message generated for change (Comment added) made by ghaering
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=762985&group_id=5470

Category: Python Interpreter Core
Group: None
>Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: Gerhard Häring (ghaering)
Assigned to: Gerhard Häring (ghaering)
Summary: str.split seems to eat exception

Initial Comment:
comp.lang.python posting from Bill C. Wong (Message-ID:
<7sNLa.30264$Kg7.14786@nwrdny01.gnilink.net>)

################################
def func( s ):
    s1, s2 = s.split( ' ', 1 )
    try:
        raise s1
    except "aaaa":
        print 'except "aaaa"'
    except:
        print 'except:'

s = "aaaa "
func( s )
################################
If I manually assign s1 with s1 = "aaaa", then it works
fine! What am I doing wrong here?

----

Indeed if after the line s1, s2 = s.split you insert a line

s1 = "aaaaa"

then a different except clause is executed. Confirmed
with both Python 2.2.3 and Python 2.3beta2. This smells
like a bug to me.

Assigning to me and trying to investigate further.

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

>Comment By: Gerhard Häring (ghaering)
Date: 2003-06-30 11:36

Message:
Logged In: YES 
user_id=163326

Other people confirmed on comp.lang.python that the cause of
this is indeed misuse of string exceptions. Closing.

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

Comment By: Gerhard Häring (ghaering)
Date: 2003-06-30 05:31

Message:
Logged In: YES 
user_id=163326

Ok, from http://python.org/doc/current/ref/try.html about
the except clause:

"""Note that the object identities must match, i.e. it must
be the same object, not just an object with the same value."""

Please can somebody confirm this and if so, close the bug
report?

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

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