Skip to content

Commit

Permalink
Fix CloudpickleWrapper load-save asymmetry (#935)
Browse files Browse the repository at this point in the history
* Fix CloudpickleWrapper load-save asymmetry

CloudpickleWrapper loads using `pickle.loads`, and saves using `cloudpickle.dumps`. Using this codepath would lead to protocol error before this commit, since `pickle.loads` can't read `cloudpickle.dumps`.

* Update changelog

* Update changelog.rst

Co-authored-by: Anssi <kaneran21@hotmail.com>
  • Loading branch information
shwang and Miffyli committed Jul 9, 2020
1 parent 9ce4155 commit c54dc5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/misc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Bug Fixes:
- Fixed a bug ``callback.locals`` did not have the correct values (@PartiallyTyped)
- Fixed a bug in the ``close()`` method of ``SubprocVecEnv``, causing wrappers further down in the wrapper stack to not be closed. (@NeoExtended)
- Fixed a bug in the ``generate_expert_traj()`` method in ``record_expert.py`` when using a non-image vectorized environment (@jbarsce)
- Fixed a bug in CloudPickleWrapper's (used by VecEnvs) ``__setstate___`` where loading was incorrectly using ``pickle.loads`` (@shwang).


Deprecations:
Expand Down Expand Up @@ -716,4 +717,4 @@ Thanks to @bjmuld @iambenzo @iandanforth @r7vme @brendenpetersen @huvar @abhiskk
@Miffyli @dwiel @miguelrass @qxcv @jaberkow @eavelardev @ruifeng96150 @pedrohbtp @srivatsankrishnan @evilsocket
@MarvineGothic @jdossgollin @SyllogismRXS @rusu24edward @jbulow @Antymon @seheevic @justinkterry @edbeeching
@flodorner @KuKuXia @NeoExtended @PartiallyTyped @mmcenta @richardwu @tirafesi @caburu @johannes-dornheim @kvenkman @aakash94
@enderdead @hardmaru @jbarsce @ColinLeongUDRI
@enderdead @hardmaru @jbarsce @ColinLeongUDRI @shwang
2 changes: 1 addition & 1 deletion stable_baselines/common/vec_env/base_vec_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,4 @@ def __getstate__(self):
return cloudpickle.dumps(self.var)

def __setstate__(self, obs):
self.var = pickle.loads(obs)
self.var = cloudpickle.loads(obs)

0 comments on commit c54dc5d

Please sign in to comment.