Skip to content

Commit

Permalink
Fixed sizeof?
Browse files Browse the repository at this point in the history
  • Loading branch information
arekbulski committed Aug 29, 2016
1 parent 6625901 commit cf0064e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion construct/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def _parse(self, stream, context):
def _build(self, obj, stream, context):
if not isinstance(obj, collections.Sequence):
raise RangeError("expected sequence type, found %s" % type(obj))
if len(obj) < self.mincount or len(obj) > self.maxcount:
if not len(context) <= self.mincount <= self.maxcount <= len(context):
raise RangeError("expected %d to %d, found %d" %
(self.mincount, self.maxcount, len(obj)))
cnt = 0
Expand All @@ -563,6 +563,7 @@ def _build(self, obj, stream, context):
(self.mincount, self.maxcount, len(obj)), sys.exc_info()[1])

def _sizeof(self, context):
print("range sizeof context=",context)
if context is None:
raise SizeofError("cannot calculate size")
if not len(context) <= self.mincount <= self.maxcount <= len(context):
Expand Down

0 comments on commit cf0064e

Please sign in to comment.