Skip to content

Commit 7c6ac57

Browse files
committed
address review: test + warning
1 parent 2635360 commit 7c6ac57

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

Lib/test/test_array.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ def __index__(self):
118118
IEEE_754_DOUBLE_COMPLEX_LE = 24
119119
IEEE_754_DOUBLE_COMPLEX_BE = 25
120120

121+
MACHINE_FORMAT_CODE_MAX = 25
122+
121123

122124
class ArrayReconstructorTest(unittest.TestCase):
123125

@@ -143,7 +145,7 @@ def test_error(self):
143145
self.assertRaises(ValueError, array_reconstructor,
144146
array.array, "b", UNKNOWN_FORMAT, b"")
145147
self.assertRaises(ValueError, array_reconstructor,
146-
array.array, "b", 26, b"")
148+
array.array, "b", MACHINE_FORMAT_CODE_MAX + 1, b"")
147149
self.assertRaises(ValueError, array_reconstructor,
148150
array.array, "d", 16, b"a")
149151

Modules/arraymodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,8 @@ cf_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
672672

673673
CHECK_ARRAY_BOUNDS(ap, i);
674674

675-
f[0] = x.real;
676-
f[1] = x.imag;
675+
f[0] = (float)x.real;
676+
f[1] = (float)x.imag;
677677
if (i >= 0) {
678678
memcpy(ap->ob_item + i*sizeof(f), &f, sizeof(f));
679679
}

0 commit comments

Comments
 (0)