]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Fix for memory leak reported in #128. Thanks to Manlio Perillo for reporting the...
authorChristopher Lenz <cmlenz@gmail.com>
Fri, 18 Jul 2008 13:09:21 +0000 (13:09 +0000)
committerChristopher Lenz <cmlenz@gmail.com>
Fri, 18 Jul 2008 13:09:21 +0000 (13:09 +0000)
ChangeLog
babel/localedata.py

index 5fdfdb66e52629b848f5a2b61670f509aae92618..70fdb2a5aaa3d97e44cfcc43f7ef82f2d67127b0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,8 @@ http://svn.edgewall.org/repos/babel/tags/0.9.4/
  * Currency symbol definitions that is defined with choice patterns in the
    CLDR data are no longer imported, so the symbol code will be used instead.
  * Fixed quarter support in date formatting.
+ * Fixed a serious memory leak that was introduces by the support for CLDR
+   aliases in 0.9.3 (ticket #128).
 
 
 Version 0.9.3
index 5a76f6ae9e961ed7cb03f165c29bba43e2cf01e0..203bec80079efcc9676a23e1a1531ffa76ce910a 100644 (file)
@@ -174,6 +174,9 @@ class Alias(object):
             data = data[key]
         if isinstance(data, Alias):
             data = data.resolve(base)
+        elif isinstance(data, tuple):
+            alias, others = data
+            data = alias.resolve(base)
         return data
 
 
@@ -185,19 +188,21 @@ class LocaleDataDict(DictMixin, dict):
     def __init__(self, data, base=None):
         dict.__init__(self, data)
         if base is None:
-            base = self
+            base = data
         self.base = base
 
     def __getitem__(self, key):
-        val = dict.__getitem__(self, key)
+        orig = val = dict.__getitem__(self, key)
         if isinstance(val, Alias): # resolve an alias
             val = val.resolve(self.base)
         if isinstance(val, tuple): # Merge a partial dict with an alias
             alias, others = val
             val = alias.resolve(self.base).copy()
             merge(val, others)
-        if isinstance(val, dict): # Return a nested alias-resolving dict
+        if type(val) is dict: # Return a nested alias-resolving dict
             val = LocaleDataDict(val, base=self.base)
+        if val is not orig:
+            self[key] = val
         return val
 
     def copy(self):