Github user BryanCutler commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20373#discussion_r163420703
  
    --- Diff: python/pyspark/cloudpickle.py ---
    @@ -608,37 +620,18 @@ def save_global(self, obj, name=None, 
pack=struct.pack):
             The name of this method is somewhat misleading: all types get
             dispatched here.
             """
    -        if obj.__module__ == "__builtin__" or obj.__module__ == "builtins":
    -            if obj in _BUILTIN_TYPE_NAMES:
    -                return self.save_reduce(_builtin_type, 
(_BUILTIN_TYPE_NAMES[obj],), obj=obj)
    -
    -        if name is None:
    -            name = obj.__name__
    -
    -        modname = getattr(obj, "__module__", None)
    -        if modname is None:
    -            try:
    -                # whichmodule() could fail, see
    -                # 
https://bitbucket.org/gutworth/six/issues/63/importing-six-breaks-pickling
    -                modname = pickle.whichmodule(obj, name)
    -            except Exception:
    -                modname = '__main__'
    -
    -        if modname == '__main__':
    -            themodule = None
    -        else:
    -            __import__(modname)
    -            themodule = sys.modules[modname]
    -            self.modules.add(themodule)
    +        try:
    +            return Pickler.save_global(self, obj, name=name)
    +        except Exception:
    +            if obj.__module__ == "__builtin__" or obj.__module__ == 
"builtins":
    +                if obj in _BUILTIN_TYPE_NAMES:
    +                    return self.save_reduce(_builtin_type, 
(_BUILTIN_TYPE_NAMES[obj],), obj=obj)
    --- End diff --
    
    Some cleanups, fix memoryview support 
https://github.com/cloudpipe/cloudpickle/commit/f8187e90aed7e1b96ffaae85cdf4b37108c75d3f


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to