always read files in binary mode

This commit is contained in:
Maximilian Hils 2013-06-16 00:30:13 +02:00
parent 9e7f08acea
commit 0382b809ea
2 changed files with 4 additions and 4 deletions

View File

@ -181,7 +181,7 @@ class RandomGenerator:
class FileGenerator:
def __init__(self, path):
self.path = path
self.fp = file(path, "r")
self.fp = file(path, "rb")
self.map = mmap.mmap(self.fp.fileno(), 0, prot=mmap.PROT_READ)
def __len__(self):
@ -957,7 +957,7 @@ def read_file(settings, s):
raise FileAccessDenied("File access outside of configured directory")
if not os.path.isfile(s):
raise FileAccessDenied("File not readable")
return file(s, "r").read()
return file(s, "rb").read()
def parse_response(settings, s):

View File

@ -95,7 +95,7 @@ class TestValueFile:
v = language.Value.parseString("<path")[0]
with tutils.tmpdir() as t:
p = os.path.join(t, "path")
f = open(p, "w")
f = open(p, "wb")
f.write("x"*10000)
f.close()
@ -143,7 +143,7 @@ class TestMisc:
def test_filegenerator(self):
with tutils.tmpdir() as t:
path = os.path.join(t, "foo")
f = open(path, "w")
f = open(path, "wb")
f.write("x"*10000)
f.close()
g = language.FileGenerator(path)