Skip to content

Commit cf941b1

Browse files
author
Zach Lowry
committed
Switch handling of non-Unicode responses to treat them as byte streams
rather than ASCII strings.
1 parent 0533c39 commit cf941b1

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

test/lrs_response_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# coding=utf-8
2+
#
13
# Copyright 2014 Rustici Software
24
#
35
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -129,6 +131,15 @@ def test_setters(self):
129131
self.assertIsInstance(resp.response, httplib.HTTPResponse)
130132
self.assertEqual(resp.response, web_resp)
131133

134+
def test_unicode(self):
135+
resp = LRSResponse()
136+
resp.data = "\xce\xb4\xce\xbf\xce\xba\xce\xb9\xce\xbc\xce\xae " \
137+
"\xcf\x80\xce\xb5\xcf\x81\xce\xb9\xce\xb5\xcf\x87\xce\xbf\xce\xbc\xce\xad\xce\xbd\xce\xbf\xcf\x85"
138+
139+
self.assertIsInstance(resp, LRSResponse)
140+
self.assertIsInstance(resp.data, unicode)
141+
self.assertEqual(resp.data, u"δοκιμή περιεχομένου")
142+
132143
def test_setters_none(self):
133144
resp = LRSResponse()
134145

tincan/lrs_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def data(self, value):
106106
:type value: unicode
107107
"""
108108
if value is not None and not isinstance(value, unicode):
109-
unicode(value)
109+
value = value.decode('utf-8')
110110
self._data = value
111111

112112
@property

0 commit comments

Comments
 (0)