manolomartinez / greg

A command-line podcast aggregator
GNU General Public License v3.0
297 stars 37 forks source link

TypeError: a bytes-like object is required, not 'str' #47

Closed josswright closed 8 years ago

josswright commented 8 years ago

(I will be very embarrassed if I've reported two non-issue issues in two days, but still...)

Greg was working fine for me yesterday. However now I'm suddenly getting the following when running 'greg sync':

Traceback (most recent call last): File "/usr/bin/greg", line 9, in load_entry_point('Greg==0.4.6', 'console_scripts', 'greg')() File "/usr/lib/python3.5/site-packages/greg/gregparser.py", line 118, in main function(vars(args)) File "/usr/lib/python3.5/site-packages/greg/greg.py", line 757, in sync feed = Feed(session, target, None) File "/usr/lib/python3.5/site-packages/greg/greg.py", line 114, in init self.podcast = parse_podcast(session.feeds[feed]["url"]) File "/usr/lib/python3.5/site-packages/greg/greg.py", line 433, in parse_podcast podcast = feedparser.parse(url) File "/usr/lib/python3.5/site-packages/feedparser.py", line 3957, in parse saxparser.parse(source) File "/usr/lib/python3.5/site-packages/drv_libxml2.py", line 190, in parse _d(reader.LocalName())) File "/usr/lib/python3.5/site-packages/drv_libxml2.py", line 70, in _d return _decoder(s)[0] File "/usr/lib/python3.5/encodings/utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) TypeError: a bytes-like object is required, not 'str'

Just to check, I created a fresh set of configuration files and added a single previously-working podcast (http://theblacktapes.libsyn.com/rss), but get the same error. This is under Arch Linux, and I may have done an update yesterday, but don't remember specifically which python packages (if any) might have been updated.

josswright commented 8 years ago

I found a bug report that seems relevant here: https://github.com/themoken/canto-next/issues/10 that suggests that it's something to do with drv_libxml2 in feedparser not supporting Python3 very well. (I have no idea why this would have worked until yesterday, given how old the issue seems to be.)

In any case, the suggested solution on that page is to add: feedparser.PREFERRED_XML_PARSERS.remove('drv_libxml2') after the import feedparser

(In fact, they remove that parser on a TypeError: https://github.com/themoken/canto-next/commit/5e6449d2cdec5186c6dc6e05b9990f54c4768904 )

I've tried this in my local copy, and it seems to work here. Again, I have no idea what caused it to stop working suddenly.

FilipBB commented 8 years ago

I'm having this same issue, josswright's suggested fix works for me as well.

Narrat commented 8 years ago

But the main issue is with the packaging of the current (2.9.3-2) libxml2 package on Arch Linux. A new approach to provide py3 bindings and it is currently broken. I noticed it with canto, and the fix doesn't help there. Downgrading does. So it left me kinda wondering why it's working for greg.

But downgrading to libxml2-2.9.3-1 should solve those problems https://bugs.archlinux.org/task/48878

manolomartinez commented 8 years ago

Yeah, I've been bitten by the same libxml2 bug; downgrading sems to help, as @Narrat points out. I'm reluctant for now to remove drv_libxml2, but if the situation persists I will look into it. Thanks, @josswright for reporting and researching a workaround.

So, I suggest we Archers sit tight/downgrade libxml2 and wait for the next release. I assume greg users in other distros have not had any problems with this.

Narrat commented 8 years ago

A new package for Arch is in [testing].

josswright commented 8 years ago

Just ran an update, and rebuilt greg-git. Seems to work!