Using UTF-8 encoded str objects with non-ascii characters cause UnicodeDecodeError to be raised when using the latest pyactiveresource code.
The following code illustrates the bugs, and the attached patchset fixes the bugs with regression tests included.
# -*- coding: utf-8 -*-
from pyactiveresource.activeresource import ActiveResource
import pyactiveresource.connection
class Product(ActiveResource):
# Bug #1, a regression since pyactiveresource v1.0.1
try:
Product.find(name=u'å'.encode('utf-8'))
# UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)
except pyactiveresource.connection.Error:
pass
# Bug #2
product = Product()
product.to_xml() # UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)