tags:

views:

86

answers:

1

Django 1.1.2 & Python 2.6.5

I keep getting this error when executing a seemingly innocent queryset. Looks exactly like the issue described in http://code.djangoproject.com/ticket/7204 However, I'm running Django 1.1.2, which is supposed to have the fix for this bug. Has anybody dealt with something similar before?

Here's the code that constructs the query:

def get_some_data(self, start_date, end_date):
    qset = Transaction.txn_objects.get_transactions_between(self.business,
                                                            start_date, 
                                                            end_date)
    income_qset = qset.filter(invoiceitem__invoice__customer = self)
    income_qset = income_qset.exclude(
                    account=F("invoiceitem__taxtypes__account_payable"))
    sums = income_qset.aggregate(models.Sum('credit_amount')) # fails here

Here's an abridged version of the traceback (not very useful):

File ".../models.py" in get_income_between
  200.         sums = income_qset.aggregate(models.Sum('credit_amount'))
File ".../lib/python2.6/site-packages/django/db/models/query.py" in aggregate
  274.         query = self.query.clone()
File ".../lib/python2.6/site-packages/django/db/models/sql/query.py" in clone
  201.         obj.where = deepcopy(self.where, memo=memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  173.                 y = copier(memo)
File ".../lib/python2.6/site-packages/django/utils/tree.py" in __deepcopy__
  61.         obj.children = deepcopy(self.children, memodict)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_list
  228.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  173.                 y = copier(memo)
File ".../lib/python2.6/site-packages/django/utils/tree.py" in __deepcopy__
  61.         obj.children = deepcopy(self.children, memodict)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_list
  228.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  173.                 y = copier(memo)
File ".../lib/python2.6/site-packages/django/utils/tree.py" in __deepcopy__
  61.         obj.children = deepcopy(self.children, memodict)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_list
  228.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  173.                 y = copier(memo)
File ".../lib/python2.6/site-packages/django/utils/tree.py" in __deepcopy__
  61.         obj.children = deepcopy(self.children, memodict)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_list
  228.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_tuple
  235.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_tuple
  235.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_tuple
  235.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_tuple
  235.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_tuple
  235.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_tuple
  235.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_tuple
  235.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_tuple
  235.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_tuple
  235.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_tuple
  235.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_tuple
  235.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  338.             state = deepcopy(state, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.6/copy.py" in _deepcopy_dict
  255.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.6/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py" in _reconstruct
  323.     y = callable(*args)
File "/usr/lib/python2.6/copy_reg.py" in __newobj__
  93.     return cls.__new__(cls, *args)

Exception Type: TypeError at /reports/income_expense/by_customer/32/
Exception Value: instancemethod expected at least 2 arguments, got 0
A: 

For the benefit of whoever else might run into this, the error is caused by a combination of using django-multilingual and django.db's F object. Rewriting the code to eliminate F objects solved the issue.

The root cause is actually a bug in Python, for more info see http://bugs.python.org/issue1515

svintus