summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2019-04-18 17:05:03 (GMT)
committerGitHub <noreply@github.com>2019-04-18 17:05:03 (GMT)
commite8113f51a8bdf33188ee30a1c038a298329e7bfa (patch)
tree9352ef363c501a34f32ed4e8e43d3cf3b23b0def /Lib/xml
parent7e954e7de4f3777b5ce239640bd2b76aced09561 (diff)
downloadcpython-e8113f51a8bdf33188ee30a1c038a298329e7bfa.zip
cpython-e8113f51a8bdf33188ee30a1c038a298329e7bfa.tar.gz
cpython-e8113f51a8bdf33188ee30a1c038a298329e7bfa.tar.bz2
bpo-30485: Change the prefix for defining the default namespace in ElementPath from None to '' since there is existing code that uses that and it's more convenient to have an all-string-keys dict (e.g. when sorting items etc.). (#12860)
Diffstat (limited to 'Lib/xml')
-rw-r--r--Lib/xml/etree/ElementPath.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py
index 4d231a7..b670d58 100644
--- a/Lib/xml/etree/ElementPath.py
+++ b/Lib/xml/etree/ElementPath.py
@@ -71,7 +71,7 @@ xpath_tokenizer_re = re.compile(
)
def xpath_tokenizer(pattern, namespaces=None):
- default_namespace = namespaces.get(None) if namespaces else None
+ default_namespace = namespaces.get('') if namespaces else None
for token in xpath_tokenizer_re.findall(pattern):
tag = token[1]
if tag and tag[0] != "{":
@@ -275,11 +275,7 @@ def iterfind(elem, path, namespaces=None):
cache_key = (path,)
if namespaces:
- if None in namespaces:
- cache_key += (namespaces[None],) + tuple(sorted(
- item for item in namespaces.items() if item[0] is not None))
- else:
- cache_key += tuple(sorted(namespaces.items()))
+ cache_key += tuple(sorted(namespaces.items()))
try:
selector = _cache[cache_key]