Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

TST/BUG: fix 2to3 import rewrite of import pickle #4063

Merged
merged 2 commits into from Jun 28, 2013
Jump to file or symbol
Failed to load files and symbols.
+17 −17
Split
View
@@ -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
View
@@ -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
<release>` or issue tracker
View
@@ -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')
+ from pandas.util.py3compat import PY3
+ if PY3:
+ with open(path, 'rb') as fh:
+ return pkl.load(fh, encoding='latin1')
+ raise
View
@@ -25,3 +25,4 @@ for e in $ENVS; do
echo "[launching tox for $e]"
tox -c "$TOX_INI_PAR" -e "$e" &
done
+wait