bunch icon indicating copy to clipboard operation
bunch copied to clipboard

Bunch is completely broken when using unicode strings

Open bjorkegeek opened this issue 12 years ago • 2 comments

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)

bjorkegeek avatar Jun 19 '13 09:06 bjorkegeek

A couple of observations:

  1. 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).
  2. 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.

mikenerone avatar Sep 23 '14 20:09 mikenerone