Comment 2 for bug 1090890

Revision history for this message
Sabin Iacob (iacobs) wrote :

Happens here as well:

Traceback (most recent call last):
  File "/usr/bin/indicator-weather", line 1893, in on_apply
    (location_code, location_details) = self.location.export_location_details()
  File "/usr/bin/indicator-weather", line 406, in export_location_details
    return (self.location_code, self.location_details)
AttributeError: Location instance has no attribute 'location_code'

Turns out it's a problem at line 362, where it checks for errors from Yahoo:

            if (yahoo_woeid_result['ResultSet']['Error'] != 0) and (yahoo_woeid_result['ResultSet']['Results'] != None):

is always true because yahoo_woeid_result['ResultSet']['Error'] is a string; I fixed it by comparing with a string as well:

            if (yahoo_woeid_result['ResultSet']['Error'] != '0') and (yahoo_woeid_result['ResultSet']['Results'] != None):

so it's an easy fix

However, I take a _big_ issue with this:

            yahoo_woeid_result = eval(s)

where s is a JSON string; you're kidding, right?