Blob Blame History Raw
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Fedora Python maintainers <python-devel@lists.fedoraproject.org>
Date: Wed, 22 Jul 2020 16:47:40 +0200
Subject: [PATCH] 00134-fix-COUNT_ALLOCS-failure-in-test_sys.patch

Fix a failure in test_sys.py when configured with COUNT_ALLOCS enabled
Not yet sent upstream
---
 Lib/test/test_sys.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index b7ddbe95cb7..3a6c5a8bf53 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -957,12 +957,17 @@ class SizeofTest(unittest.TestCase):
         # type
         # static type: PyTypeObject
         s = vsize('P2n15Pl4Pn9Pn11PIP')
+        # COUNT_ALLOCS adds a further 3 Py_ssize_t and 2 pointers:
+        if hasattr(sys, 'getcounts'):
+            s += struct.calcsize('3P2P')
         check(int, s)
         # (PyTypeObject + PyNumberMethods + PyMappingMethods +
         #  PySequenceMethods + PyBufferProcs + 4P)
         s = vsize('P2n15Pl4Pn9Pn11PIP') + struct.calcsize('34P 3P 10P 2P 4P')
         # Separate block for PyDictKeysObject with 4 entries
         s += struct.calcsize("2nPn") + 4*struct.calcsize("n2P")
+        if hasattr(sys, 'getcounts'):
+            s += struct.calcsize('3P2P')
         # class
         class newstyleclass(object): pass
         check(newstyleclass, s)