pombreda / feedparser

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

(py3) can't submit bytes or string to parse(), TypeError is raised #272

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. import feedparser
2. d = feedparser.parse(b'anything')
3. d
{'feed': {}, 'bozo': 1, 'encoding': 'utf-8', 'bozo_exception': 
TypeError('expected an object with the buffer interface',), 'entries': []}

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

Please provide any additional information below.

#1
the following test should be wrapped with a try to handle the type fault so the 
test fails and continues at 2921 rather than raise TypeError

2883: if urllib.parse.urlparse(url_file_stream_or_string)[0] in ('http', 
'https', 'ftp', 'file', 'feed'):

#2
the following line also raises TypeError, _StringIO appears to be io.BytesIO on 
startup for me, and fails conversion. i suggest it needs str|bytes detection, i 
used isinstance() to test appropriately.

2927: return _StringIO(str(url_file_stream_or_string))

Original issue reported on code.google.com by firefigh...@gmail.com on 27 Apr 2011 at 1:34

GoogleCodeExporter commented 9 years ago
This is fixed in r549. Thanks for the report!

You can download the latest source code at:
<https://feedparser.googlecode.com/svn/trunk/feedparser/feedparser.py>

Original comment by kurtmckee on 27 Apr 2011 at 2:59