Commit 72bb13d4 authored by Ondrej Baranovič's avatar Ondrej Baranovič
Browse files

add special error messange for '\0' in rstruct.formatiterator for bpo-35714

branch : bpo-35714
parent ee823c67f70d
Pipeline #21413 passed with stage
in 7 minutes and 19 seconds
......@@ -462,6 +462,12 @@ class AppTestStruct(object):
assert val == sys.maxint+1
assert type(val) is long
def test_bpo35714(self):
# why not "bad char in struct format"??
for s in '\0', '2\0i', b'\0':
exc = raises(self.struct.error, self.struct.calcsize, s)
assert str(exc.value) == 'embedded null character'
class AppTestStructBuffer(object):
spaceconfig = dict(usemodules=['struct', '__pypy__'])
......@@ -72,6 +72,8 @@ class FormatIterator(object):
self.operate(fmtdesc, repetitions)
if c == '\0':
raise StructError("embedded null character")
raise StructError("bad char in struct format")
if not self._operate_is_specialized_:
if fmtdesc.alignment > 1:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment