bytes/str/unicode tweaking for py2/3.

This commit is contained in:
shimizukawa
2011-04-09 18:46:51 +09:00
parent 08f4cf1c2b
commit d398d1e987
+2 -2
View File
@@ -289,7 +289,7 @@ class Console(object):
# This pattern should match all characters that change the cursor position differently
# than a normal character.
motion_char_re = re.compile(u'([\n\r\t\010\007])')
motion_char_re = re.compile('([\n\r\t\010\007])'.encode('ascii'))
def write_scrolling(self, text, attr=None):
u'''write text at current cursor position while watching for scrolling.
@@ -309,7 +309,7 @@ class Console(object):
w, h = self.size()
scroll = 0 # the result
# split the string into ordinary characters and funny characters
chunks = self.motion_char_re.split(text)
chunks = self.motion_char_re.split(ensure_str(text))
for chunk in chunks:
n = self.write_color(chunk, attr)
if len(chunk) == 1: # the funny characters will be alone