Strange error

WSobczuk at WSobczuk at
Thu May 18 16:23:27 CEST 2006

I have encountered a very strange error and I'm hoping that some Python
hackers here could give me insight on this. file contains two functions:
def mysearch(indexname, request, c, page = 0, searchdburl = INDEX_URL,
query_add = {}, queries = [], form = True, limit = DEFAULT_LIMIT, tags
= {}, order = ''):
def search(findquery, path = None, page=0, tags = {}, order='', limit =
DEFAULT_LIMIT, queries=[], searchdburl = INDEX_URL):

I import and call both from various places.  Now recently I discovered
that when I call:
    mysearch('pubcomm', request, vars, page = page, query_add =
from one place, then inside mysearch() (I test it at the start of the
function) the tags argument *has* a value leftover from apparently from
a previous call.  When investigating I have also found that it
sometimes has the value of the search() function's tags parameter from,
apparently, some previous call.
After I changed the call to this:
    mysearch('pubcomm', request, vars, page = page, query_add =
query_add, tags = {})
the error stopped occurring, so it seems that what I'm suspecting is

The file does not contain any global 'tags' variable, but
the search() function does process it's own tags argument like so:
    tags = dict([(k, listify(v)) for k, v in tags.iteritems()])

The whole thing is happening on Python 2.4.2 on Linux (I tried it on
Fedora and Gentoo).  It's under a heavy load (the whole thing happens
inside a Flup based FCGI backend), but I'm not using threads so there
is no concurrency involved - only sequential processing of requests.

I haven't isolated a test case yet, hoping that someone could give me a
hint on this.  Maybe I'm making some stupid mistake or maybe it's some
namespace bug (or 'feature').  Any ideas?


More information about the Python-list mailing list