diff --git a/buffer/__init__.py b/buffer/__init__.py index 5189e22..f00cc58 100644 --- a/buffer/__init__.py +++ b/buffer/__init__.py @@ -640,7 +640,8 @@ class FileBuffer(Buffer): f.close() self.store_checksum(data) data = self.read_filter(data) - self.codec = chardet.detect(data)['encoding'].lower() + codec = chardet.detect(data)['encoding'] or 'utf-8' + self.codec = codec.lower() else: data = '' self.codec = 'utf-8'