Skip to content

Commit

Permalink
Add __setstate__ to fix pickling test fail
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesls committed Apr 1, 2016
1 parent 477d8f4 commit d93ae35
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions boto/pyami/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ def __init__(self, path=None, fp=None, do_load=True):
except IOError:
warnings.warn('Unable to load AWS_CREDENTIAL_FILE (%s)' % full_path)

def __setstate__(self, state):
# There's test that verify that (transitively) a Config
# object can be pickled. Now that we're storing a _parser
# attribute and relying on __getattr__ to proxy requests,
# we need to implement setstate to ensure we don't get
# into recursive loops when looking up _parser when
# this object is unpickled.
self._parser = state['_parser']

def __getattr__(self, name):
return getattr(self._parser, name)

Expand Down

0 comments on commit d93ae35

Please sign in to comment.