libo26 / feedparser

Automatically exported from code.google.com/p/feedparser
Other
0 stars 0 forks source link

'categories' key exists but raises KeyError #294

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the following script:

#!/usr/bin/python

import feedparser
url = 'http://livingsocial.com/cities/78-salt-lake-city.atom'
feed = feedparser.parse(url)
items = feed.entries
print 'categories' in items[0].keys()
print items[0]['categories']

2. Notice that the line 'print "categories" in items[0].keys()' yields True
3. Notice that the next line yields an error:
Traceback (most recent call last):
  File "rss.py", line 14, in <module>
    print items[0]['categories']
  File "/usr/local/lib/python2.6/dist-packages/feedparser.py", line 309, in __getitem__
    return [(tag['scheme'], tag['term']) for tag in UserDict.__getitem__(self, 'tags')]
KeyError: 'tags'

What is the expected output? What do you see instead?
I expect to see the value of "categories" from the rss feed. Instead, I see an 
error.

I tried getting rid of the offending lines lines of __getitem__ in the 
feedparser.py file, and that seemed to fix the problem.

What version of the product are you using? On what operating system?

feedparser 5.0.1 on ubuntu 10.10

Please provide any additional information below.

Original issue reported on code.google.com by davidvst...@gmail.com on 27 Jun 2011 at 1:14

GoogleCodeExporter commented 9 years ago
Fixed in r583.

Original comment by kurtmckee on 8 Sep 2011 at 4:31