Thanks for the patch on reviews.reviewboard.org! I've landed it, and it will ship in the next RBTools release.
-David On Wed Feb 18 2015 at 8:25:28 AM Halvor Lund <halvor.l...@gmail.com> wrote: > I'm having trouble posting review requests using the web API if the > summary or description contains non-ASCII characters. I'm using RBTools > 0.7.1, Python 2.7.8 and Ubuntu 14.10. > The following script reproduces the problem: > > # coding: utf-8 > from rbtools.api.client import RBClient > > # Example data > RB_PATH = 'http://review.com/reviews/' > USER = "user" > PASS = "password" > PATH = "/home/user/repo" > def main(): > import random > client = RBClient(RB_PATH, username=USER, password=PASS) > root = client.get_root() > rbrepo = root.get_repositories(path=PATH)[0].id > revreq = root.get_review_requests().create(repository=rbrepo, > commit_id=str(random.random > ())) > # Apparently necessary to post attachment or diff to actually create > the request > revreq.get_file_attachments().upload_attachment( > "attachment", > " ", > caption="An attachment.") > summary = 'ø' > draft = revreq.get_draft() > draft = draft.update(summary=summary) > > > if __name__ == "__main__": > main() > > > This gives the following error: > Traceback (most recent call last): > File "testutf.py", line 24, in <module> > main() > File "testutf.py", line 21, in main > draft = draft.update(summary=summary) > File > "/usr/local/lib/python2.7/site-packages/RBTools-0.7.1-py2.7.egg/rbtools/api/resource.py", > line 137, in <lambda> > meth(resource, **kwargs))) > File > "/usr/local/lib/python2.7/site-packages/RBTools-0.7.1-py2.7.egg/rbtools/api/decorators.py", > line 27, in request_method > *args, **kwargs) > File > "/usr/local/lib/python2.7/site-packages/RBTools-0.7.1-py2.7.egg/rbtools/api/transport/sync.py", > line 62, in execute_request_method > return self._execute_request(request) > File > "/usr/local/lib/python2.7/site-packages/RBTools-0.7.1-py2.7.egg/rbtools/api/transport/sync.py", > line 71, in _execute_request > rsp = self.server.make_request(request) > File > "/usr/local/lib/python2.7/site-packages/RBTools-0.7.1-py2.7.egg/rbtools/api/request.py", > line 512, in make_request > content_type, body = request.encode_multipart_formdata() > File > "/usr/local/lib/python2.7/site-packages/RBTools-0.7.1-py2.7.egg/rbtools/api/request.py", > line 101, in encode_multipart_formdata > content.write(self._fields[key].encode('utf-8') + NEWLINE) > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: > ordinal not in range(128) > > If I instead use a unicode string: > summary = u'ø' > then an error occurs in httplib.py: > > Traceback (most recent call last): > File "testutf.py", line 24, in <module> > main() > File "testutf.py", line 21, in main > draft = draft.update(summary=summary) > File > "/usr/local/lib/python2.7/site-packages/RBTools-0.7.1-py2.7.egg/rbtools/api/resource.py", > line 137, in <lambda> > meth(resource, **kwargs))) > File > "/usr/local/lib/python2.7/site-packages/RBTools-0.7.1-py2.7.egg/rbtools/api/decorators.py", > line 27, in request_method > *args, **kwargs) > File > "/usr/local/lib/python2.7/site-packages/RBTools-0.7.1-py2.7.egg/rbtools/api/transport/sync.py", > line 62, in execute_request_method > return self._execute_request(request) > File > "/usr/local/lib/python2.7/site-packages/RBTools-0.7.1-py2.7.egg/rbtools/api/transport/sync.py", > line 71, in _execute_request > rsp = self.server.make_request(request) > File > "/usr/local/lib/python2.7/site-packages/RBTools-0.7.1-py2.7.egg/rbtools/api/request.py", > line 525, in make_request > rsp = self._urlopen(r) > File "/usr/lib64/python2.7/urllib2.py", line 127, in urlopen > return _opener.open(url, data, timeout) > File "/usr/lib64/python2.7/urllib2.py", line 404, in open > response = self._open(req, data) > File "/usr/lib64/python2.7/urllib2.py", line 422, in _open > '_open', req) > File "/usr/lib64/python2.7/urllib2.py", line 382, in _call_chain > result = func(*args) > File "/usr/lib64/python2.7/urllib2.py", line 1214, in http_open > return self.do_open(httplib.HTTPConnection, req) > File "/usr/lib64/python2.7/urllib2.py", line 1181, in do_open > h.request(req.get_method(), req.get_selector(), req.data, headers) > File "/usr/lib64/python2.7/httplib.py", line 995, in request > self._send_request(method, url, body, headers) > File "/usr/lib64/python2.7/httplib.py", line 1029, in _send_request > self.endheaders(body) > File "/usr/lib64/python2.7/httplib.py", line 991, in endheaders > self._send_output(message_body) > File "/usr/lib64/python2.7/httplib.py", line 842, in _send_output > msg += message_body > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 90: > ordinal not in range(128) > > Is there any way to circumvent these errors? > > -- > Supercharge your Review Board with Power Pack: > https://www.reviewboard.org/powerpack/ > Want us to host Review Board for you? Check out RBCommons: > https://rbcommons.com/ > Happy user? Let us know! https://www.reviewboard.org/users/ > --- > You received this message because you are subscribed to the Google Groups > "reviewboard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to reviewboard+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Supercharge your Review Board with Power Pack: https://www.reviewboard.org/powerpack/ Want us to host Review Board for you? Check out RBCommons: https://rbcommons.com/ Happy user? Let us know! https://www.reviewboard.org/users/ --- You received this message because you are subscribed to the Google Groups "reviewboard" group. To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.