Skip to content

Commit 268a953

Browse files
authored
fix escape characters in regexp patterns (#308)
1 parent 5f63d61 commit 268a953

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

powa/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
__VERSION__ = "5.1.1"
1111

12-
ver_tmp = re.sub("(alpha|beta|dev)[0-9]*", "", __VERSION__)
12+
ver_tmp = re.sub(r"(alpha|beta|dev)[0-9]*", "", __VERSION__)
1313
__VERSION_NUM__ = [int(part) for part in (ver_tmp.split("."))]
1414

1515
POWA_ROOT = os.path.dirname(__file__)

powa/sql/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
def unprepare(sql):
1919
if sql.startswith("PREPARE"):
2020
sql = re.sub("PREPARE.*AS", "", sql)
21-
sql = re.sub("\$\d+", "?", sql)
21+
sql = re.sub(r"\$\d+", "?", sql)
2222
return sql
2323

2424

2525
def format_jumbled_query(sql, params):
2626
sql = unprepare(sql)
2727
it = iter(params)
2828
try:
29-
sql = re.sub("\?", lambda val: next(it), sql)
29+
sql = re.sub(r"\?", lambda val: next(it), sql)
3030
except StopIteration:
3131
pass
3232
return sql
@@ -709,7 +709,7 @@ def get_hypoplans(cur, query, indexes=None):
709709
cur.execute("ROLLBACK TO hypo")
710710
raise e
711711

712-
COST_RE = "(?<=\.\.)\d+\.\d+"
712+
COST_RE = r"(?<=\.\.)\d+\.\d+"
713713
m = re.search(COST_RE, baseplan)
714714
if m:
715715
basecost = float(m.group(0))

0 commit comments

Comments
 (0)