From 1160eeb2569486785c0568cd84090e4029cc0747 Mon Sep 17 00:00:00 2001 From: dol-sen Date: Sun, 25 Sep 2011 18:17:11 -0700 Subject: fix a py3 failure, because the file was not opened in binary mode. --- layman/overlays/tar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'layman') diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py index 5d66acc..c6f2443 100644 --- a/layman/overlays/tar.py +++ b/layman/overlays/tar.py @@ -118,7 +118,7 @@ class TarOverlay(OverlaySource): pkg = path([base, self.parent.name + ext]) try: - out_file = open(pkg, 'w') + out_file = open(pkg, 'w+b') out_file.write(tar) out_file.close() except Exception, error: -- cgit v1.2.3-1-g7c22 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(-) (limited to 'layman') 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