aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevan Franchini <twitch153@gentoo.org>2015-03-24 12:09:01 -0400
committerDevan Franchini <twitch153@gentoo.org>2015-03-24 12:09:01 -0400
commit708276267e3d68acdaaf81a57b0f43aa132b9cc1 (patch)
tree849a95e737d15a4d7cf226199c94de6ecc6792b3
parentlayman.cfg: Adds "protocol_order" to config with example (diff)
downloadlayman-708276267e3d68acdaaf81a57b0f43aa132b9cc1.tar.gz
layman-708276267e3d68acdaaf81a57b0f43aa132b9cc1.tar.bz2
layman-708276267e3d68acdaaf81a57b0f43aa132b9cc1.zip
compatibility.py: Adds binary mode aware compatibility to fileopen()
-rw-r--r--layman/compatibility.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/layman/compatibility.py b/layman/compatibility.py
index 2ef4d8c..67ca3e6 100644
--- a/layman/compatibility.py
+++ b/layman/compatibility.py
@@ -21,7 +21,10 @@ def encode(text, enc="UTF-8"):
def fileopen(path, mode='r', enc="UTF-8"):
"""py2, py3 compatibility function"""
try:
- f = open(path, mode, encoding=enc)
+ if 'b' in mode:
+ f = open(path, mode)
+ else:
+ f = open(path, mode, encoding=enc)
except TypeError:
f = open(path, mode)
return f