Hello,

I'm experiencing an unusual problem with django where it's sometimes  
throwing a TypeError exception with the exception value "unsupported  
operand type(s) for *: 'Decimal' and 'Decimal'" when multiplying a  
DecimalField by a Decimal. This seems to happen for about 20% of  
requests to a view, and is more frequent when the requests are  
concurrent.

The code that's throwing the exception is the first return in this  
simple class method on a model:

def CO2e(self, *args, **kwargs):
     if(kwargs.get('qty', None) != None):
         return self.factor*self.type.equivalency*Decimal(kwargs['qty'])
     return self.factor*self.type.equivalency

where factor and equivalency are both django DecimalFields on models,  
and Decimal is the standard python Decimal class from the decimal  
package.

(According to the exception page the value of kwargs is {'qty':  
u'464.02'} in the case I'm currently debugging. It doesn't what the  
value of qty is, it's a unicode string which the Decimal class should  
be able to handle.)

The only somewhat related information I can find online is this thread:
http://groups.google.com/group/django-users/browse_thread/thread/91aa6c088f6c090/929f2fd69307cd22

but the link to the the psycopg ticket no longer works and just goes  
to a rant about how the author hates trac. I'm not convinced that it  
is that bug since the environment is already running under mod_wsgi,  
which the django-users thread suggests fixes the problem. The  
environment is using the postgres database engine, and has psycopg  
2.0.7 installed on it.

So a couple of questions:
1. Is the bug described in that thread still an issue? It's a fairly  
old thread.
2. Does anyone have any suggestions for where else to poke for  
debugging this?

- Dave

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to