#27364: fix "incorrect" uses of escape character in the stdlib.

And most of the tools.

Patch by Emanual Barry, reviewed by me, Serhiy Storchaka, and
Martin Panter.
This commit is contained in:
R David Murray 2016-09-08 13:59:53 -04:00
parent 513d7478a1
commit 44b548dda8
83 changed files with 324 additions and 324 deletions

View file

@ -59,15 +59,15 @@
import re
xpath_tokenizer_re = re.compile(
"("
"'[^']*'|\"[^\"]*\"|"
"::|"
"//?|"
"\.\.|"
"\(\)|"
"[/.*:\[\]\(\)@=])|"
"((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|"
"\s+"
r"("
r"'[^']*'|\"[^\"]*\"|"
r"::|"
r"//?|"
r"\.\.|"
r"\(\)|"
r"[/.*:\[\]\(\)@=])|"
r"((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|"
r"\s+"
)
def xpath_tokenizer(pattern, namespaces=None):
@ -180,7 +180,7 @@ def prepare_predicate(next, token):
if elem.get(key) == value:
yield elem
return select
if signature == "-" and not re.match("\-?\d+$", predicate[0]):
if signature == "-" and not re.match(r"\-?\d+$", predicate[0]):
# [tag]
tag = predicate[0]
def select(context, result):
@ -188,7 +188,7 @@ def prepare_predicate(next, token):
if elem.find(tag) is not None:
yield elem
return select
if signature == "-='" and not re.match("\-?\d+$", predicate[0]):
if signature == "-='" and not re.match(r"\-?\d+$", predicate[0]):
# [tag='value']
tag = predicate[0]
value = predicate[-1]

View file

@ -1030,7 +1030,7 @@ def register_namespace(prefix, uri):
ValueError is raised if prefix is reserved or is invalid.
"""
if re.match("ns\d+$", prefix):
if re.match(r"ns\d+$", prefix):
raise ValueError("Prefix format reserved for internal use")
for k, v in list(_namespace_map.items()):
if k == uri or v == prefix: