Loading diffoscope/readers/__init__.py +3 −1 Original line number Diff line number Diff line Loading @@ -17,12 +17,14 @@ # You should have received a copy of the GNU General Public License # along with diffoscope. If not, see <https://www.gnu.org/licenses/>. import codecs from .json import JSONReaderV1 def load_diff_from_path(path): with open(path, 'rb') as fp: return load_diff(fp, path) return load_diff(codecs.getreader('utf-8')(fp), path) def load_diff(fp, path): Loading diffoscope/readers/json.py +3 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ # along with diffoscope. If not, see <https://www.gnu.org/licenses/>. import json import codecs from ..difference import Difference from ..presenters.json import JSON_FORMAT_MAGIC Loading @@ -28,7 +27,9 @@ from .utils import UnrecognizedFormatError class JSONReaderV1(object): def load(self, fp, fn): raw = json.load(codecs.getreader('utf-8')(fp)) # fp should be a str-stream not a bytes-stream. If you need to pass in # a bytes-stream, wrap it in codecs.getreader('utf-8')(fp) raw = json.load(fp) if JSON_FORMAT_MAGIC not in raw or raw[JSON_FORMAT_MAGIC] != 1: raise UnrecognizedFormatError( "Magic not found in JSON: {}".format(JSON_FORMAT_MAGIC) Loading Loading
diffoscope/readers/__init__.py +3 −1 Original line number Diff line number Diff line Loading @@ -17,12 +17,14 @@ # You should have received a copy of the GNU General Public License # along with diffoscope. If not, see <https://www.gnu.org/licenses/>. import codecs from .json import JSONReaderV1 def load_diff_from_path(path): with open(path, 'rb') as fp: return load_diff(fp, path) return load_diff(codecs.getreader('utf-8')(fp), path) def load_diff(fp, path): Loading
diffoscope/readers/json.py +3 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ # along with diffoscope. If not, see <https://www.gnu.org/licenses/>. import json import codecs from ..difference import Difference from ..presenters.json import JSON_FORMAT_MAGIC Loading @@ -28,7 +27,9 @@ from .utils import UnrecognizedFormatError class JSONReaderV1(object): def load(self, fp, fn): raw = json.load(codecs.getreader('utf-8')(fp)) # fp should be a str-stream not a bytes-stream. If you need to pass in # a bytes-stream, wrap it in codecs.getreader('utf-8')(fp) raw = json.load(fp) if JSON_FORMAT_MAGIC not in raw or raw[JSON_FORMAT_MAGIC] != 1: raise UnrecognizedFormatError( "Magic not found in JSON: {}".format(JSON_FORMAT_MAGIC) Loading