]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
basicsize and itemsize are Py_ssize_t #9688
authorBenjamin Peterson <benjamin@python.org>
Wed, 25 Aug 2010 23:13:17 +0000 (23:13 +0000)
committerBenjamin Peterson <benjamin@python.org>
Wed, 25 Aug 2010 23:13:17 +0000 (23:13 +0000)
Lib/test/test_types.py
Misc/NEWS
Objects/typeobject.c

index d82c84607b98e418cf46a1230f8e542c8b583381..d16dbba173525374fe5212b5618bb45e9d4f5dbc 100644 (file)
@@ -550,6 +550,11 @@ class TypesTests(unittest.TestCase):
         for code in 'xXobns':
             self.assertRaises(ValueError, format, 0, ',' + code)
 
+    def test_internal_sizes(self):
+        self.assertGreater(object.__basicsize__, 0)
+        self.assertGreater(tuple.__itemsize__, 0)
+
+
 def test_main():
     run_unittest(TypesTests)
 
index 6d3d497af4473b229e374e6bc72f331a1652afe4..ecb1a4f4a098796b02be9ff7509ed97ce56aa76d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 3.2 Alpha 2?
 Core and Builtins
 -----------------
 
+- Issue #9688: __basicsize__ and __itemsize__ must be accessed as Py_ssize_t.
+
 - Issue #9684: Added a definition for SIZEOF_WCHAR_T to PC/pyconfig.h,
   to match the pyconfig.h generated by configure on other systems.
 
index 1babcb605c3bd7b35440c7b2399b143b09127d4c..8b74e1e07681fca406b768f7b832a50d5a98c399 100644 (file)
@@ -189,8 +189,8 @@ assign_version_tag(PyTypeObject *type)
 
 
 static PyMemberDef type_members[] = {
-    {"__basicsize__", T_INT, offsetof(PyTypeObject,tp_basicsize),READONLY},
-    {"__itemsize__", T_INT, offsetof(PyTypeObject, tp_itemsize), READONLY},
+    {"__basicsize__", T_PYSSIZET, offsetof(PyTypeObject,tp_basicsize),READONLY},
+    {"__itemsize__", T_PYSSIZET, offsetof(PyTypeObject, tp_itemsize), READONLY},
     {"__flags__", T_LONG, offsetof(PyTypeObject, tp_flags), READONLY},
     {"__weakrefoffset__", T_LONG,
      offsetof(PyTypeObject, tp_weaklistoffset), READONLY},