[Python-bugs-list] [ python-Bugs-571885 ] Segmentation fault in Python 2.3

noreply@sourceforge.net noreply@sourceforge.net
Thu, 20 Jun 2002 15:56:40 -0700


Bugs item #571885, was opened at 2002-06-20 22: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: Closed
>Resolution: Fixed
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: Jeremy Hylton (jhylton)
Date: 2002-06-20 22:56

Message:
Logged In: YES 
user_id=31392

The latest CVS on the 2.2 maintenance branch also works
correctly.

I suspect you've hit a bug that is already fixed.  I'm
closing for now, but feel free to re-open if you can provoke
it with a current checkout from CVS.  If so, it would be
helpful if you could provide a stack trace from gdb.


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

Comment By: Jeremy Hylton (jhylton)
Date: 2002-06-20 22:52

Message:
Logged In: YES 
user_id=31392

When I run the test script, python2.3 says:
654321123456

If I add a future statement to the script and run it with
2.2, I get a core dump.


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

Comment By: Christophe Delord (cdelord)
Date: 2002-06-20 22: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