[Python-bugs-list] [ python-Bugs-667147 ] Segmentation fault printing str subclass
SourceForge.net
noreply@sourceforge.net
Mon, 13 Jan 2003 05:51:29 -0800
Bugs item #667147, was opened at 2003-01-13 08:25
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=667147&group_id=5470
Category: Type/class unification
Group: Python 2.2
Status: Open
Resolution: None
>Priority: 7
Submitted By: James Henderson (henderj)
Assigned to: Nobody/Anonymous (nobody)
Summary: Segmentation fault printing str subclass
Initial Comment:
If I define a subclass of the built-in type str as
follows:
class Letter(str):
def __new__(cls, letter):
if letter == 'EPS':
return str.__new__(cls)
return str.__new__(cls, letter)
def __str__(self):
if not self:
return 'EPS'
return self
then the following produces a segmentation fault:
>>> w = Letter('w')
>>> print w
I realize that the last line of the class definition
should be:
return str.__str__(self)
but what I tried should still not cause a crash. I am
running Red Hat Linux 7.1 and I have got the same
behaviour on Python 2.2, Python 2.2.2 and Python 2.3a0.
James
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-01-13 08:51
Message:
Logged In: YES
user_id=33168
Ouch! This affects both 2.2.2 and 2.3.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=667147&group_id=5470