Ticket #13357: django-pypy.2.diff
File django-pypy.2.diff, 8.1 KB (added by , 14 years ago) |
---|
-
django/contrib/admin/options.py
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 2c2bcd5..1d3a150 100644
a b class BaseModelAdmin(object): 73 73 readonly_fields = () 74 74 75 75 def __init__(self): 76 self.formfield_overrides = dict(FORMFIELD_FOR_DBFIELD_DEFAULTS, **self.formfield_overrides) 76 overrides = FORMFIELD_FOR_DBFIELD_DEFAULTS.copy() 77 overrides.update(self.formfield_overrides) 78 self.formfield_overrides = overrides 77 79 78 80 def formfield_for_dbfield(self, db_field, **kwargs): 79 81 """ -
django/core/cache/backends/filebased.py
diff --git a/django/core/cache/backends/filebased.py b/django/core/cache/backends/filebased.py index 91f0b78..4433367 100644
a b class CacheClass(BaseCache): 42 42 fname = self._key_to_file(key) 43 43 try: 44 44 f = open(fname, 'rb') 45 exp = pickle.load(f) 46 now = time.time() 47 if exp < now: 45 try: 46 exp = pickle.load(f) 47 now = time.time() 48 if exp < now: 49 f.close() 50 self._delete(fname) 51 else: 52 return pickle.load(f) 53 finally: 48 54 f.close() 49 self._delete(fname)50 else:51 return pickle.load(f)52 55 except (IOError, OSError, EOFError, pickle.PickleError): 53 56 pass 54 57 return default … … class CacheClass(BaseCache): 67 70 os.makedirs(dirname) 68 71 69 72 f = open(fname, 'wb') 70 now = time.time() 71 pickle.dump(now + timeout, f, pickle.HIGHEST_PROTOCOL) 72 pickle.dump(value, f, pickle.HIGHEST_PROTOCOL) 73 try: 74 now = time.time() 75 pickle.dump(now + timeout, f, pickle.HIGHEST_PROTOCOL) 76 pickle.dump(value, f, pickle.HIGHEST_PROTOCOL) 77 finally: 78 f.close() 73 79 except (IOError, OSError): 74 80 pass 75 81 … … class CacheClass(BaseCache): 93 99 fname = self._key_to_file(key) 94 100 try: 95 101 f = open(fname, 'rb') 96 exp = pickle.load(f) 97 now = time.time() 98 if exp < now: 102 try: 103 exp = pickle.load(f) 104 now = time.time() 105 if exp < now: 106 self._delete(fname) 107 return False 108 else: 109 return True 110 finally: 99 111 f.close() 100 self._delete(fname)101 return False102 else:103 return True104 112 except (IOError, OSError, EOFError, pickle.PickleError): 105 113 return False 106 114 -
tests/modeltests/aggregation/models.py
diff --git a/tests/modeltests/aggregation/models.py b/tests/modeltests/aggregation/models.py index e5f0f5d..74e43b8 100644
a b u'The Definitive Guide to Django: Web Development Done Right' 191 191 192 192 # Calling values on a queryset that has annotations returns the output 193 193 # as a dictionary 194 >>> Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values()195 [ {'rating': 4.5, 'isbn': u'159059725', 'name': u'The Definitive Guide to Django: Web Development Done Right', 'pubdate': datetime.date(2007, 12, 6), 'price': Decimal("30..."), 'contact_id': 1, 'id': 1, 'publisher_id': 1, 'pages': 447, 'mean_age': 34.5}]194 >>> [sorted(o.iteritems()) for o in Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values()] 195 [[('contact_id', 1), ('id', 1), ('isbn', u'159059725'), ('mean_age', 34.5), ('name', u'The Definitive Guide to Django: Web Development Done Right'), ('pages', 447), ('price', Decimal("30...")), ('pubdate', datetime.date(2007, 12, 6)), ('publisher_id', 1), ('rating', 4.5)]] 196 196 197 197 >>> Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values('pk', 'isbn', 'mean_age') 198 198 [{'pk': 1, 'isbn': u'159059725', 'mean_age': 34.5}] … … u'The Definitive Guide to Django: Web Development Done Right' 203 203 204 204 # An empty values() call before annotating has the same effect as an 205 205 # empty values() call after annotating 206 >>> Book.objects.filter(pk=1).values().annotate(mean_age=Avg('authors__age'))207 [ {'rating': 4.5, 'isbn': u'159059725', 'name': u'The Definitive Guide to Django: Web Development Done Right', 'pubdate': datetime.date(2007, 12, 6), 'price': Decimal("30..."), 'contact_id': 1, 'id': 1, 'publisher_id': 1, 'pages': 447, 'mean_age': 34.5}]206 >>> [sorted(o.iteritems()) for o in Book.objects.filter(pk=1).values().annotate(mean_age=Avg('authors__age'))] 207 [[('contact_id', 1), ('id', 1), ('isbn', u'159059725'), ('mean_age', 34.5), ('name', u'The Definitive Guide to Django: Web Development Done Right'), ('pages', 447), ('price', Decimal("30...")), ('pubdate', datetime.date(2007, 12, 6)), ('publisher_id', 1), ('rating', 4.5)]] 208 208 209 209 # Calling annotate() on a ValuesQuerySet annotates over the groups of 210 210 # fields to be selected by the ValuesQuerySet. -
tests/modeltests/expressions/models.py
diff --git a/tests/modeltests/expressions/models.py b/tests/modeltests/expressions/models.py index 76006e1..f6292f5 100644
a b FieldError: Joined field references are not permitted in this query 127 127 >>> acme.save() 128 128 Traceback (most recent call last): 129 129 ... 130 TypeError: int() argument must be a string or a number...130 TypeError: ... 131 131 132 132 """} -
tests/regressiontests/aggregation_regress/models.py
diff --git a/tests/regressiontests/aggregation_regress/models.py b/tests/regressiontests/aggregation_regress/models.py index 7c51cd1..66a5ff7 100644
a b FieldError: Cannot resolve keyword 'foo' into field. Choices are: authors, conta 174 174 {'number': 1132, 'select': 1132} 175 175 176 176 # Regression for #10064: select_related() plays nice with aggregates 177 >>> Book.objects.select_related('publisher').annotate(num_authors=Count('authors')).values()[0]178 {'rating': 4.0, 'isbn': u'013790395', 'name': u'Artificial Intelligence: A Modern Approach', 'pubdate': datetime.date(1995, 1, 15), 'price': Decimal("82.8..."), 'contact_id': 8, 'id': 5, 'num_authors': 2, 'publisher_id': 3, 'pages': 1132} 177 >>> sorted(Book.objects.select_related('publisher').annotate(num_authors=Count('authors')).values()[0].iteritems()) 178 [('contact_id', 8), ('id', 5), ('isbn', u'013790395'), ('name', u'Artificial Intelligence: A Modern Approach'), ('num_authors', 2), ('pages', 1132), ('price', Decimal("82.8...")), ('pubdate', datetime.date(1995, 1, 15)), ('publisher_id', 3), ('rating', 4.0)] 179 179 180 180 # Regression for #10010: exclude on an aggregate field is correctly negated 181 181 >>> len(Book.objects.annotate(num_authors=Count('authors'))) … … FieldError: Cannot resolve keyword 'foo' into field. Choices are: authors, conta 219 219 >>> Book.objects.filter(id__in=[]).aggregate(num_authors=Count('authors'), avg_authors=Avg('authors'), max_authors=Max('authors'), max_price=Max('price'), max_rating=Max('rating')) 220 220 {'max_authors': None, 'max_rating': None, 'num_authors': 0, 'avg_authors': None, 'max_price': None} 221 221 222 >>> Publisher.objects.filter(pk=5).annotate(num_authors=Count('book__authors'), avg_authors=Avg('book__authors'), max_authors=Max('book__authors'), max_price=Max('book__price'), max_rating=Max('book__rating')).values()223 [{'max_authors': None, 'name': u"Jonno's House of Books", 'num_awards': 0, 'max_price': None, 'num_authors': 0, 'max_rating': None, 'id': 5, 'avg_authors': None}] 222 >>> list(Publisher.objects.filter(pk=5).annotate(num_authors=Count('book__authors'), avg_authors=Avg('book__authors'), max_authors=Max('book__authors'), max_price=Max('book__price'), max_rating=Max('book__rating')).values()) == [{'max_authors': None, 'name': u"Jonno's House of Books", 'num_awards': 0, 'max_price': None, 'num_authors': 0, 'max_rating': None, 'id': 5, 'avg_authors': None}] 223 True 224 224 225 225 # Regression for #10113 - Fields mentioned in order_by() must be included in the GROUP BY. 226 226 # This only becomes a problem when the order_by introduces a new join.