Skip to content

Commit

Permalink
Bug 1428045 - Conditionally set the filter based on python version
Browse files Browse the repository at this point in the history
Unicode raw string literals are a syntax error in Python 3 and there
appears to be no nicer way to handle this for both versions.
  • Loading branch information
ghickman authored and edmorley committed Mar 21, 2018
1 parent 07c2652 commit f7b91ca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion treeherder/etl/text.py
@@ -1,11 +1,16 @@
# -*- coding: utf-8 -*-
import re

import six

if len(u"\U0010FFFF") != 1:
raise Exception('Python has been compiled in UCS-2 mode which is not supported.')

# Regexp that matches all non-BMP unicode characters.
filter_re = re.compile(ur"([\U00010000-\U0010FFFF])", re.U)
if six.PY3:
filter_re = re.compile(r"([\U00010000-\U0010FFFF])")
else:
filter_re = re.compile(ur"([\U00010000-\U0010FFFF])", re.U)


def convert_unicode_character_to_ascii_repr(match_obj):
Expand Down

0 comments on commit f7b91ca

Please sign in to comment.