MostAwesomeDude/construct — Issue #18: MetaFiled requires length attribute to be present on build
Author: ruletko
Created: 2012-03-01 04:58:38+00:00
State: open

This is more like a question rather an issue. I'd expect MEtaField's related length fiekd to be autopopulated on building a structure, however this does not happen:

```python
>>> from construct import *
>>> foo = Struct("foo",
... Byte("length"),
... MetaField("data", lambda ctx: ctx["length"])
... )

>>> foo.build(Container(data="test"))
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/pymodules/python2.6/construct/core.py", line 206, in build
self.build_stream(obj, stream)
File "/usr/lib/pymodules/python2.6/construct/core.py", line 214, in build_stream
self._build(obj, stream, Container())
File "/usr/lib/pymodules/python2.6/construct/core.py", line 662, in _build
subobj = getattr(obj, sc.name)
AttributeError: 'Container' object has no attribute 'length'
```
Could you explain correct behavior?