File tree 3 files changed +13
-8
lines changed
3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -293,6 +293,7 @@ pandas 0.11.0
293
293
- fixed pretty priniting of sets (GH3294 _)
294
294
- Panel() and Panel.from_dict() now respects ordering when give OrderedDict (GH3303 _)
295
295
- DataFrame where with a datetimelike incorrectly selecting (GH3311 _)
296
+ - Ensure pickles created in py2 can be read in py3
296
297
297
298
.. _GH3294 : https://github.com/pydata/pandas/issues/3294
298
299
.. _GH622 : https://github.com/pydata/pandas/issues/622
Original file line number Diff line number Diff line change @@ -1575,12 +1575,12 @@ def load(path):
1575
1575
-------
1576
1576
unpickled : type of object stored in file
1577
1577
"""
1578
- f = open (path , 'rb' )
1579
1578
try :
1580
- return pickle .load (f )
1581
- finally :
1582
- f .close ()
1583
-
1579
+ with open (path ,'rb' ) as fh :
1580
+ return pickle .load (fh )
1581
+ except :
1582
+ with open (path ,'rb' ) as fh :
1583
+ return pickle .load (fh , encoding = 'latin1' )
1584
1584
1585
1585
class UTF8Recoder :
1586
1586
"""
Original file line number Diff line number Diff line change @@ -22,9 +22,13 @@ def setUp(self):
22
22
23
23
def compare (self , vf ):
24
24
25
- fh = open (vf ,'rb' )
26
- data = pickle .load (fh )
27
- fh .close ()
25
+ # py3 compat when reading py2 pickle
26
+ try :
27
+ with open (vf ,'rb' ) as fh :
28
+ data = pickle .load (fh )
29
+ except :
30
+ with open (vf ,'rb' ) as fh :
31
+ data = pickle .load (fh , encoding = 'latin1' )
28
32
29
33
for typ , dv in data .items ():
30
34
for dt , result in dv .items ():
You can’t perform that action at this time.
0 commit comments