Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.
Ticket #2430: lazy-param-initialization.patch
| File lazy-param-initialization.patch,
2.2 KB
(added by xaka, 2 years ago) |
|
|
-
|
old
|
new
|
|
| 187 | 187 | if param in params: |
| 188 | 188 | # make sure we don't keep references to mutables |
| 189 | 189 | setattr(self, param, copy_if_mutable(params.pop(param))) |
| 190 | | |
| 191 | 190 | else: |
| 192 | | if hasattr(self, param): |
| 193 | | # make sure we don't alter mutable class attributes |
| 194 | | value = copy_if_mutable(getattr(self.__class__, param), |
| 195 | | True) |
| 196 | | if value[1]: |
| 197 | | # re-set it only if mutable |
| 198 | | setattr(self, param, value[0]) |
| 199 | | else: |
| 200 | | setattr(self, param, None) |
| | 191 | # make sure we don't alter mutable class attributes |
| | 192 | value = copy_if_mutable(getattr(self.__class__, param), True) |
| | 193 | if value[1]: |
| | 194 | # re-set it only if mutable |
| | 195 | setattr(self, param, value[0]) |
| 201 | 196 | |
| 202 | 197 | for unused in params.iterkeys(): |
| 203 | 198 | warnings.warn('keyword argument "%s" is unused at %r instance' % ( |
-
|
old
|
new
|
|
| 59 | 59 | dct[param] = ParamDescriptor(param) |
| 60 | 60 | except KeyError: |
| 61 | 61 | # declared in a superclass, skip it... |
| 62 | | pass |
| | 62 | if [base for base in bases if hasattr(base, param)]: |
| | 63 | continue |
| | 64 | |
| | 65 | # not declared anywhere and because set it |
| | 66 | # by default to None |
| | 67 | dct[param_prefix+param] = None |
| | 68 | dct[param] = ParamDescriptor(param) |
| 63 | 69 | params = list(params) |
| 64 | 70 | dct['params'] = params |
| 65 | 71 | #XXX: Remove when deprecation is effective |
Download in other formats: