Commit e9ce6176 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Pickle extension functions and instances

parent d1f7e31b
......@@ -651,6 +651,8 @@ class Pickler:
dispatch[DictionaryType] = save_dict
if not PyStringMap is None:
dispatch[PyStringMap] = save_dict
# Pyston change:
dispatch[AttrwrapperType] = save_dict
def _batch_setitems(self, items):
# Helper to batch up SETITEMS sequences; proto >= 1 only
......@@ -772,6 +774,11 @@ class Pickler:
dispatch[BuiltinFunctionType] = save_global
dispatch[TypeType] = save_global
# Pyston change: extension functions have a different type from our
# builtin functions (which is BuiltinFunctionType):
import math
dispatch[type(math.sin)] = save_global
# Pickling helpers
def _keep_alive(x, memo):
......
......@@ -81,6 +81,9 @@ EllipsisType = type(Ellipsis)
# DictProxyType = type(TypeType.__dict__)
NotImplementedType = type(NotImplemented)
# Pyston change:
AttrwrapperType = type(_C().__dict__)
# For Jython, the following two types are identical
# Pyston change: don't support these yet
# GetSetDescriptorType = type(FunctionType.func_code)
......
......@@ -10,3 +10,15 @@ l3 = l2.pop()
print l2, l3, l2 is l3
print pickle.loads(pickle.dumps("hello world"))
# Sqlalchemy wants this:
import operator
print repr(pickle.dumps(len))
print repr(pickle.dumps(operator.and_))
class C(object):
pass
c = C()
c.a = 1
print repr(pickle.dumps(c))
print pickle.loads(pickle.dumps(c)).a
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment