Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Given an input object that is a function, generate a string of the
- # form
- # "__pyrelFunctionPointer__:object ID:function name".
- def makeFunctionString(self, obj):
- # The im_self field on functions contains the object the function
- # is bound to.
- obj = key.im_self
- if not hasattr(obj, 'id'):
- # We can only serialize functions if they are bound to objects
- # that we are also serializing.
- raise RuntimeError("Tried to serialize a function bound to an object with no ID: %s" % str(obj))
- boundId = obj.id
- if boundId not in self.objectToId:
- # Unrecognized object ID. raise RuntimeError("Tried to serialize a function bound to object with unknown ID %s" % boundID)
- ## The __name__ field is the function's name in string form.
- funcName = obj.__name__
- return "__pyrelFunctionPointer:%s:%s" % (boundId, funcName)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement