Example:
import bitstring
format = 'bits:4=BL_OFFT, uint:12=width, uint:12=height'
d = {'BL_OFFT': '0b1011', 'width': 352, 'height': 288}
s = bitstring.pack(format, **d)
No output expected. Instead, got a ValueException:
Traceback (most recent call last):
File "trybs.py", line 4, in <module>
s = bitstring.pack(format, **d)
File "C:\Python26\lib\site-packages\bitstring.py", line 2663, in pack
s.append(_init_with_token(name, length, value))
File "C:\Python26\lib\site-packages\bitstring.py", line 101, in
_init_with_tok
en
b = BitString(value)
File "C:\Python26\lib\site-packages\bitstring.py", line 576, in __init__
func(d, offset, length)
File "C:\Python26\lib\site-packages\bitstring.py", line 1115, in _setauto
self.append(_init_with_token(*token))
File "C:\Python26\lib\site-packages\bitstring.py", line 107, in
_init_with_tok
en
raise ValueError("Can't parse token name %s." % name)
ValueError: Can't parse token name bl_offt.
Note lower-case name 'bl-offt' in last line of output.
Changing the key to lower-case in the format and dictionary allowed the
example to run.
I'm using r456 in Subversion. Python version 2.6.2 on Windows XP.