Skip to content

Commit

Permalink
Revert "[weather] Ugly workaround for feedparser unicode bug on Pytho…
Browse files Browse the repository at this point in the history
…n 3"

I was testing on the wrong version on python. This is what happens when you
code instead of sleep :(

The workaround will be more complicated than that.
This reverts commit 6a729d0.
  • Loading branch information
Elad Alfassa committed Nov 24, 2014
1 parent b72b1c8 commit 750266a
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions weather.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding=utf8
# coding=utf8
"""
weather.py - Willie Yahoo! Weather Module
Copyright 2008, Sean B. Palmer, inamidst.com
Expand All @@ -14,7 +14,6 @@

import feedparser
from lxml import etree
from sys import version_info


def setup(bot):
Expand Down Expand Up @@ -152,28 +151,7 @@ def weather(bot, trigger):

query = web.urlencode({'w': woeid, 'u': 'c'})
url = 'http://weather.yahooapis.com/forecastrss?' + query

# Since feedparser has problems with Python 3 and unicode, and there was
# no feedparser release since 2012, we have to workaround this manually
# in a really ugly way. This kinda sucks.
# See https://code.google.com/p/feedparser/issues/detail?id=384
# it will be solved once feeedparser 5.1.4 will be released, but who knows
# when that will be. I thought of adding a version check here so we won't
# try to workaround on feedparser 5.1.4, but it's 1:08 in the morning so
# I decided it's not a good use of my time right now.

if version_info.major > 3:
# backup the refernece to chardet, just in case
old_chardet = feedparser.chardet
# set it to none, to skip a faulty feedparser code branch
feedparser.chardet = None
parsed = feedparser.parse(url) # Do the actual parsing
# restore chardet to its original value
feedparser.chardet = old_chardet
else:
# Python 2.x, no feedparser issues here
parsed = feedparser.parse(url)

parsed = feedparser.parse(url)
location = parsed['feed']['title']

cover = get_cover(parsed)
Expand Down

0 comments on commit 750266a

Please sign in to comment.