2


1

TypeError:instancemethodは少なくとも2つの引数を予期し、0を取得しました

Django 1.1.2およびPython 2.6.5

一見無害なクエリセットを実行すると、このエラーが発生し続けます。 http://code.djangoproject.com/ticket/7204で説明されている問題とまったく同じように見えますが、Django 1.1.2を実行しています。これには、このバグの修正が含まれているはずです。 以前に誰かが似たようなものを扱ったことがありますか?

クエリを作成するコードは次のとおりです。

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

以下は、トレースバックの短縮版です(あまり有用ではありません):

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

1 Answer


1


他の誰かがこれに遭遇する可能性があるため、このエラーは、django-multilingualとdjango.dbのFオブジェクトの組み合わせによって発生します。 Fオブジェクトを削除するためにコードを書き直すことで問題が解決しました。

根本的な原因は実際にはPythonのバグです。詳細については、http://bugs.python.org/issue1515を参照してください