Skip to content

BUG: compat_pickle should not modify global namespace #5661

New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pandas/compat/pickle_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import numpy as np
import pandas
import copy
import pickle as pkl
from pandas import compat
from pandas.compat import u, string_types
Expand All @@ -29,7 +30,7 @@ def load_reduce(self):
except:

# try to reencode the arguments
if self.encoding is not None:
if getattr(self,'encoding',None) is not None:
args = tuple([arg.encode(self.encoding)
if isinstance(arg, string_types)
else arg for arg in args])
Expand All @@ -39,7 +40,7 @@ def load_reduce(self):
except:
pass

if self.is_verbose:
if getattr(self,'is_verbose',None):
print(sys.exc_info())
print(func, args)
raise
Expand All @@ -53,6 +54,7 @@ class Unpickler(pkl._Unpickler):
class Unpickler(pkl.Unpickler):
pass

Unpickler.dispatch = copy.copy(Unpickler.dispatch)
Unpickler.dispatch[pkl.REDUCE[0]] = load_reduce


Expand Down