[PATCHSET] Fix UnicodeDecodeError for utf-8 encoded strings.

26 views
Skip to first unread message

Dylan Smith

unread,
Mar 20, 2012, 11:22:49 AM3/20/12
to pyactiveresource
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):
    _site = "http://localhost:1234"

# 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.name = u'å'.encode('utf-8')
product.to_xml() # UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)
0001-Annotate-url-params-in-_query_string-rather-than-_sp.patch
0002-Properly-handle-url-encoding-of-unicode-encoded-stri.patch
0003-Serialize-utf-8-encoded-strings-attributes-without-e.patch

Mark Roach

unread,
Mar 20, 2012, 12:15:53 PM3/20/12
to pyactive...@googlegroups.com
Thanks so much, and my apologies to not getting to this myself. I have applied and committed all the patches.

--
You received this message because you are subscribed to the Google Groups "pyactiveresource" group.
To post to this group, send email to pyactive...@googlegroups.com.
To unsubscribe from this group, send email to pyactiveresour...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pyactiveresource?hl=en.

Reply all
Reply to author
Forward
0 new messages