Skip to content

Commit

Permalink
Merge pull request #51 from ogrisel/fix-pypy3-built-in-methods
Browse files Browse the repository at this point in the history
FIX pypy3 support for method descriptors
  • Loading branch information
ogrisel committed Jan 20, 2016
2 parents 926dd3f + 57c4846 commit e47f29f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cloudpickle/cloudpickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from __future__ import print_function

import operator
import os
import io
import pickle
import struct
Expand Down Expand Up @@ -188,8 +187,9 @@ def save_function(self, obj, name=None):
# 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:
#print("save global", islambda(obj), obj.__code__.co_filename, modname, themodule)
if (islambda(obj)
or getattr(obj.__code__, 'co_filename', None) == '<stdin>'
or themodule is None):
self.save_function_tuple(obj)
return
else:
Expand Down Expand Up @@ -249,7 +249,10 @@ def extract_code_globals(co):
"""
Find all globals names read or written to by codeblock co
"""
code = co.co_code

code = getattr(co, 'co_code', None)
if code is None:
return set()
if not PY3:
code = [ord(c) for c in code]
names = co.co_names
Expand Down

0 comments on commit e47f29f

Please sign in to comment.