Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

CString.sizeof(context) throws "can't calculate size" SizeofError #11

Open
HazimGazov opened this issue Nov 14, 2011 · 1 comment
Open

Comments

@HazimGazov
Copy link

This seems to be an issue with CString being an adapted RepeatUntil, which always throws an error for sizeof calls.

>>> from construct import *
>>> str = CString("a_string")
>>> str_parsed = str.parse("foo\x00")
>>> print str_parsed
foo
>>> str.sizeof()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/construct-2.06-py2.7.egg/construct/core.py", line 242, in sizeof
    raise SizeofError(e)
construct.core.SizeofError: can't calculate size
>>> str.sizeof(str_parsed)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/construct-2.06-py2.7.egg/construct/core.py", line 242, in sizeof
    raise SizeofError(e)
construct.core.SizeofError: can't calculate size
@MostAwesomeDude
Copy link
Owner

Hm, this could almost certainly be improved for cases where we have a context. RepeatUntil's a bit of a whiner like that. I'd have to carefully look at how its builder works. RepeatUntil's not super-tested, although we do test its basic functionality.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants