summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2016-09-08 17:59:53 (GMT)
committerR David Murray <rdmurray@bitdance.com>2016-09-08 17:59:53 (GMT)
commit44b548dda872c0d4f30afd6b44fd74b053a55ad8 (patch)
treeb3c1ff8485bc279000f9db95491ebc69a4385876 /Lib/xml
parent513d7478a136e7646075592da2593476299cc8be (diff)
downloadcpython-44b548dda872c0d4f30afd6b44fd74b053a55ad8.zip
cpython-44b548dda872c0d4f30afd6b44fd74b053a55ad8.tar.gz
cpython-44b548dda872c0d4f30afd6b44fd74b053a55ad8.tar.bz2
#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.
Diffstat (limited to 'Lib/xml')
-rw-r--r--Lib/xml/etree/ElementPath.py22
-rw-r--r--Lib/xml/etree/ElementTree.py2
2 files changed, 12 insertions, 12 deletions
diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py
index 5de4232..ab6b79a 100644
--- a/Lib/xml/etree/ElementPath.py
+++ b/Lib/xml/etree/ElementPath.py
@@ -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]
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index 67b7f2b..4b0c661 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -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: