# HG changeset patch # User Sean Farley # Date 1392765569 21600 # Node ID 91d6854184904f20f9c785b6594d4a2a637eec65 # Parent 56f426d0261f679429615ff7a3b6fde4924de6f7 util: fallback to raw string reading if pickle fails This is the next step for getting rid of all the random read and write functions throughout hgsubversion. diff --git a/hgsubversion/util.py b/hgsubversion/util.py --- a/hgsubversion/util.py +++ b/hgsubversion/util.py @@ -169,8 +169,14 @@ def load(file_path, default=None, resave 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 - data = compathacks.pickle_load(f) + try: + # Ok, JSON couldn't be loaded, so we'll try the old way of using pickle + data = compathacks.pickle_load(f) + except: + # well, pickle didn't work either, so we reset the file pointer and + # read the string + f.seek(0) + data = f.read() # convert the file to json immediately f.close()