diff options
author | astaric <anze.staric@gmail.com> | 2014-06-12 09:33:36 +0200 |
---|---|---|
committer | astaric <anze.staric@gmail.com> | 2015-08-05 18:21:00 +0200 |
commit | a1cc3f1ca8149cddd97bd6823857cc9e3eba544e (patch) | |
tree | e3c1274701ac51feb91985b7f568dbc51d28db93 /babel/support.py | |
parent | 5c073d75a581a178c4679a073553c589d79c1d7e (diff) | |
download | babel-a1cc3f1ca8149cddd97bd6823857cc9e3eba544e.tar.gz |
Add __copy__ and __deepcopy__ to LazyProxy.
Python's copy.copy and copy.deepcopy do not call objects __init__,
resulting in endless recursion.
Diffstat (limited to 'babel/support.py')
-rw-r--r-- | babel/support.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/babel/support.py b/babel/support.py index c720c74..5ab97a5 100644 --- a/babel/support.py +++ b/babel/support.py @@ -263,6 +263,23 @@ class LazyProxy(object): def __setitem__(self, key, value): self.value[key] = value + def __copy__(self): + return LazyProxy( + self._func, + enable_cache=self._is_cache_enabled, + *self._args, + **self._kwargs + ) + + def __deepcopy__(self, memo): + from copy import deepcopy + return LazyProxy( + deepcopy(self._func, memo), + enable_cache=deepcopy(self._is_cache_enabled, memo), + *deepcopy(self._args, memo), + **deepcopy(self._kwargs, memo) + ) + class NullTranslations(gettext.NullTranslations, object): |