Skip to content

Commit

Permalink
Merge pull request Yelp#555 from davidmarin/just_use_value_error
Browse files Browse the repository at this point in the history
Just use value error
  • Loading branch information
irskep committed Aug 28, 2012
2 parents 8b536c0 + 692b6ba commit fb4b547
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions mrjob/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@

try:
import simplejson as json # preferred because of C speedups
JSONDecodeError = json.JSONDecodeError
except ImportError:
import json # built in to Python 2.6 and later
JSONDecodeError = ValueError

# yaml is nice to have, but we can fall back on JSON if need be
try:
Expand Down Expand Up @@ -165,11 +163,10 @@ def conf_object_at_path(conf_path):
else:
try:
return json.load(f)
except JSONDecodeError, e:
except ValueError, e:
msg = ('If your mrjob.conf is in YAML, you need to install'
' yaml; see http://pypi.python.org/pypi/PyYAML/')
# JSONDecodeError currently has a msg attr, but it may not in
# the future
# Use msg attr if it's set
if hasattr(e, 'msg'):
e.msg = '%s (%s)' % (e.msg, msg)
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def test_json_error(self):
try:
load_mrjob_conf(conf_path)
assert False
except mrjob.conf.JSONDecodeError, e:
except ValueError, e:
self.assertIn('If your mrjob.conf is in YAML', e.msg)


Expand Down

0 comments on commit fb4b547

Please sign in to comment.