Ticket #12049: lazyobject-deepcopy.diff
File lazyobject-deepcopy.diff, 2.2 KB (added by , 15 years ago) |
---|
-
django/utils/functional.py
307 307 if self._wrapped is None: self._setup() 308 308 return str(self._wrapped) 309 309 310 def __deepcopy__(self, memo): 311 if self._wrapped is None: 312 result = self.__class__(self._setupfunc) 313 memo[id(self)] = result 314 return result 315 else: 316 import copy 317 return copy.deepcopy(self._wrapped, memo) 318 310 319 def _setup(self): 311 320 self._wrapped = self._setupfunc() -
tests/regressiontests/context_processors/tests.py
3 3 """ 4 4 5 5 from django.conf import settings 6 from django.contrib.auth.models import Group 7 from django.db.models import Q 6 8 from django.test import TestCase 7 9 from django.template import Template 8 10 … … 81 83 self.assertContains(response, "username: super") 82 84 # bug #12037 is tested by the {% url %} in the template: 83 85 self.assertContains(response, "url: /userpage/super/") 86 87 # See if this object can be used for queries where a Q() comparing 88 # a user can be used with another Q() (in an AND or OR fashion). 89 # This simulates what a template tag might do with the user from the 90 # context. Note that we don't need to execute a query, just build it. 91 # 92 # The failure case (bug #12049) on Python 2.4 with a LazyObject-wrapped 93 # User is a fatal TypeError: "function() takes at least 2 arguments 94 # (0 given)" deep inside deepcopy(). 95 # 96 # Python 2.5 and 2.6 succeeded, but logged internally caught exception 97 # spew: 98 # 99 # Exception RuntimeError: 'maximum recursion depth exceeded while 100 # calling a Python object' in <type 'exceptions.AttributeError'> 101 # ignored" 102 query = Q(user=response.context['user']) & Q(someflag=True)