Commit 2706fa6
committed
MNT: make _setattr_cm more forgiving
Our attempts to identify the set of cases we wanted to support did not
correctly capture all relevant cases. This tries to simplify the
logic:
- if the attribute is in the instance dict, stash and restore it via
setattr at the end
- if the attribute is not on the object, delete it with delattr at
the end
- if the object has the attribute, but it is not in the instance
dict:
- if it is a property, stash and restore the old value
- in all other cases assume that setattr will put the value in the
instance dict and delattr will do what we want on the way out
closes #176461 parent 4249e18 commit 2706fa6
2 files changed
Lines changed: 32 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2035 | 2035 | | |
2036 | 2036 | | |
2037 | 2037 | | |
2038 | | - | |
2039 | 2038 | | |
| 2039 | + | |
| 2040 | + | |
2040 | 2041 | | |
2041 | 2042 | | |
| 2043 | + | |
| 2044 | + | |
2042 | 2045 | | |
| 2046 | + | |
| 2047 | + | |
2043 | 2048 | | |
2044 | 2049 | | |
2045 | | - | |
2046 | | - | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
2047 | 2058 | | |
2048 | | - | |
2049 | | - | |
2050 | | - | |
2051 | | - | |
| 2059 | + | |
2052 | 2060 | | |
2053 | 2061 | | |
2054 | 2062 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
669 | 677 | | |
670 | 678 | | |
671 | 679 | | |
| |||
696 | 704 | | |
697 | 705 | | |
698 | 706 | | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
699 | 711 | | |
700 | 712 | | |
701 | 713 | | |
| |||
705 | 717 | | |
706 | 718 | | |
707 | 719 | | |
708 | | - | |
| 720 | + | |
| 721 | + | |
709 | 722 | | |
710 | 723 | | |
711 | 724 | | |
| |||
715 | 728 | | |
716 | 729 | | |
717 | 730 | | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
718 | 734 | | |
719 | 735 | | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
| |||
0 commit comments