Message328999
I'm not convinced that any change is needed, this is completely expected behaviour (and not special to modules).
The following code also raises RecursionError:
class VerboseObject:
def __setattr__(self, nm, value):
print(f"Setting {nm} to {value}")
setattr(self, nm, value)
o = VerboseObject()
o.a = 42
This is because setattr() calls the __setattr__ method, which calls setattr() again, ... .
The fix is to call super().__setattr__ instead:
class VerboseObject:
def __setattr__(self, nm, value):
print(f"Setting {nm} to {value}")
super().__setattr__(nm, value)
o = VerboseObject()
o.a = 42 |
|
Date |
User |
Action |
Args |
2018-10-31 15:59:07 | ronaldoussoren | set | recipients:
+ ronaldoussoren, docs@python, levkivskyi, denis-osipov, xtreak |
2018-10-31 15:59:07 | ronaldoussoren | set | messageid: <1541001547.24.0.788709270274.issue35119@psf.upfronthosting.co.za> |
2018-10-31 15:59:07 | ronaldoussoren | link | issue35119 messages |
2018-10-31 15:59:07 | ronaldoussoren | create | |
|