andymckay/zamboni — comment on commit fb66754ef74057948ff041ca061f7bd46b767b7e
File: apps/paypal/__init__.py line 95
By kumar303:

Here's another among hackers that you should catch:

>>> Decimal('¹'.decode('utf8'))
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/Cellar/python2.6/2.6.5/lib/python2.6/decimal.py", line 556, in __new__
self._int = str(int(intpart+fracpart))
ValueError: invalid literal for int() with base 10: '\xb9'

oh, wait, looks like ``str()`` saves you:

>>> Decimal(str('¹'.decode('utf8')))
Traceback (most recent call last):
File "", line 1, in
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb9' in position 0: ordinal not in range(128)

still worth adding a test for if you don't already have one.