mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
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.
This commit is contained in:
parent
d86829e2cd
commit
dbf5c6edc1
@ -169,8 +169,14 @@ def load(file_path, default=None, resave=True):
|
|||||||
data = _convert(json.load(f), _descrub)
|
data = _convert(json.load(f), _descrub)
|
||||||
f.close()
|
f.close()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# Ok, JSON couldn't be loaded, so we'll try the old way of using pickle
|
try:
|
||||||
data = compathacks.pickle_load(f)
|
# 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
|
# convert the file to json immediately
|
||||||
f.close()
|
f.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user