|
16 | 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17 | 17 | # See the License for the specific language governing permissions and |
18 | 18 | # limitations under the License. |
19 | | -from .util import UnicodeMixin, ImmutableMixin |
| 19 | +from .util import UnicodeMixin, ImmutableMixin, mutating_method |
20 | 20 |
|
21 | 21 |
|
22 | 22 | class CountryCodeSource(object): |
@@ -215,13 +215,10 @@ def __hash__(self): |
215 | 215 | self.country_code_source, |
216 | 216 | self.preferred_domestic_carrier_code)) |
217 | 217 |
|
| 218 | + @mutating_method |
218 | 219 | def __init__(self, *args, **kwargs): |
219 | | - old_mutable = self._mutable |
220 | | - self._mutable = True |
221 | | - try: |
222 | | - if len(kwargs) == 0 and len(args) == 1 and isinstance(args[0], PhoneNumber): |
223 | | - super(FrozenPhoneNumber, self).__init__(**args[0].__dict__) |
224 | | - else: |
225 | | - super(FrozenPhoneNumber, self).__init__(*args, **kwargs) |
226 | | - finally: |
227 | | - self._mutable = old_mutable |
| 220 | + if len(kwargs) == 0 and len(args) == 1 and isinstance(args[0], PhoneNumber): |
| 221 | + # Copy constructor |
| 222 | + super(FrozenPhoneNumber, self).__init__(**args[0].__dict__) |
| 223 | + else: |
| 224 | + super(FrozenPhoneNumber, self).__init__(*args, **kwargs) |
0 commit comments