summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLele Gaifax <lele@metapensiero.it>2016-10-15 13:19:16 +0200
committerLele Gaifax <lele@metapensiero.it>2016-10-15 13:19:16 +0200
commit44ceb975224ac4f4da27c115eda2ec53550ced11 (patch)
treead3c89f089dac100f8eabe289e092dc6dfc50cac
parent47d39660b627147be2fbc9fa6d7f33f2c24dfa16 (diff)
Fix #595: use a double escape in the replacement argument to re.sub()
Starting with version 3.6 Python is getting stricter in which escape sequences it accepts in string literals, so unknown codes must use a double backslash. This also use the sub() method on the compiled pattern, instead of passing it to the "generic" re.sub() function.
-rw-r--r--pgcli/packages/prioritization.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/pgcli/packages/prioritization.py b/pgcli/packages/prioritization.py
index eb01b310..37ced704 100644
--- a/pgcli/packages/prioritization.py
+++ b/pgcli/packages/prioritization.py
@@ -11,7 +11,7 @@ white_space_regex = re.compile('\\s+', re.MULTILINE)
def _compile_regex(keyword):
# Surround the keyword with word boundaries and replace interior whitespace
# with whitespace wildcards
- pattern = '\\b' + re.sub(white_space_regex, '\\s+', keyword) + '\\b'
+ pattern = '\\b' + white_space_regex.sub(r'\\s+', keyword) + '\\b'
return re.compile(pattern, re.MULTILINE | re.IGNORECASE)
keywords = get_literals('keywords')