(self)
| 654 | |
| 655 | @cpython_only |
| 656 | def testSetattrWrapperNameIntern(self): |
| 657 | # Issue #25794: __setattr__ should intern the attribute name |
| 658 | class A: |
| 659 | pass |
| 660 | |
| 661 | def add(self, other): |
| 662 | return 'summa' |
| 663 | |
| 664 | name = str(b'__add__', 'ascii') # shouldn't be optimized |
| 665 | self.assertIsNot(name, '__add__') # not interned |
| 666 | type.__setattr__(A, name, add) |
| 667 | self.assertEqual(A() + 1, 'summa') |
| 668 | |
| 669 | name2 = str(b'__add__', 'ascii') |
| 670 | self.assertIsNot(name2, '__add__') |
| 671 | self.assertIsNot(name2, name) |
| 672 | type.__delattr__(A, name2) |
| 673 | with self.assertRaises(TypeError): |
| 674 | A() + 1 |
| 675 | |
| 676 | def testSetattrNonStringName(self): |
| 677 | class A: |
nothing calls this directly
no test coverage detected