[Python-Dev] Nested scopes core dump

Michael Hudson mwh21@cam.ac.uk
19 Mar 2001 23:44:11 +0000


Jeremy Hylton <jeremy@alum.mit.edu> writes:

> >>>>> "MWH" == Michael Hudson <mwh21@cam.ac.uk> writes:
> 
>   MWH> [*] I thought that if you used the same keys when you were
>   MWH> iterating over a dict you were safe.  It seems not, at least as
>   MWH> far as I could tell with mounds of debugging printf's.
> 
> I did, too.  Anyone know what the problems is?  

The dict's resizing, it turns out.

I note that in PyDict_SetItem, the check to see if the dict needs
resizing occurs *before* it is known whether the key is already in the
dict.  But if this is the problem, how come we haven't been bitten by
this before?

Cheers,
M.

-- 
  While preceding your entrance with a grenade is a good tactic in
  Quake, it can lead to problems if attempted at work.    -- C Hacking
               -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html