summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-06-07 01:34:14 -0700
committerStefan Krah <skrah@bytereef.org>2019-06-07 10:34:14 +0200
commit8f0bbbdcae73f275faff90cc4559f6111116f001 (patch)
tree47506daf7f147301e049066def24354b96c008c3 /Lib
parent685b806549cc956aeeb3a57fe15ee5a4d1704aed (diff)
downloadcpython-git-8f0bbbdcae73f275faff90cc4559f6111116f001.tar.gz
bpo-37188: Fix a divide-by-zero in arrays of size-0 objects (GH-13881) (#13882)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_arrays.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_arrays.py b/Lib/ctypes/test/test_arrays.py
index 37719399e2..9e41f45dc9 100644
--- a/Lib/ctypes/test/test_arrays.py
+++ b/Lib/ctypes/test/test_arrays.py
@@ -194,6 +194,21 @@ class ArrayTestCase(unittest.TestCase):
_type_ = c_int
_length_ = 1.87
+ def test_empty_element_struct(self):
+ class EmptyStruct(Structure):
+ _fields_ = []
+
+ obj = (EmptyStruct * 2)() # bpo37188: Floating point exception
+ assert sizeof(obj) == 0
+
+ def test_empty_element_array(self):
+ class EmptyArray(Array):
+ _type_ = c_int
+ _length_ = 0
+
+ obj = (EmptyArray * 2)() # bpo37188: Floating point exception
+ assert sizeof(obj) == 0
+
def test_bpo36504_signed_int_overflow(self):
# The overflow check in PyCArrayType_new() could cause signed integer
# overflow.