diff --git a/django/utils/functional.py b/django/utils/functional.py
index b66fdd3..fecf9f0 100644
a
|
b
|
def lazy(func, *resultclasses):
|
147 | 147 | the lazy evaluation code is triggered. Results are not memoized; the |
148 | 148 | function is evaluated on every access. |
149 | 149 | """ |
150 | | # When lazy() is called by the __reduce_ex__ machinery to reconstitute the |
151 | | # __proxy__ class it can't call with *args, so the first item will just be |
152 | | # a tuple. |
153 | | if len(resultclasses) == 1 and isinstance(resultclasses[0], tuple): |
154 | | resultclasses = resultclasses[0] |
155 | 150 | |
156 | 151 | class __proxy__(Promise): |
157 | 152 | """ |
… |
… |
def lazy(func, *resultclasses):
|
168 | 163 | if self.__dispatch is None: |
169 | 164 | self.__prepare_class__() |
170 | 165 | |
171 | | def __reduce_ex__(self, protocol): |
172 | | return (lazy, (self.__func, resultclasses), self.__dict__) |
| 166 | def __reduce__(self): |
| 167 | return ( |
| 168 | lazy_proxy_unpickle, |
| 169 | (self.__func, self.__args, self.__kw) + resultclasses |
| 170 | ) |
173 | 171 | |
174 | 172 | def __prepare_class__(cls): |
175 | 173 | cls.__dispatch = {} |
… |
… |
def lazy(func, *resultclasses):
|
249 | 247 | |
250 | 248 | return wraps(func)(__wrapper__) |
251 | 249 | |
| 250 | def lazy_proxy_unpickle(func, args, kwargs, *resultclasses): |
| 251 | return lazy(func, *resultclasses)(*args, **kwargs) |
| 252 | |
252 | 253 | def allow_lazy(func, *resultclasses): |
253 | 254 | """ |
254 | 255 | A decorator that allows a function to be called with one or more lazy |
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index 17e53df..bb6d0a7 100644
a
|
b
|
|
1 | 1 | # -*- encoding: utf-8 -*- |
| 2 | import datetime |
| 3 | import decimal |
2 | 4 | import os |
3 | 5 | import sys |
4 | | import decimal |
5 | | import datetime |
| 6 | import pickle |
6 | 7 | |
7 | 8 | from django.template import Template, Context |
8 | 9 | from django.conf import settings |
9 | | from django.utils.formats import get_format, date_format, time_format, localize, localize_input |
| 10 | from django.utils.formats import (get_format, date_format, time_format, localize, |
| 11 | localize_input) |
10 | 12 | from django.utils.numberformat import format as nformat |
11 | 13 | from django.test import TestCase |
12 | | from django.utils.translation import ugettext, ugettext_lazy, activate, deactivate, gettext_lazy, to_locale |
| 14 | from django.utils.translation import (ugettext, ugettext_lazy, activate, |
| 15 | deactivate, gettext_lazy, to_locale) |
13 | 16 | |
14 | 17 | from forms import I18nForm, SelectDateForm, SelectDateWidget, CompanyForm |
15 | 18 | |
… |
… |
class TranslationTests(TestCase):
|
40 | 43 | self.assertEqual(True, s == s2) |
41 | 44 | s4 = ugettext_lazy('Some other string') |
42 | 45 | self.assertEqual(False, s == s4) |
| 46 | |
| 47 | def test_lazy_pickle(self): |
| 48 | s1 = ugettext_lazy("test") |
| 49 | self.assertEqual(unicode(s1), "test") |
| 50 | s2 = pickle.loads(pickle.dumps(s1)) |
| 51 | self.assertEqual(unicode(s2), "test") |
43 | 52 | |
44 | 53 | def test_string_concat(self): |
45 | 54 | """ |