Rev 187: Add some python 2.7 specific size changes for String objects. in http://bazaar.launchpad.net/%2Bbranch/meliae
John Arbash Meinel
john at arbash-meinel.com
Tue Mar 22 10:32:24 UTC 2011
At http://bazaar.launchpad.net/%2Bbranch/meliae
------------------------------------------------------------
revno: 187
revision-id: john at arbash-meinel.com-20110322103212-q3ohgf1trmqh9lzw
parent: john at arbash-meinel.com-20110225164245-i098e8rw752xq84j
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: meliae
timestamp: Tue 2011-03-22 11:32:12 +0100
message:
Add some python 2.7 specific size changes for String objects.
-------------- next part --------------
=== modified file 'meliae/tests/test__scanner.py'
--- a/meliae/tests/test__scanner.py 2010-08-10 16:14:19 +0000
+++ b/meliae/tests/test__scanner.py 2011-03-22 10:32:12 +0000
@@ -1,14 +1,14 @@
-# Copyright (C) 2009, 2010 Canonical Ltd
-#
+# Copyright (C) 2009, 2010, 2011 Canonical Ltd
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
-#
+#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -28,6 +28,10 @@
STRING_BASE = 8
STRING_SCALING = 4
+if sys.version_info[:2] >= (2, 7):
+ # In python2.7 they 'shrunk' strings by a couple bytes, by changing where
+ # the pointer was. So their base size is a few bytes smaller
+ STRING_BASE = 5
class TestSizeOf(tests.TestCase):
@@ -39,6 +43,7 @@
self.assertEqual(expected_size, _scanner.size_of(obj))
def test_empty_string(self):
+ fixed_size = STRING_BASE
self.assertSizeOf(STRING_SCALING, '', extra_size=0+STRING_BASE, has_gc=False)
def test_short_string(self):
More information about the bazaar-commits
mailing list