diff options
author | Joel Wright <joel.wright@sohonet.com> | 2015-01-14 11:10:48 +0000 |
---|---|---|
committer | Joel Wright <joel.wright@sohonet.com> | 2015-02-17 14:52:35 +0000 |
commit | cac21e3cff323d828b69b2280151b9c505bdaeda (patch) | |
tree | 7435e633f138ed563d08cdd546e6df07da808039 | |
parent | 06c73c6020e5af873e3ce245a27035da3448de7b (diff) | |
download | python-swiftclient-cac21e3cff323d828b69b2280151b9c505bdaeda.tar.gz |
Fix crash when stat'ing objects with non-ascii names
This patch fixes a crash and stack trace in stat when an object
name contains non-ascii characters.
Change-Id: Ib6dc686771e593243de56cafc100b17e51d9d9d5
Closes-Bug: 1411665
-rw-r--r-- | swiftclient/multithreading.py | 4 | ||||
-rw-r--r-- | tests/unit/test_multithreading.py | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/swiftclient/multithreading.py b/swiftclient/multithreading.py index 7ae82fa..32d8ffa 100644 --- a/swiftclient/multithreading.py +++ b/swiftclient/multithreading.py @@ -84,13 +84,11 @@ class OutputManager(object): self.print_pool.submit(self._print, msg) def print_items(self, items, offset=DEFAULT_OFFSET, skip_missing=False): - lines = [] template = '%%%ds: %%s' % offset for k, v in items: if skip_missing and not v: continue - lines.append((template % (k, v)).rstrip()) - self.print_msg('\n'.join(lines)) + self.print_msg((template % (k, v)).rstrip()) def error(self, msg, *fmt_args): if fmt_args: diff --git a/tests/unit/test_multithreading.py b/tests/unit/test_multithreading.py index 5f85b1c..6597793 100644 --- a/tests/unit/test_multithreading.py +++ b/tests/unit/test_multithreading.py @@ -205,6 +205,11 @@ class TestOutputManager(testtools.TestCase): thread_manager.print_raw( u'some raw bytes: \u062A\u062A'.encode('utf-8')) + thread_manager.print_items([ + ('key', u'value'), + ('object', 'O\xcc\x88bject') + ]) + # Now we have a thread for error printing and a thread for # normal print messages self.assertEqual(starting_thread_count + 2, @@ -227,7 +232,10 @@ class TestOutputManager(testtools.TestCase): self.assertEqual(''.join([ 'one-argument\n', 'one fish, 88 fish\n', - 'some\n', 'where\n', over_the, raw_bytes + 'some\n', 'where\n', + over_the, raw_bytes, + ' key: value\n', + ' object: O\xcc\x88bject\n' ]), out_stream.getvalue()) first_item = u'I have 99 problems, but a \u062A\u062A is not one\n' |