Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
unsupported operand type(s) for *: 'Decimal' and 'Decimal'
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Landlord Bulfleet  
View profile  
 More options Sep 19 2007, 8:41 am
From: "Landlord Bulfleet" <landlord1...@gmail.com>
Date: Wed, 19 Sep 2007 15:41:50 +0300
Local: Wed, Sep 19 2007 8:41 am
Subject: Re: unsupported operand type(s) for *: 'Decimal' and 'Decimal'

We have the following weird problem, that we are unable to deliberately
replicate no matter what we try...

It seems to appears only when our server (running python2.5.1, daily updated
django svn, mod_python 3.3.1) has been running for at least maybe 4-5
hours...
After an apache restart there is no sign of the bug for another 5-7 hours...

The weird thing is that calling the view with the exactly the same
parameters usually doesn't reproduce the error.

=== sample code ===
(class1, class2) = (sum.__class__, f_c.rate.__class__)
d_sum = sum * f_c.rate
<-  break

Local vars:
class1 <class 'decimal.Decimal'>
class2 <class 'decimal.Decimal'>
sum Decimal("0.23")
=== ===

sum is property of a model object in our database
(models.DecimalField(max_digits=7,
decimal_places=2)) & f_c.rate is a  Decimal constructed using
Decimal(string) construction (Decimal is imported with "from decimal import
Decimal")

We have some doubts that this may be a result of the django's python
2.3_decimal compatibility.

Any help is appreciated...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Dunck  
View profile  
 More options Sep 19 2007, 5:18 pm
From: "Jeremy Dunck" <jdu...@gmail.com>
Date: Wed, 19 Sep 2007 16:18:54 -0500
Local: Wed, Sep 19 2007 5:18 pm
Subject: Re: unsupported operand type(s) for *: 'Decimal' and 'Decimal'

On 9/19/07, Landlord Bulfleet <landlord1...@gmail.com> wrote:
...

> sum is property of a model object in our database
> (models.DecimalField(max_digits=7, decimal_places=2)) & f_c.rate is a
> Decimal constructed using Decimal(string) construction (Decimal is imported
> with "from decimal import Decimal")

> We have some doubts that this may be a result of the django's python 2.3
> _decimal compatibility.

You're using PsycoPG with multiple interpreters.  :)

http://www.initd.org/tracker/psycopg/ticket/192
http://groups.google.com/group/django-developers/browse_thread/thread...

Anyway, I did run into this using psycopg1, but switched to psycopg2
and patched it since 1) it's being maintained and 2) it was easier to
fix that way.

I emailed the psycopg list a couple weeks ago with a patch but never
heard back from them.  I don't have rights to add the patch to their
ticket tracker, or I'd do that, too.

I'm attaching a patch against psycopg2's source code here.   This is
for r896 on the 2.0.x branch.

Alternatively, you could run separate apache processes for each needed
interpreter or switch to mod_wsgi.

I wasn't prepared to swtich to mod_wsgi in a hurry, so patched
psycopg2 instead.

Apparently not that many people are using multiple interpreters and
decimal fields with psycopg...

  psycopg2-2.0.x-896-decimal.diff
8K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Landlord Bulfleet  
View profile  
 More options Sep 20 2007, 6:43 am
From: "Landlord Bulfleet" <landlord1...@gmail.com>
Date: Thu, 20 Sep 2007 13:43:47 +0300
Local: Thurs, Sep 20 2007 6:43 am
Subject: Re: unsupported operand type(s) for *: 'Decimal' and 'Decimal'

Thanks :)

Looks like this is the solution to our problem. We haven't tested it yet but
will try soon.

Thanks again

On 9/20/07, Jeremy Dunck <jdu...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google