[Python-bugs-list] [ python-Bugs-457431 ] '-' character breaks exception handling

noreply@sourceforge.net noreply@sourceforge.net
Fri, 31 Aug 2001 15:10:26 -0700


Bugs item #457431, was opened at 2001-08-31 15:04
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=457431&group_id=5470

Category: None
>Group: Not a Bug
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: '-' character breaks exception handling

Initial Comment:
Catching a string based exception containing a '-' 
character that was raised within a function call 
cannot be explicitly caught. Example :

>>> def test() :
... 	raise 'Lock-Removed'
... 
>>> try :
... 	test()
... except 'Lock-Removed' :
... 	print 'Caught it!'
... 
Traceback (most recent call last):
  File "<interactive input>", line 2, in ?
  File "<interactive input>", line 2, in test
Lock-Removed
>>> try :
... 	raise 'Lock-Removed'
... except 'Lock-Removed' :
... 	print 'Caught it!'
... 
Caught it!



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

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-08-31 15:10

Message:
Logged In: YES 
user_id=6380

Not a bug. Check the docs: string exceptions must be caught
by name, not by value. That it usually works is an accident
of implementation, and cannot be trusted across modules.

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

Comment By: Nobody/Anonymous (nobody)
Date: 2001-08-31 15:07

Message:
Logged In: NO 

Found on version 1.5.2 and 2.1.1 on Windows NT 4.0 
w/Service Pack 6a.

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

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