From 2a23299f0bb515c3b3e3193fadd5f1cc18381c6a Mon Sep 17 00:00:00 2001 From: lanjelot Date: Thu, 7 May 2020 15:15:19 +1000 Subject: [PATCH] Fixes #134 --- patator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/patator.py b/patator.py index 017ca02..83e091f 100755 --- a/patator.py +++ b/patator.py @@ -967,7 +967,7 @@ if PY3: # http://python3porting.com/problems.html return x.encode('ISO-8859-1', errors='ignore') def B(x): - return x.decode(errors='ignore') + return x.decode('ISO-8859-1', errors='ignore') else: def b(x): return x @@ -1114,14 +1114,14 @@ def html_unescape(s): return h.unescape(s) def count_lines(filename): - with open(filename) as f: + with open(filename, 'rb') as f: lines = 0 buf_size = 1024 * 1024 read_f = f.read buf = read_f(buf_size) while buf: - lines += buf.count('\n') + lines += buf.count(b'\n') buf = read_f(buf_size) return lines @@ -1150,7 +1150,7 @@ class FileIter: self.filename = filename def __iter__(self): - return open(self.filename) + return open(self.filename, 'rb') def padhex(d): x = '%x' % d