summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordol-sen <brian.dolbec@gmail.com>2011-10-13 20:11:30 -0700
committerdol-sen <brian.dolbec@gmail.com>2011-10-13 20:11:30 -0700
commitbce27850d7e2d86e1b8046be8eb1d51c83dbdd2c (patch)
tree25d7228b81e9a8df1e5d5f08884cbab6787f6d84
parentb59d8988174e0af06b0ec614b077800171bc139b (diff)
downloadlayman-bce27850d7e2d86e1b8046be8eb1d51c83dbdd2c.tar.gz
layman-bce27850d7e2d86e1b8046be8eb1d51c83dbdd2c.tar.bz2
layman-bce27850d7e2d86e1b8046be8eb1d51c83dbdd2c.zip
fix an encode error regression in python 2 introduced in the py2, py3 compatibility changes.
-rw-r--r--layman/db.py6
1 files 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()