[3.14] gh-140474: Fix memory leak in array.array (GH-140478) (GH-140498)

gh-140474: Fix memory leak in `array.array` (GH-140478)
(cherry picked from commit aa9d0a61d5)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2025-10-23 12:20:16 +02:00 committed by GitHub
parent 853e5d94eb
commit 0fdae5f590
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View file

@ -1255,6 +1255,14 @@ def test_typecode_u_deprecation(self):
with self.assertWarns(DeprecationWarning):
array.array("u")
def test_empty_string_mem_leak_gh140474(self):
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
for _ in range(1000):
a = array.array('u', '')
self.assertEqual(len(a), 0)
self.assertEqual(a.typecode, 'u')
class UCS4Test(UnicodeTest):
typecode = 'w'