[Python-checkins] r87968 - python/branches/py3k/Lib/test/test_bigmem.py

antoine.pitrou python-checkins at python.org
Wed Jan 12 21:46:38 CET 2011


Author: antoine.pitrou
Date: Wed Jan 12 21:46:37 2011
New Revision: 87968

Log:
Fix the expected memory use of utf-8 encoding.  Also, release the
one reference to a huge object even when an exception is raised.



Modified:
   python/branches/py3k/Lib/test/test_bigmem.py

Modified: python/branches/py3k/Lib/test/test_bigmem.py
==============================================================================
--- python/branches/py3k/Lib/test/test_bigmem.py	(original)
+++ python/branches/py3k/Lib/test/test_bigmem.py	Wed Jan 12 21:46:37 2011
@@ -564,8 +564,11 @@
         if expectedsize is None:
             expectedsize = size
 
-        s = c * size
-        self.assertEqual(len(s.encode(enc)), expectedsize)
+        try:
+            s = c * size
+            self.assertEqual(len(s.encode(enc)), expectedsize)
+        finally:
+            s = None
 
     def setUp(self):
         # HACK: adjust memory use of tests inherited from BaseStrTest
@@ -586,7 +589,8 @@
         for name, memuse in self._adjusted.items():
             getattr(type(self), name).memuse = memuse
 
-    @bigmemtest(minsize=_2G + 2, memuse=character_size + 1)
+    # the utf8 encoder preallocates big time (4x the number of characters)
+    @bigmemtest(minsize=_2G + 2, memuse=character_size + 4)
     def test_encode(self, size):
         return self.basic_encode_test(size, 'utf-8')
 


More information about the Python-checkins mailing list