Skip to content

Commit

Permalink
Catch exceptions from yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
eacharles committed Jul 9, 2019
1 parent 15a0522 commit af36e24
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dmsky/utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def yaml_load(filename):
raise Exception('File does not exist: %s' % (filename))
try:
ret = yaml.load(open(filename), Loader=yaml.CLoader)
except IOError:
except (IOError, AttributeError):
ret = yaml.load(open(filename), Loader=yaml.Loader)
return ret

Expand All @@ -33,7 +33,7 @@ def yaml_dump(x, filename):

try:
out.write(yaml.dump(x, Dumper=yaml.CDumper))
except IOError:
except (IOError, AttributeError):
out.write(yaml.dump(x, Dumper=yaml.Dumper))
out.close()

Expand Down

0 comments on commit af36e24

Please sign in to comment.