Skip to content

Commit

Permalink
merge upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nchammas committed Aug 4, 2014
1 parent 91b7584 commit 7b4750e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/pyspark/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,11 @@ def __reduce__(self):

def _hijack_namedtuple():
""" Hack namedtuple() to make it picklable """
global _old_namedtuple # or it will put in closure
# hijack only one time
if hasattr(collections.namedtuple, "__hijack"):
return

global _old_namedtuple # or it will put in closure
def _copy_func(f):
return types.FunctionType(f.func_code, f.func_globals, f.func_name,
f.func_defaults, f.func_closure)
Expand All @@ -318,6 +321,7 @@ def namedtuple(name, fields, verbose=False, rename=False):
collections.namedtuple.func_globals["_old_namedtuple"] = _old_namedtuple
collections.namedtuple.func_globals["_hack_namedtuple"] = _hack_namedtuple
collections.namedtuple.func_code = namedtuple.func_code
collections.namedtuple.__hijack = 1

# hack the cls already generated by namedtuple
# those created in other module can be pickled as normal,
Expand Down

0 comments on commit 7b4750e

Please sign in to comment.