[Pythonmac-SIG] memory corruption Python 2.3/Mac OS 10.3?

Bob Ippolito bob at redivi.com
Thu Aug 26 23:30:57 CEST 2004


On Aug 26, 2004, at 4:58 PM, Rayme Jernigan wrote:

> Chris, thanks. I'm not using the weakref module, so I don't think so. 
> And as it happens, I've been directing the code to execute in the 
> terminal.
>
> Bob, here's a somewhat minimized bit of code that illustrates the 
> problem. It won't make much sense, but it runs. The interesting part 
> occurs after the "While 1" loop is entered. I have a print statement 
> to flag that for you in the output, as well as before and after print 
> statements to bracket the area of apparent data corruption in 
> "list_of_lists." Thanks.
----
> 		# create a list for the list elements
> 		self.list_of_lists = [ ]		
> 		node = [0,0,0,0,0,0,0]
> 		while x < self.listsize:
> 			self.list_of_lists.append(node)
> 			x += 1

Pretty much what I expected.  This is a bug in your code, not in 
Python.  What you probably want is 
self.list_of_lists.append(list(node)) or the like.  You're appending 
*the same exact list object*.  If you change one, it changes "them 
all", because they are the same list.

-bob


More information about the Pythonmac-SIG mailing list