[Python-bugs-list] [ python-Bugs-571885 ] Segmentation fault in Python 2.3
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 20 Jun 2002 15:50:13 -0700
Bugs item #571885, was opened at 2002-06-21 00:46
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=571885&group_id=5470
Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Christophe Delord (cdelord)
Assigned to: Nobody/Anonymous (nobody)
Summary: Segmentation fault in Python 2.3
Initial Comment:
It seems there's a bug in python 2.3
The following script works with python 2.2, not with 2.3
def flatten(L):
for i in L:
if type(i) == list:
for j in flatten(i):
yield j
else:
yield i
def mklist(n):
if n:
return [ str(n), mklist(n-1), str(n) ]
else:
return []
L = mklist(6)
print "".join(flatten(L))
flatten seems to work but join makes a segmentation fault.
It works fine with print "".join(list(flatten(L)))
or when L = mklist(4)
I'm using Python 2.3 with Linux (Redhat)
Best regards,
Christophe Delord.
----------------------------------------------------------------------
>Comment By: Christophe Delord (cdelord)
Date: 2002-06-21 00:50
Message:
Logged In: YES
user_id=566423
Of course, with a correct indentation, it is:
def flatten(L):
for i in L:
if type(i) == list:
for j in flatten(i):
yield j
else:
yield i
def mklist(n):
if n:
return [ str(n), mklist(n-1), str(n) ]
else:
return []
L = mklist(6)
print "".join(flatten(L))
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=571885&group_id=5470