Remove raw Unicode literals (fix #2069)

PEP 414 didn't add `ur"..."` literals to Python 3. So for hybrid 2/3
compatibility, these had to be replaced with ordinary Unicode string literals.
This was only painful for one string; the others were only raw strings by
convention. (All were regexes.)
This commit is contained in:
Adrian Sampson 2016-06-21 14:29:14 -07:00
parent 7fa3188396
commit 351b6f8c9d
3 changed files with 7 additions and 7 deletions

View file

@ -376,7 +376,7 @@ def _parse_id(s):
no ID can be found, return None.
"""
# Find the first thing that looks like a UUID/MBID.
match = re.search(ur'[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}', s)
match = re.search(u'[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}', s)
if match:
return match.group()

View file

@ -222,9 +222,9 @@ class Bs1770gainBackend(Backend):
out = []
data = text.decode('utf8', errors='ignore')
regex = re.compile(
ur'(\s{2,2}\[\d+\/\d+\].*?|\[ALBUM\].*?)'
'(?=\s{2,2}\[\d+\/\d+\]|\s{2,2}\[ALBUM\]'
':|done\.\s)', re.DOTALL | re.UNICODE)
u'(\\s{2,2}\\[\\d+\\/\\d+\\].*?|\\[ALBUM\\].*?)'
'(?=\\s{2,2}\\[\\d+\\/\\d+\\]|\\s{2,2}\\[ALBUM\\]'
':|done\\.\\s)', re.DOTALL | re.UNICODE)
results = re.findall(regex, data)
for parts in results[0:num_lines]:
part = parts.split(b'\n')

View file

@ -760,7 +760,7 @@ class ConfigTest(unittest.TestCase, TestHelper, _common.Assertions):
ui._raw_main(['test'])
replacements = self.test_cmd.lib.replacements
self.assertEqual(replacements, [(re.compile(ur'[xy]'), 'z')])
self.assertEqual(replacements, [(re.compile(u'[xy]'), 'z')])
def test_multiple_replacements_parsed(self):
with self.write_config_file() as config:
@ -769,8 +769,8 @@ class ConfigTest(unittest.TestCase, TestHelper, _common.Assertions):
ui._raw_main(['test'])
replacements = self.test_cmd.lib.replacements
self.assertEqual(replacements, [
(re.compile(ur'[xy]'), u'z'),
(re.compile(ur'foo'), u'bar'),
(re.compile(u'[xy]'), u'z'),
(re.compile(u'foo'), u'bar'),
])
def test_cli_config_option(self):