Skip to content
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

str.upper is not picklable under PyPy3 #50

Closed
ogrisel opened this issue Jan 19, 2016 · 1 comment
Closed

str.upper is not picklable under PyPy3 #50

ogrisel opened this issue Jan 19, 2016 · 1 comment
Labels

Comments

@ogrisel
Copy link
Contributor

ogrisel commented Jan 19, 2016

Report from the failing test ran with the PyPy3 environment configured by tox (not available on travis-ci):

__________________________________________________________________________________ CloudPickleTest.test_method_descriptors __________________________________________________________________________________

self = <tests.cloudpickle_test.CloudPickleTest testMethod=test_method_descriptors>

    def test_method_descriptors(self):
>       f = pickle_depickle(str.upper)

tests/cloudpickle_test.py:241: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/cloudpickle_test.py:37: in pickle_depickle
    return pickle.loads(cloudpickle.dumps(obj))
cloudpickle/cloudpickle.py:605: in dumps
    cp.dump(obj)
cloudpickle/cloudpickle.py:107: in dump
    return Pickler.dump(self, obj)
../../opt/pypy3/lib-python/3/pickle.py:237: in dump
    self.save(obj)
../../opt/pypy3/lib-python/3/pickle.py:299: in save
    f(self, obj) # Call unbound method with explicit self
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <cloudpickle.cloudpickle.CloudPickler object at 0x0000000004568560>, obj = <function upper at 0x0000000001a32fc0>, name = 'upper'

    def save_function(self, obj, name=None):
        """ Registered with the dispatch to handle all function types.

            Determines what kind of function obj is (e.g. lambda, defined at
            interactive prompt, etc) and handles the pickling appropriately.
            """
        write = self.write

        if name is None:
            name = obj.__name__
        modname = pickle.whichmodule(obj, name)
        # print('which gives %s %s %s' % (modname, obj, name))
        try:
            themodule = sys.modules[modname]
        except KeyError:
            # eval'd items such as namedtuple give invalid items for their function __module__
            modname = '__main__'

        if modname == '__main__':
            themodule = None

        if themodule:
            self.modules.add(themodule)
            if getattr(themodule, name, None) is obj:
                return self.save_global(obj, name)

        # if func is lambda, def'ed at prompt, is in main, or is nested, then
        # we'll pickle the actual function object rather than simply saving a
        # reference (as is done in default pickler), via save_function_tuple.
>       if islambda(obj) or obj.__code__.co_filename == '<stdin>' or themodule is None:
E       AttributeError: 'builtin-code' object has no attribute 'co_filename'
@llllllllll
Copy link
Contributor

fixed in #51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants