Python bug? Named parameters in recursive calls sometimes confuses python?

Michael Hudson mwh at python.net
Fri Nov 28 12:47:44 CET 2003


magnus at thinkware.se (Magnus Lyck?) writes:

> Something really strange is happening to me (sometimes).
> I'm using Python 2.3.2 on NT 4.0 as well as win32all-157,
> adodbapi and db_row. 
> 
> During a recursive call to a method, it seems Python messes 
> up its variable bindings once in a while. Suddenly, one of 
> several local variables gets rebound to the object it was bound 
> to one step up in the recursion. 

I don't seem to have th brain cells to really understand your code
this morning (and obviously can't run it myself), but at first blush
it seems vastly more likely that you're confused than Python.

I've never heard of a bug like this before.

> The relevant part of the code looks like this with print statements
> that show the problem. This problem only seems to occur for certain
> input to my program.
> 
> Note that I print the same variables and object IDs three times, and
> suddenly, a variable has changed its binding (without any reassignment)
> to the value it had one level up in the recursion.
> 
[snip]
> The output looks like this:
> 
> 1. Column G06_PERS_INTRID (9282024) Table TGANST (9282768)
> 2. Column G06_PERS_INTRID (9282024) Table TGANST (9282768)
> 3. Column G06_PERS_INTRID (9282024) Table TGANST (9282768)
> 1. Column G60_ANSTID (9283512) Table TGANSTOV (10002536)
> 2. Column G60_ANSTID (9283512) Table TGANSTOV (10002536)
> 1. Column G08_ANSTID (10003232) Table TGANSTU (10002920)
> 2. Column G08_ANSTID (10003232) Table TGANSTU (10002920)
> 3. Column G08_ANSTID (10003232) Table TGANSTU (10002920)
> 1. Column G15_ANSTID (10002704) Table TGBELOPP (10003184)
> 2. Column G15_ANSTID (10002704) Table TGBELOPP (10003184)
> 1. Column G45_ANSTID (10002752) Table TGLED (9282672)
> 2. Column G45_ANSTID (10002752) Table TGLED (9282672)
> 1. Column G46_ANSTID (10002728) Table TGLON (10002512)
> 2. Column G46_ANSTID (10002728) Table TGLON (10002512)
> 3. Column G46_ANSTID (10002728) Table TGANST (9282768)  <= N.B. 
>                                                   Table magically morphed.

Isn't it possible that the code has just returned twice?

Unless you can produce an example that can be run somewhere other than
your setup, it's going to be pretty hard for someone else to debug
this!

Cheers,
mwh

-- 
  SPIDER:  'Scuse me. [scuttles off]
  ZAPHOD:  One huge spider.
    FORD:  Polite though.
                   -- The Hitch-Hikers Guide to the Galaxy, Episode 11




More information about the Python-list mailing list