[Lldb-commits] [lldb] r251139 - Make uses of unicode literals portable.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 23 12:52:36 PDT 2015
Author: zturner
Date: Fri Oct 23 14:52:36 2015
New Revision: 251139
URL: http://llvm.org/viewvc/llvm-project?rev=251139&view=rev
Log:
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().
Modified:
lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitA.py
lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitB.py
lldb/trunk/test/progress.py
lldb/trunk/test/test_results.py
Modified: lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitA.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitA.py?rev=251139&r1=251138&r2=251139&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitA.py (original)
+++ lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitA.py Fri Oct 23 14:52:36 2015
@@ -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
Modified: lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitB.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitB.py?rev=251139&r1=251138&r2=251139&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitB.py (original)
+++ lldb/trunk/test/functionalities/command_script/import/thepackage/TPunitB.py Fri Oct 23 14:52:36 2015
@@ -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
Modified: lldb/trunk/test/progress.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/progress.py?rev=251139&r1=251138&r2=251139&view=diff
==============================================================================
--- lldb/trunk/test/progress.py (original)
+++ lldb/trunk/test/progress.py Fri Oct 23 14:52:36 2015
@@ -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(AnimatedProgres
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):
Modified: lldb/trunk/test/test_results.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/test_results.py?rev=251139&r1=251138&r2=251139&view=diff
==============================================================================
--- lldb/trunk/test/test_results.py (original)
+++ lldb/trunk/test/test_results.py Fri Oct 23 14:52:36 2015
@@ -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):
More information about the lldb-commits
mailing list