diff -urN Twisted-10.0.0.orig/twisted/spread/jelly.py Twisted-10.0.0/twisted/spread/jelly.py
|
old
|
new
|
|
| 154 | 154 | unjellyableRegistry = {} |
| 155 | 155 | unjellyableFactoryRegistry = {} |
| 156 | 156 | |
| | 157 | NO_STATE=object() |
| 157 | 158 | |
| 158 | | |
| 159 | | def _newInstance(cls, state): |
| | 159 | def _newInstance(cls, state=NO_STATE): |
| 160 | 160 | """ |
| 161 | 161 | Make a new instance of a class without calling its __init__ method. |
| 162 | 162 | 'state' will be used to update inst.__dict__ . Supports both new- and |
| … |
… |
|
| 165 | 165 | if not isinstance(cls, types.ClassType): |
| 166 | 166 | # new-style |
| 167 | 167 | 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 |
| 169 | 171 | else: |
| 170 | | inst = instance(cls, state) |
| | 172 | if state is not NO_STATE: |
| | 173 | inst = instance(cls, state) |
| | 174 | else: |
| | 175 | inst = instance(cls) |
| 171 | 176 | return inst |
| 172 | 177 | |
| 173 | 178 | |
| … |
… |
|
| 675 | 680 | if not self.taster.isClassAllowed(clz): |
| 676 | 681 | raise InsecureJelly("Class %s not allowed." % jelType) |
| 677 | 682 | if hasattr(clz, "__setstate__"): |
| 678 | | ret = _newInstance(clz, {}) |
| | 683 | ret = _newInstance(clz) |
| 679 | 684 | state = self.unjelly(obj[1]) |
| 680 | 685 | ret.__setstate__(state) |
| 681 | 686 | else: |