From bce27850d7e2d86e1b8046be8eb1d51c83dbdd2c Mon Sep 17 00:00:00 2001 From: dol-sen Date: Thu, 13 Oct 2011 20:11:30 -0700 Subject: fix an encode error regression in python 2 introduced in the py2, py3 compatibility changes. --- layman/db.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/layman/db.py b/layman/db.py index cca257b..0215a2f 100644 --- a/layman/db.py +++ b/layman/db.py @@ -27,6 +27,7 @@ __version__ = "$Id: db.py 309 2007-04-09 16:23:38Z wrobel $" #------------------------------------------------------------------------------- import os, os.path +import sys import urllib2 import hashlib @@ -414,11 +415,12 @@ class RemoteDB(DbBase): 'oblem with the webserver. Check the content ' 'of the file. Error was:\n' + str(error)) + # the folowing is neded for py3 only + if sys.hexversion >= 0x3000000 and hasattr(olist, 'decode'): + olist = olist.decode("UTF-8") # Ok, now we can overwrite the old cache try: out_file = fileopen(mpath, 'w') - if hasattr(olist, 'decode'): - olist = olist.decode("UTF-8") out_file.write(olist) out_file.close() -- cgit v1.2.3-1-g7c22