You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to parse a feed an KeyError: 'where' occurred.
View complete traceback
/<project_location>/venv/bin/python main.py
Traceback (most recent call last):
File "main.py", line 28, in <module>
main()
File "main.py", line 22, in main
feed = feedparser.parse(tmp)
File "/<project_location>/venv/lib/python3.8/site-packages/feedparser/api.py", line 263, in parse
saxparser.parse(source)
File "/usr/lib/python3.8/xml/sax/expatreader.py", line 111, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python3.8/xml/sax/xmlreader.py", line 125, in parse
self.feed(buffer)
File "/usr/lib/python3.8/xml/sax/expatreader.py", line 217, in feed
self._parser.Parse(data, isFinal)
File "../Modules/pyexpat.c", line 407, in StartElement
File "/usr/lib/python3.8/xml/sax/expatreader.py", line 369, in start_element_ns
self._cont_handler.startElementNS(pair, None,
File "/<project_location>/venv/lib/python3.8/site-packages/feedparser/parsers/strict.py", line 103, in startElementNS
self.unknown_starttag(localname, list(attrsD.items()))
File "/<project_location>/venv/lib/python3.8/site-packages/feedparser/mixin.py", line 289, in unknown_starttag
return method(attrs_d)
File "/<project_location>/venv/lib/python3.8/site-packages/feedparser/namespaces/georss.py", line 98, in _start_gml_point
self._parse_srs_attrs(attrs_d)
File "/<project_location>/venv/lib/python3.8/site-packages/feedparser/namespaces/georss.py", line 94, in _parse_srs_attrs
context['where']['srsName'] = srs_name
File "/<project_location>/venv/lib/python3.8/site-packages/feedparser/util.py", line 113, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'where'
Process finished with exit code 1
I didn't find nothing relevant in the project's issues or SO, only this question which is basically the very same issue.
The problem seems the absent of where tag from georss namespace.
How to replicate in unittests:
<!--
Description: item point where
Expect: entries[0]['where']['type'] == 'Point' and entries[0]['where']['coordinates'] == (31.1732, 36.9382)
-->
<feed
xmlns="http://www.w3.org/2005/Atom"
xmlns:gml="http://www.opengis.net/gml"
>
<entry>
<gml:Point>
<gml:pos>36.9382 31.1732</gml:pos>
</gml:Point>
</entry>
</feed>
Unittest result
======================================================================
ERROR: test_000000 (__main__.TestCase)
./tests/illformed/geo/gml_point.xml: item point where
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests/runtests.py", line 916, in fn
self.fail_unless_eval(xmlfile, eval_string)
File "tests/runtests.py", line 173, in fail_unless_eval
env = feedparser.parse(xmlfile)
File "/<---->/feedparser/.tox/py38/lib/python3.8/site-packages/feedparser/api.py", line 282, in parse
saxparser.parse(source)
File "/usr/lib/python3.8/xml/sax/expatreader.py", line 111, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python3.8/xml/sax/xmlreader.py", line 125, in parse
self.feed(buffer)
File "/usr/lib/python3.8/xml/sax/expatreader.py", line 217, in feed
self._parser.Parse(data, isFinal)
File "../Modules/pyexpat.c", line 407, in StartElement
File "/usr/lib/python3.8/xml/sax/expatreader.py", line 369, in start_element_ns
self._cont_handler.startElementNS(pair, None,
File "/<---->/feedparser/.tox/py38/lib/python3.8/site-packages/feedparser/parsers/strict.py", line 103, in startElementNS
self.unknown_starttag(localname, list(attrsD.items()))
File "/<---->/feedparser/.tox/py38/lib/python3.8/site-packages/feedparser/mixin.py", line 292, in unknown_starttag
return method(attrs_d)
File "/<---->/feedparser/.tox/py38/lib/python3.8/site-packages/feedparser/namespaces/georss.py", line 98, in _start_gml_point
self._parse_srs_attrs(attrs_d)
File "/<---->/feedparser/.tox/py38/lib/python3.8/site-packages/feedparser/namespaces/georss.py", line 94, in _parse_srs_attrs
context['where']['srsName'] = srs_name
File "/<---->/feedparser/.tox/py38/lib/python3.8/site-packages/feedparser/util.py", line 114, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'where'
The text was updated successfully, but these errors were encountered:
n3s7or
pushed a commit
to n3s7or/feedparser
that referenced
this issue
Mar 25, 2022
When trying to parse a feed an
KeyError: 'where'
occurred.View complete traceback
I didn't find nothing relevant in the project's issues or SO, only this question which is basically the very same issue.
The problem seems the absent of
where
tag fromgeorss
namespace.How to replicate in unittests:
Unittest result
The text was updated successfully, but these errors were encountered: