Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e10206

Browse files
committed
basicsize and itemsize are Py_ssize_t #9688
1 parent dc078de commit 0e10206

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

Lib/test/test_types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,11 @@ def test_format_spec_errors(self):
550550
for code in 'xXobns':
551551
self.assertRaises(ValueError, format, 0, ',' + code)
552552

553+
def test_internal_sizes(self):
554+
self.assertGreater(object.__basicsize__, 0)
555+
self.assertGreater(tuple.__itemsize__, 0)
556+
557+
553558
def test_main():
554559
run_unittest(TypesTests)
555560

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ What's New in Python 3.2 Alpha 2?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #9688: __basicsize__ and __itemsize__ must be accessed as Py_ssize_t.
16+
1517
- Issue #9684: Added a definition for SIZEOF_WCHAR_T to PC/pyconfig.h,
1618
to match the pyconfig.h generated by configure on other systems.
1719

Objects/typeobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ assign_version_tag(PyTypeObject *type)
189189

190190

191191
static PyMemberDef type_members[] = {
192-
{"__basicsize__", T_INT, offsetof(PyTypeObject,tp_basicsize),READONLY},
193-
{"__itemsize__", T_INT, offsetof(PyTypeObject, tp_itemsize), READONLY},
192+
{"__basicsize__", T_PYSSIZET, offsetof(PyTypeObject,tp_basicsize),READONLY},
193+
{"__itemsize__", T_PYSSIZET, offsetof(PyTypeObject, tp_itemsize), READONLY},
194194
{"__flags__", T_LONG, offsetof(PyTypeObject, tp_flags), READONLY},
195195
{"__weakrefoffset__", T_LONG,
196196
offsetof(PyTypeObject, tp_weaklistoffset), READONLY},

0 commit comments

Comments
 (0)