diff options
| author | Zachary Turner <zturner@google.com> | 2015-10-23 19:52:36 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2015-10-23 19:52:36 +0000 |
| commit | 58968ac83f23c2987d7bdd349d5b0a82f4a2e812 (patch) | |
| tree | b6774965bbc6ddb1822fb946ae4f190ceaf79ccb | |
| parent | 9b058a6ec737bf992ac08fec37a6cf0504bdca45 (diff) | |
| download | bcm5719-llvm-58968ac83f23c2987d7bdd349d5b0a82f4a2e812.tar.gz bcm5719-llvm-58968ac83f23c2987d7bdd349d5b0a82f4a2e812.zip | |
Make uses of unicode literals portable.
Six provides six.u() which resolves to either u"" or "" depending on
Python version, and and six.unichr() which resolves to either unichr()
or chr() depending on Python version. Use these functions anywhere
where we were relying on u"" or unichr().
llvm-svn: 251139
| -rw-r--r-- | lldb/test/functionalities/command_script/import/thepackage/TPunitA.py | 5 | ||||
| -rw-r--r-- | lldb/test/functionalities/command_script/import/thepackage/TPunitB.py | 5 | ||||
| -rwxr-xr-x | lldb/test/progress.py | 27 | ||||
| -rw-r--r-- | lldb/test/test_results.py | 7 |
4 files changed, 27 insertions, 17 deletions
diff --git a/lldb/test/functionalities/command_script/import/thepackage/TPunitA.py b/lldb/test/functionalities/command_script/import/thepackage/TPunitA.py index 86381a1acc2..cd18e4cfc95 100644 --- a/lldb/test/functionalities/command_script/import/thepackage/TPunitA.py +++ b/lldb/test/functionalities/command_script/import/thepackage/TPunitA.py @@ -1,3 +1,6 @@ +import lldb_shared +import six + def command(debugger, command, result, internal_dict): - result.PutCString(u"hello world A") + result.PutCString(six.u("hello world A")) return None diff --git a/lldb/test/functionalities/command_script/import/thepackage/TPunitB.py b/lldb/test/functionalities/command_script/import/thepackage/TPunitB.py index 52db603e512..936201157ac 100644 --- a/lldb/test/functionalities/command_script/import/thepackage/TPunitB.py +++ b/lldb/test/functionalities/command_script/import/thepackage/TPunitB.py @@ -1,3 +1,6 @@ +import lldb_shared +import six + def command(debugger, command, result, internal_dict): - result.PutCString(u"hello world B") + result.PutCString(six.u("hello world B")) return None diff --git a/lldb/test/progress.py b/lldb/test/progress.py index 99b089620c0..bb71b4bcfce 100755 --- a/lldb/test/progress.py +++ b/lldb/test/progress.py @@ -2,6 +2,9 @@ from __future__ import print_function +import lldb_shared +import six + import sys import time @@ -17,17 +20,17 @@ class ProgressBar(object): format Format incremental """ - light_block = unichr(0x2591).encode("utf-8") - solid_block = unichr(0x2588).encode("utf-8") - solid_right_arrow = unichr(0x25BA).encode("utf-8") + light_block = six.unichr(0x2591).encode("utf-8") + solid_block = six.unichr(0x2588).encode("utf-8") + solid_right_arrow = six.unichr(0x25BA).encode("utf-8") def __init__(self, start=0, end=10, width=12, - fill=unichr(0x25C9).encode("utf-8"), - blank=unichr(0x25CC).encode("utf-8"), - marker=unichr(0x25CE).encode("utf-8"), + fill=six.unichr(0x25C9).encode("utf-8"), + blank=six.unichr(0x25CC).encode("utf-8"), + marker=six.unichr(0x25CE).encode("utf-8"), format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%', incremental=True): super(ProgressBar, self).__init__() @@ -81,9 +84,9 @@ class AnimatedProgressBar(ProgressBar): start=0, end=10, width=12, - fill=unichr(0x25C9).encode("utf-8"), - blank=unichr(0x25CC).encode("utf-8"), - marker=unichr(0x25CE).encode("utf-8"), + fill=six.unichr(0x25C9).encode("utf-8"), + blank=six.unichr(0x25CC).encode("utf-8"), + marker=six.unichr(0x25CE).encode("utf-8"), format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%', incremental=True, stdout=sys.stdout): @@ -107,9 +110,9 @@ class ProgressWithEvents(AnimatedProgressBar): start=0, end=10, width=12, - fill=unichr(0x25C9).encode("utf-8"), - blank=unichr(0x25CC).encode("utf-8"), - marker=unichr(0x25CE).encode("utf-8"), + fill=six.unichr(0x25C9).encode("utf-8"), + blank=six.unichr(0x25CC).encode("utf-8"), + marker=six.unichr(0x25CE).encode("utf-8"), format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%', incremental=True, stdout=sys.stdout): diff --git a/lldb/test/test_results.py b/lldb/test/test_results.py index f35d34c9d03..b6ef584c16d 100644 --- a/lldb/test/test_results.py +++ b/lldb/test/test_results.py @@ -23,6 +23,7 @@ import time import traceback import xml.sax.saxutils +import six from six.moves import cPickle @@ -494,11 +495,11 @@ class XunitFormatter(ResultsFormatter): # Build up an array of range expressions. illegal_ranges = [ - "%s-%s" % (unichr(low), unichr(high)) + "%s-%s" % (six.unichr(low), six.unichr(high)) for (low, high) in illegal_chars_u] # Compile the regex - return re.compile(u'[%s]' % u''.join(illegal_ranges)) + return re.compile(six.u('[%s]') % six.u('').join(illegal_ranges)) @staticmethod def _quote_attribute(text): @@ -524,7 +525,7 @@ class XunitFormatter(ResultsFormatter): unicode_content = str_or_unicode.decode('utf-8') else: unicode_content = str_or_unicode - return self.invalid_xml_re.sub(u'?', unicode_content).encode('utf-8') + return self.invalid_xml_re.sub(six.u('?'), unicode_content).encode('utf-8') @classmethod def arg_parser(cls): |

