# HG changeset patch # User Sean Farley # Date 1392480553 21600 # Node ID ad4cb902593e68695016be7c9d4f471179beebd5 # Parent 6e4892b6628a14608e8515c9cd3fcb021bf25b40 util: convert pickle to json If we fallback to loading data with pickle, then we immediately save the data in json format to avoid any pickling in the future. diff --git a/hgsubversion/util.py b/hgsubversion/util.py --- a/hgsubversion/util.py +++ b/hgsubversion/util.py @@ -189,11 +189,15 @@ def load(file_path): f = open(file_path) try: data = _convert(json.load(f), _descrub) + f.close() except ValueError: # Ok, JSON couldn't be loaded, so we'll try the old way of using pickle f.seek(0) data = pickle.load(f) - f.close() + + # convert the file to json immediately + f.close() + dump(data, file_path) return data def parseurl(url, heads=[]):