diff --git a/doc/source/release.rst b/doc/source/release.rst index ae76324c0e848..18d5939d909ed 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -294,6 +294,8 @@ pandas 0.12 - ``Series.hist`` will now take the figure from the current environment if one is not passed - Fixed bug where a 1xN DataFrame would barf on a 1xN mask (:issue:`4071`) + - Fixed running of ``tox`` under python3 where the pickle import was getting + rewritten in an incompatible way (:issue:`4062`, :issue:`4063`) pandas 0.11.0 diff --git a/doc/source/v0.12.0.txt b/doc/source/v0.12.0.txt index 2a5847af4ed1d..b9fbc4d9cf806 100644 --- a/doc/source/v0.12.0.txt +++ b/doc/source/v0.12.0.txt @@ -437,6 +437,8 @@ Bug Fixes - ``Series.hist`` will now take the figure from the current environment if one is not passed - Fixed bug where a 1xN DataFrame would barf on a 1xN mask (:issue:`4071`) + - Fixed running of ``tox`` under python3 where the pickle import was getting + rewritten in an incompatible way (:issue:`4062`, :issue:`4063`) See the :ref:`full release notes ` or issue tracker diff --git a/pandas/io/pickle.py b/pandas/io/pickle.py index a01771dda1f25..765c0cd46d4e5 100644 --- a/pandas/io/pickle.py +++ b/pandas/io/pickle.py @@ -1,8 +1,5 @@ -# XXX: HACK for NumPy 1.5.1 to suppress warnings -try: - import cPickle as pickle -except ImportError: # pragma: no cover - import pickle +import cPickle as pkl + def to_pickle(obj, path): """ @@ -14,11 +11,9 @@ def to_pickle(obj, path): path : string File path """ - f = open(path, 'wb') - try: - pickle.dump(obj, f, protocol=pickle.HIGHEST_PROTOCOL) - finally: - f.close() + with open(path, 'wb') as f: + pkl.dump(obj, f, protocol=pkl.HIGHEST_PROTOCOL) + def read_pickle(path): """ @@ -38,11 +33,11 @@ def read_pickle(path): unpickled : type of object stored in file """ try: - with open(path,'rb') as fh: - return pickle.load(fh) + with open(path, 'rb') as fh: + return pkl.load(fh) except: - from pandas.util import py3compat - if not py3compat.PY3: - raise - with open(path,'rb') as fh: - return pickle.load(fh, encoding='latin1') \ No newline at end of file + from pandas.util.py3compat import PY3 + if PY3: + with open(path, 'rb') as fh: + return pkl.load(fh, encoding='latin1') + raise diff --git a/tox_prll.sh b/tox_prll.sh index 910e49b6b5a80..a426d68297ac5 100755 --- a/tox_prll.sh +++ b/tox_prll.sh @@ -25,3 +25,4 @@ for e in $ENVS; do echo "[launching tox for $e]" tox -c "$TOX_INI_PAR" -e "$e" & done +wait