diff --git a/src/allmydata/scripts/common_http.py b/src/allmydata/scripts/common_http.py index 5d989feb1..20159b020 100644 --- a/src/allmydata/scripts/common_http.py +++ b/src/allmydata/scripts/common_http.py @@ -1,7 +1,7 @@ from __future__ import print_function import os -from six.moves import cStringIO as StringIO +from io import BytesIO from six.moves import urllib, http_client import six import allmydata # for __full_version__ @@ -39,8 +39,8 @@ class BadResponse(object): def do_http(method, url, body=""): - if isinstance(body, str): - body = StringIO(body) + if isinstance(body, bytes): + body = BytesIO(body) elif isinstance(body, six.text_type): raise TypeError("do_http body must be a bytestring, not unicode") else: diff --git a/src/allmydata/scripts/tahoe_status.py b/src/allmydata/scripts/tahoe_status.py index 36c2d5daa..ff746901b 100644 --- a/src/allmydata/scripts/tahoe_status.py +++ b/src/allmydata/scripts/tahoe_status.py @@ -32,7 +32,7 @@ def _get_json_for_fragment(options, fragment, method='GET', post_args=None): body = '' if post_args is not None: raise ValueError("post_args= only valid for POST method") - resp = do_http(method, url, body=body) + resp = do_http(method, url, body=body.encode("utf-8")) if isinstance(resp, BadResponse): # specifically NOT using format_http_error() here because the # URL is pretty sensitive (we're doing /uri/). diff --git a/src/allmydata/test/cli/test_status.py b/src/allmydata/test/cli/test_status.py index 77eaddf7c..35cd26894 100644 --- a/src/allmydata/test/cli/test_status.py +++ b/src/allmydata/test/cli/test_status.py @@ -95,8 +95,8 @@ class Integration(GridTestMixin, CLITestMixin, unittest.TestCase): d = self.do_cli('status')# '--verbose') def _check(ign): - code, stdout, stdin = ign - self.assertEqual(code, 0) + code, stdout, stderr = ign + self.assertEqual(code, 0, stderr) self.assertTrue('Skipped 1' in stdout) d.addCallback(_check) return d