Skip to content

0.4.5

Compare
Choose a tag to compare
@dargueta dargueta released this 05 Aug 06:57
· 234 commits to master since this release

Released: 2018-08-04

Bugfixes

  • StringZ failed to include the trailing null when reporting its size.
  • pylint was missing from the development dependencies.

Features

Added present argument to Field that accepts a callable returning a
boolean indicating if the field is present. This is useful for optional
structures whose presence in a stream is dependent on a bit flag somewhere
earlier in the stream:

    class MyStruct(binobj.Struct):
        flags = fields.UInt8()
        name = fields.StringZ(present=lambda f, *_: f['flags'] & 0x80)

    MyStruct.from_bytes(b'\0') == {
        'flags': 0,
        'name': fields.NOT_PRESENT,
    }