summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_types.py5
-rw-r--r--Misc/NEWS2
-rw-r--r--Objects/typeobject.c4
3 files changed, 9 insertions, 2 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index a56476b..d227ab1 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -666,6 +666,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)
diff --git a/Misc/NEWS b/Misc/NEWS
index 48f1b9a..4bedeb0 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -14,6 +14,8 @@ Core and Builtins
- Restore GIL in nis_cat in case of error.
+- Issue #9688: __basicsize__ and __itemsize__ must be accessed as Py_ssize_t.
+
- Issue #5319: Print an error if flushing stdout fails at interpreter
shutdown.
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 3bf4e90..d2124f1 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -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},