Ticket #4430: slots-solution.patch

File slots-solution.patch, 1.4 KB (added by toidinamai, 7 years ago)

implementation for the new test case

  • twisted/spread/jelly.py

    diff -urN Twisted-10.0.0.orig/twisted/spread/jelly.py Twisted-10.0.0/twisted/spread/jelly.py
    old new  
    154154unjellyableRegistry = {}
    155155unjellyableFactoryRegistry = {}
    156156
     157NO_STATE=object()
    157158
    158 
    159 def _newInstance(cls, state):
     159def _newInstance(cls, state=NO_STATE):
    160160    """
    161161    Make a new instance of a class without calling its __init__ method.
    162162    'state' will be used to update inst.__dict__ . Supports both new- and
     
    165165    if not isinstance(cls, types.ClassType):
    166166        # new-style
    167167        inst = cls.__new__(cls)
    168         inst.__dict__.update(state) # Copy 'instance' behaviour
     168
     169        if state is not NO_STATE:
     170            inst.__dict__.update(state) # Copy 'instance' behaviour
    169171    else:
    170         inst = instance(cls, state)
     172        if state is not NO_STATE:
     173            inst = instance(cls, state)
     174        else:   
     175            inst = instance(cls)
    171176    return inst
    172177
    173178
     
    675680            if not self.taster.isClassAllowed(clz):
    676681                raise InsecureJelly("Class %s not allowed." % jelType)
    677682            if hasattr(clz, "__setstate__"):
    678                 ret = _newInstance(clz, {})
     683                ret = _newInstance(clz)
    679684                state = self.unjelly(obj[1])
    680685                ret.__setstate__(state)
    681686            else: