jsumners / jsumners/feedparser
feedparser.parse() with Python 3 and missing sgmllib: UnboundLocalError
Open
Nobody has claimed this yet.
auto-migrated
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
If Python 3 is used and user forgets to rename sgmllib3.py to sgmllib.py, then
feedparser.py will set _SGML_AVAILABLE to 0, and feedparser.parse() function
will cause UnboundLocalError, resulting in many errors in test suite.
Example:
======================================================================
ERROR: test_001000 (__main__.TestLooseParser)
./tests/wellformed/atom/entry_summary.xml: entry summary
----------------------------------------------------------------------
Traceback (most recent call last):
File "feedparsertest.py", line 754, in <lambda>
self.failUnlessEval(xmlfile, evalString)
File "feedparsertest.py", line 164, in failUnlessEval
env = feedparser.parse(xmlfile)
File "../build/lib/feedparser.py", line 4012, in parse
result['feed'] = feedparser.feeddata
UnboundLocalError: local variable 'feedparser' referenced before assignment
======================================================================
Original issue reported on code.google.com by Arfrever...@gmail.com on 18 Dec 2012 at 12:43
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in feedparser.py around the parse() code shown in the traceback, then inspect how _SGML_AVAILABLE is set when sgmllib is unavailable. Run the affected tests through feedparsertest.py with the Python 3 missing-sgmllib condition; done means parse() no longer raises UnboundLocalError and the test suite errors are resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100