Opened 15 years ago

Closed 15 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: dev
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

Description

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):
        UserProfile.objects.get_or_create(
            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/manager.py", 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/query.py", line 364, in get_or_create
    return self.get(**kwargs), False
  File "/home/tim/code/python/django-trunk/django/db/models/query.py", line 333, in get
    clone = clone.order_by()
  File "/home/tim/code/python/django-trunk/django/db/models/query.py", line 637, in order_by
    obj = self._clone()
  File "/home/tim/code/python/django-trunk/django/db/models/query.py", line 737, in _clone
    query = self.query.clone()
  File "/home/tim/code/python/django-trunk/django/db/models/sql/query.py", line 228, in clone
    obj.where = deepcopy(self.where)
  File "/usr/lib/python2.5/copy.py", line 173, in deepcopy
    y = copier(memo)
  File "/home/tim/code/python/django-trunk/django/utils/tree.py", line 61, in __deepcopy__
    obj.children = deepcopy(self.children, memodict)
  File "/usr/lib/python2.5/copy.py", line 162, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.5/copy.py", line 227, in _deepcopy_list
    y.append(deepcopy(a, memo))
  File "/usr/lib/python2.5/copy.py", line 162, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.5/copy.py", line 234, in _deepcopy_tuple
    y.append(deepcopy(a, memo))
  File "/usr/lib/python2.5/copy.py", line 189, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib/python2.5/copy.py", line 337, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/lib/python2.5/copy.py", line 162, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python2.5/copy.py", line 254, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib/python2.5/copy.py", 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 by Tim Graham, 15 years ago

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

comment:2 by Tim Graham, 15 years ago

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