Eiriks
Eiriks

Reputation: 487

feedparser - various errors

I need feedparser (se http://www.feedparser.org) for a project, and want to keep third party modules in a separate folder. I did this by adding a folder to my python path, and putting relevant modules there, among them feedparser.

This first attempt to import feedparser resulted in

>>> import feedparser
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/users/me/modules/feedparser.py", line 1
    ed socket timeout; added support for chardet library
            ^
SyntaxError: invalid syntax

I found the text "socket timeout; added..." in the comments at the bottom of the file, removed these comments, and tried again:

>>> import feedparser
Traceback (most recent call last):
    File "", line 1, in 
    File "/home/users/me/modules/feedparser.py", line 1
    = [(key, value) for key, value in attrs if key in self.acceptable_attributes]
    ^
IndentationError: unexpected indent

Ok, so some indent error. I made sure the indent in the function in question where ok (moved some line breaks down to no-indent). And tried again:

>>> import feedparser
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/users/me/modules/feedparser.py", line 1
    , value) for key, value in attrs if key in self.acceptable_attributes]
    ^
SyntaxError: invalid syntax

As much I google, I cannot find anything wrong with the syntax:

def unknown_starttag(self, tag, attrs):
    if not tag in self.acceptable_elements:
        if tag in self.unacceptable_elements_with_end_tag:
            self.unacceptablestack += 1
        return
    attrs = self.normalize_attrs(attrs)
    attrs = [(key, value) for key, value in attrs if key in self.acceptable_attributes]
    _BaseHTMLProcessor.unknown_starttag(self, tag, attrs)

Now what? Is my approach all wrong? Why do I keep producing these errors in a module that seems so well tested and trusted?

Upvotes: -1

Views: 961

Answers (1)

mikej
mikej

Reputation: 66263

The first error sounds like your copy of feedparser.py is corrupt. The last line of the file should be entirely a comment:

#4.1 - MAP - removed socket timeout; added support for chardet library

It sounds like a line break has been introduced resulting in an invalid statement at the end of the file:

#4.1 - MAP - remov
ed socket timeout; added support for chardet library

Upvotes: 1

Related Questions