When you have an xml document like the one with a default namespace below. When you try to lookup nodes in the document they are not found.
```
docTree.find("specVersion")
None
```
If you add a namespaces map with the '' key and the default namespaces like:
{ '': 'urn:schemas-upnp-org:device-1-0' }
then the nodes are still not found. The issue is that there is a case
missing from xpath_tokenizer that does not yield a pair with the default namespace when one is specified. Here is a fix.
https://github.com/myronww/cpython/commit/0fc65daca239624139f2a018a83f0b0ec04a8068
```
from xml.etree.ElementTree import fromstring as parse_xml_fromstring
from xml.etree.ElementTree import ElementTree
SAMPLEXML = """<?xml version="1.0" encoding="utf-8"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion><major>1</major><minor>0</minor></specVersion>
<device>
<deviceType>urn:schemas-wifialliance-org:device:WFADevice:1</deviceType>
<friendlyName>R7400 (Wireless AP)</friendlyName>
</device>
</root>
rootNode = parse_xml_fromstring(SAMPLEXML)
# Create a namespaces map like { '': 'urn:schemas-upnp-org:device-1-0' }
defaultns = {"": docNode.tag.split("}")[0][1:]}
specVerNode = docNode.find("specVersion", namespaces=defaultns)
```
Results should look like this
```
docNode.find("specVersion", namespaces=defaultns)
<Element '{urn:schemas-upnp-org:device-1-0}specVersion' at 0x7f18030e32f0>
```
|