473,734 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange error

I have encountered a very strange error and I'm hoping that some Python
hackers here could give me insight on this.

searchview.py file contains two functions:
def mysearch(indexn ame, request, c, page = 0, searchdburl = INDEX_URL,
query_add = {}, queries = [], form = True, limit = DEFAULT_LIMIT, tags
= {}, order = ''):
and
def search(findquer y, 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('pubco mm', request, vars, page = page, query_add =
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('pubco mm', request, vars, page = page, query_add =
query_add, tags = {})
the error stopped occurring, so it seems that what I'm suspecting is
right.

The searchview.py 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?

Thanks,
Wojtek

May 18 '06 #1
6 1230
WS******@gmail. com wrote:
I have encountered a very strange error and I'm hoping that some Python
hackers here could give me insight on this.

searchview.py file contains two functions:
def mysearch(indexn ame, request, c, page = 0, searchdburl = INDEX_URL,
query_add = {}, queries = [], form = True, limit = DEFAULT_LIMIT, tags
= {}, order = ''):
and
def search(findquer y, path = None, page=0, tags = {}, order='', limit =
DEFAULT_LIMIT, queries=[], searchdburl = INDEX_URL):


default values are evaluated once, when the function object is created.
this is explained in the tutorial, in the language reference, and in
the FAQ:

http://pyfaq.infogami.com/why-are-de...etween-objects

</F>

May 18 '06 #2
Evaluation of default values seems to have nothing to do with the case
I described.
The default values are both tags = {}, and still inside mysearch() I
sometimes get some value from previous call inside tags, when the tags
keyword argument is not specified.

May 18 '06 #3
WS******@gmail. com wrote:
The default values are both tags = {}, and still inside mysearch() I
sometimes get some value from previous call inside tags, when the tags
keyword argument is not specified.


which is exactly what happens if you *update* the default argument. did
you even bother to read the FAQ entry?

</F>

May 18 '06 #4
WS******@gmail. com wrote:
Evaluation of default values seems to have nothing to do with the case
I described.
It does. Please *read* the faq:
http://pyfaq.infogami.com/why-are-de...etween-objects
The default values are both tags = {}, and still inside mysearch() I
sometimes get some value from previous call inside tags, when the tags
keyword argument is not specified.


def wtf(foo, args=[]):
args.append(foo )
print args

wtf('???')
wtf('???')
wtf('???')

You didn't post the actual code for mysearch(), but chances are your
code is modifying it !-)

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom. gro'.split('@')])"
May 18 '06 #5
>> This type of bug commonly bites neophyte programmers.

That IS weird. I'm new. I read it, I see how it works, but how come in
between calls of the function, you can't access the values being
stored? Or I guess you can, but I don't see the way.

How come you can't do something like :
wtf.args


It doesn't give you the list with the values it's storing between
function calls.

May 18 '06 #6
Sorry,

Never mind.

wtf.func_defaul ts

Thanks for the examples.

Rick

May 18 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8925
by: Olaf | last post by:
I have a frameset page witch contains the myFuc() function. The function is accessed from a page in one of the frames in the frameset. An example is shown below. <input onclick="javaScript:alert('document.forms(0)='+document.forms(0)); parent.myFunc(document.forms(0));" type="button" value="Open" name="Button" ID="Button"> The strange part is that the debug alert says that the document.forms(0) is an object så all seem to be well. But...
25
3730
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's machines. The code opens MS Word through Automation and then opens a particular Word doc. It's still working fine on most machines; but on one or two of them, the user is getting an Automation Error. The code used is as follows: Dim objWord As...
0
328
by: Kris Vanherck | last post by:
yesterday i started getting this strange error when i try to run my asp.net project: Compiler Error Message: CS0006: Metadata file 'c:\winnt\microsoft.net\framework\v1.1.4322\temporary asp.net files\spsweb\0e3514bf\cb1844e7\assembly\dl2\3b163f 16\00452d31_84e5c301\infragistics.webui.ultrawebgrid.v3.dll' could not be found
6
1699
by: Gary | last post by:
I have an application that has been working just fine for a couple of years. It queries a SQL database and returns some formatted data back to the client. I have a new client, who has a larger database than any of our previous customers. For example, the query to build the datatable now takes about 2 minutes instead of one minute or less. This is a third party database we are integrating with. He is getting very strange results. For...
5
1735
by: Nathan Sokalski | last post by:
When I view my index.aspx page any time after the first time, I recieve the following error: System.Web.TraceContext.AddNewControl(String id, String parentId, String type, Int32 viewStateSize) +313 System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +201 System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +263
0
3572
by: ivb | last post by:
Hi all, I am using DB2 8.1.11.1 on NT with ASP.NET 1.1 When application make connection to database (via ADO.NET), it set "Connection timeout" parameter to 30 seconds. After, when my webpage requests database, and query execution time exceeds 30 seconds, the following error reported: ===
11
2594
by: Martin Joergensen | last post by:
Hi, I've encountered a really, *really*, REALLY strange error :-) I have a for-loop and after 8 runs I get strange results...... I mean: A really strange result.... I'm calculating temperatures. T = 20 degrees at all times.... The 2D T-array looks like this:
1
1556
by: JoReiners | last post by:
Hello, I have a really strange problem. I'm unable to figure it out on my own. I parse very simple xml documents, without any check for their form. These files look very similar and are encoded in UTF-8. Now minidom is always able to parse these files with minidom.parse("file") . Now when fetching I use this expression: xmldoc.getElementsByTagName('DocNumb').firstChild.data.encode('latin1')
11
2488
by: Mike C# | last post by:
Hi all, I keep getting a strange error and can't pin it down. The message is: This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. However I'm not purposely requesting that the Runtime terminate in an "unusual way." The line that is causing me headaches is:
3
1835
by: Shelly | last post by:
I am encountering two strange problems. First one: I get a "server misconfiguration error", but only sometimes. It occurs on the first screen that accesses the database on a submit. This error is intermittent -- sometimes it happens and sometimes not from the same screen with the same data. Here is the error:
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.