You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that this is a relatively niche issue, but for example in a config system (i.e. pytorch/pytorch#140779), if you don't want to have a delete work, (i.e. have it set it back to a default value), the code in
ifnotself.createand (nothasattr(self.target, self.attribute) or
will call delattr, and then not call setattr, because it still has the attr.
Possible fixes:
If delattr throws (maybe NotImplementederror), call setattr instead (this is nice and explicit + removes the hacky workaround I have to do).
If the value after it's been deleted doesn't equal the original value, reassign it? (this might require objects to be comparable, not sure if that is already an issue here).
Either way I wanted to see if there was any interest in fixing this, and if anyone saw a solution that seemed reasonable enough.
CPython versions tested on:
3.12
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered:
Except we're not a proxy class. In particular it makes no logical sense to delete these configs. Making delattr throw on all calls probably makes more sense for the usecase, then defining it to either reset to default, or to allow deletion.
Bug report
Bug description:
Expected
Actual
Note that this is a relatively niche issue, but for example in a config system (i.e. pytorch/pytorch#140779), if you don't want to have a delete work, (i.e. have it set it back to a default value), the code in
cpython/Lib/unittest/mock.py
Line 1637 in 94a7a4e
Possible fixes:
If delattr throws (maybe NotImplementederror), call setattr instead (this is nice and explicit + removes the hacky workaround I have to do).
If the value after it's been deleted doesn't equal the original value, reassign it? (this might require objects to be comparable, not sure if that is already an issue here).
Either way I wanted to see if there was any interest in fixing this, and if anyone saw a solution that seemed reasonable enough.
CPython versions tested on:
3.12
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: