Issue1149372

classification
Title: exceptions problem in __str__
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: bzimmer Nosy List: bzimmer, lilachb
Priority: normal Keywords:

Created on 2005-02-22.20:52:15 by lilachb, last changed 2005-02-23.04:43:33 by bzimmer.

Messages
msg950 (view) Author: Lilach Bien (lilachb) Date: 2005-02-22.20:52:15
When defining a class that overloads the __str__ 
method and raises an exception in the overloaded 
method, for example

class C:
  def __str__(self):
    raise Exception("i am an exception")

If we call str on an object of this class the exception will 
not be raised

x=C()
str(x)

(no exception will be reported by jython)

P.S.
when using x.__str__() the exception will be raised and 
jython will display it
msg951 (view) Author: Brian Zimmer (bzimmer) Date: 2005-02-23.04:43:33
Logged In: YES 
user_id=37674

The behaviour of raising an exception is consistent with CPython.  The 
bug is in PyInstance which catches the thrown exception and then calls 
__repr__.
History
Date User Action Args
2005-02-22 20:52:15lilachbcreate