Commit fd99ad79 authored by Matti Picus's avatar Matti Picus
Browse files

merge bpo-35714 which changes an error message

......@@ -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)
break
else:
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