bunch
bunch copied to clipboard
Bunch is completely broken when using unicode strings
Test using dictionary:
>>> d={}
>>> d[u'r\xf6k']="smoke"
>>> u'r\xf6k' in d
True
>>> print repr(d)
{u'r\xf6k': 'smoke'}
Test using bunch:
>>> b=Bunch() >>> b[u'r\xf6k']="smoke" >>> u'r\xf6k' in b False >>> print repr(b) Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 7: ordinal not in range(128)
A couple of observations:
- The proposed patch breaks some functionality, such as the ability to change the value of an existing actual attribute on the object (more likely to be an issue with subclasses of
Bunch). - At a glance, it looks like the unicode breakage is only in
__repr__(), so is cosmetic.
In any case, it looks to me like this project might not be maintained anymore.