Opened 10 years ago

Closed 10 years ago

#12665 closed (invalid)

get_or_create fails with self as a parameter

Reported by: Tim Graham Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords: get_or_create deepcopy TypeError
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I believe this bug was introduced in changeset [11916].

I have the following code (abbreviated) which works fine on Django 1.1:

class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    client = models.ForeignKey(Client)

class Client(models.Model):
    def create_login(self):
            user = user,
            client = self,

However, the create_login method generates the following traceback with the latest SVN checkout:

  File "/home/tim/code/python/django-trunk/django/db/models/", line 135, in get_or_create
    return self.get_query_set().get_or_create(**kwargs)
  File "/home/tim/code/python/django-trunk/django/db/models/", line 364, in get_or_create
    return self.get(**kwargs), False
  File "/home/tim/code/python/django-trunk/django/db/models/", line 333, in get
    clone = clone.order_by()
  File "/home/tim/code/python/django-trunk/django/db/models/", line 637, in order_by
    obj = self._clone()
  File "/home/tim/code/python/django-trunk/django/db/models/", line 737, in _clone
    query = self.query.clone()
  File "/home/tim/code/python/django-trunk/django/db/models/sql/", line 228, in clone
    obj.where = deepcopy(self.where)
  File "/usr/lib/python2.5/", line 173, in deepcopy
    y = copier(memo)
  File "/home/tim/code/python/django-trunk/django/utils/", line 61, in __deepcopy__
    obj.children = deepcopy(self.children, memodict)
  File "/usr/lib/python2.5/", line 162, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.5/", line 227, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File "/usr/lib/python2.5/", line 162, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.5/", line 234, in _deepcopy_tuple
    y.append(deepcopy(a, memo))
  File "/usr/lib/python2.5/", line 189, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib/python2.5/", line 337, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/lib/python2.5/", line 162, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.5/", line 254, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib/python2.5/", line 181, in deepcopy
    rv = reductor(2)
TypeError: 'NoneType' object is not callable

I can try to work up a test if this looks to be a valid bug.

Change History (2)

comment:1 Changed 10 years ago by Tim Graham

Actually I have tracked this down to r11952 (merge of multi-db).

comment:2 Changed 10 years ago by Tim Graham

Resolution: invalid
Status: newclosed

looks to be caused by some hackish code in the app I'm working on.

Note: See TracTickets for help on using tickets.
Back to Top