Skip to content

Commit b002ab2

Browse files
committed
Trying to make StringIO handle unicode and pass it through to
FieldStorage to eliminate the error: self = FieldStorage(None, None, ''), line = '{ "data": "Joe Doe 1" }' def __write(self, line): """line is always bytes, not string""" if self.__file is not None: if self.__file.tell() + len(line) > 1000: self.file = self.make_file() data = self.__file.getvalue() self.file.write(data) self.__file = None if self._binary_file: # keep bytes self.file.write(line) else: # decode to string > self.file.write(line.decode(self.encoding, self.errors)) E AttributeError: 'str' object has no attribute 'decode'
1 parent c4ca84c commit b002ab2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

test/rest_common.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from .mocknull import MockNull
1616

17-
from roundup.anypy.strings import StringIO
17+
from io import StringIO
1818
import json
1919

2020
NEEDS_INSTANCE = 1
@@ -409,7 +409,7 @@ def testDispatch(self):
409409
# simulate: /rest/data/user/<id>/realname
410410
# use etag in header
411411
etag = calculate_etag(self.db.user.getnode(self.joeid))
412-
body='{ "data": "Joe Doe 1" }'
412+
body=u'{ "data": "Joe Doe 1" }'
413413
env = { "CONTENT_TYPE": "application/json",
414414
"CONTENT_LENGTH": len(body),
415415
"REQUEST_METHOD": "PUT"
@@ -442,7 +442,7 @@ def testDispatch(self):
442442
# simulate: /rest/data/user/<id>/realname
443443
# use etag in payload
444444
etag = calculate_etag(self.db.user.getnode(self.joeid))
445-
body='{ "@etag": "%s", "data": "Joe Doe 2" }'%etag
445+
body=u'{ "@etag": "%s", "data": "Joe Doe 2" }'%etag
446446
env = { "CONTENT_TYPE": "application/json",
447447
"CONTENT_LENGTH": len(body),
448448
"REQUEST_METHOD": "PUT"
@@ -510,7 +510,7 @@ def testDispatch(self):
510510
self.assertEqual(self.dummy_client.response_code, 200)
511511

512512
etag = calculate_etag(self.db.user.getnode(self.joeid))
513-
body='{ "address": "[email protected]", "@etag": "%s"}'%etag
513+
body=u'{ "address": "[email protected]", "@etag": "%s"}'%etag
514514
env = { "CONTENT_TYPE": "application/json",
515515
"CONTENT_LENGTH": len(body),
516516
"REQUEST_METHOD": "PATCH"
@@ -536,7 +536,7 @@ def testDispatch(self):
536536

537537
# and set it back
538538
etag = calculate_etag(self.db.user.getnode(self.joeid))
539-
body='{ "address": "%s", "@etag": "%s"}'%(
539+
body=u'{ "address": "%s", "@etag": "%s"}'%(
540540
stored_results['data']['attributes']['address'],
541541
etag)
542542
# reuse env and headers from prior test.
@@ -557,7 +557,7 @@ def testDispatch(self):
557557
del(self.headers)
558558

559559
# POST to create new issue
560-
body='{ "title": "foo bar", "priority": "critical" }'
560+
body=u'{ "title": "foo bar", "priority": "critical" }'
561561

562562
env = { "CONTENT_TYPE": "application/json",
563563
"CONTENT_LENGTH": len(body),

0 commit comments

Comments
 (0)