self.assertIn(b"Exception ignored in:", stderr)
self.assertIn(b"C.__del__", stderr)
+ def test_issue35714(self):
+ # Embedded null characters should not be allowed in format strings.
+ for s in '\0', '2\0i', b'\0':
+ with self.assertRaisesRegex(struct.error,
+ 'embedded null character'):
+ struct.calcsize(s)
+
+
class UnpackIteratorTest(unittest.TestCase):
"""
Tests for iterative unpacking (struct.Struct.iter_unpack).
size_t ncodes;
fmt = PyBytes_AS_STRING(self->s_format);
+ if (strlen(fmt) != (size_t)PyBytes_GET_SIZE(self->s_format)) {
+ PyErr_SetString(_structmodulestate_global->StructError,
+ "embedded null character");
+ return -1;
+ }
f = whichtable(&fmt);