Properly serialize UnsafeProxy objects
Required as part of fix for #12123
This commit is contained in:
parent
a410bf26d3
commit
95a58d1178
1 changed files with 20 additions and 7 deletions
|
@ -61,13 +61,22 @@ class UnsafeProxy(object):
|
|||
def __getattribute__(self, name):
|
||||
if name == '_obj':
|
||||
return object.__getattribute__(self, "_obj")
|
||||
elif name == '__reduce_ex__':
|
||||
return object.__getattribute__(self, "__reduce_ex__")
|
||||
elif name == '__UNSAFE__':
|
||||
return True
|
||||
else:
|
||||
return getattr(object.__getattribute__(self, "_obj"), name)
|
||||
|
||||
def __eq__(self, obj):
|
||||
'''
|
||||
special handling for == due to the fact that int objects do
|
||||
not define it, so trying to guess whether we should or should
|
||||
not override object.__eq__ with the wrapped classes version
|
||||
causes problems
|
||||
'''
|
||||
return object.__getattribute__(self, "_obj") == obj
|
||||
|
||||
def __delattr__(self, name):
|
||||
delattr(object.__getattribute__(self, "_obj"), name)
|
||||
def __setattr__(self, name, value):
|
||||
|
@ -76,12 +85,17 @@ class UnsafeProxy(object):
|
|||
def __nonzero__(self):
|
||||
return bool(object.__getattribute__(self, "_obj"))
|
||||
def __str__(self):
|
||||
#import epdb; epdb.st()
|
||||
return str(object.__getattribute__(self, "_obj"))
|
||||
def __unicode__(self):
|
||||
#import epdb; epdb.st()
|
||||
return unicode(object.__getattribute__(self, "_obj"))
|
||||
def __repr__(self):
|
||||
return repr(object.__getattribute__(self, "_obj"))
|
||||
|
||||
|
||||
def __reduce_ex__(self, protocol):
|
||||
return (UnsafeProxy, (self._obj,))
|
||||
|
||||
#
|
||||
# factories
|
||||
#
|
||||
|
@ -94,12 +108,11 @@ class UnsafeProxy(object):
|
|||
'__imul__', '__int__', '__invert__', '__ior__', '__ipow__', '__irshift__',
|
||||
'__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__', '__len__',
|
||||
'__long__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__',
|
||||
'__neg__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__',
|
||||
'__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__',
|
||||
'__repr__', '__reversed__', '__rfloordiv__', '__rlshift__', '__rmod__',
|
||||
'__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__',
|
||||
'__rtruediv__', '__rxor__', '__setitem__', '__setslice__', '__sub__',
|
||||
'__truediv__', '__xor__', 'next',
|
||||
'__neg__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__',
|
||||
'__rdiv__', '__rdivmod__', '__repr__', '__reversed__', '__rfloordiv__',
|
||||
'__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__',
|
||||
'__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setitem__',
|
||||
'__setslice__', '__sub__', '__truediv__', '__xor__', 'next',
|
||||
]
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in a new issue