Commit 56ea69b
committed
Fix function attribute tests: __defaults__ del, __code__ free vars check, bound method dir()
- Support `del func.__defaults__` and `del func.__kwdefaults__` by changing
setter signatures to `PySetterValue<Option<...>>` so Delete is treated as
setting the value to None (matching CPython behaviour)
- Validate free-variable count when assigning to `func.__code__`: raise
ValueError when the new code object's freevars count doesn't match the
existing closure size
- Add `__dir__` to `PyBoundMethod` that delegates to the underlying
function's dir(), so attributes set on the function show up in
`dir(bound_method)`
- Remove `@unittest.expectedFailure` from the four tests that now pass:
test_blank_func_defaults, test_func_default_args, test___code__,
test_dir_includes_correct_attrs1 parent e79df4a commit 56ea69b
2 files changed
Lines changed: 29 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
| |||
238 | 237 | | |
239 | 238 | | |
240 | 239 | | |
241 | | - | |
242 | 240 | | |
243 | 241 | | |
244 | 242 | | |
| |||
269 | 267 | | |
270 | 268 | | |
271 | 269 | | |
272 | | - | |
273 | 270 | | |
274 | 271 | | |
275 | 272 | | |
276 | 273 | | |
277 | 274 | | |
278 | | - | |
279 | 275 | | |
280 | 276 | | |
281 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
788 | 788 | | |
789 | 789 | | |
790 | 790 | | |
791 | | - | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
792 | 802 | | |
793 | 803 | | |
794 | 804 | | |
| |||
797 | 807 | | |
798 | 808 | | |
799 | 809 | | |
| 810 | + | |
800 | 811 | | |
801 | 812 | | |
802 | 813 | | |
803 | 814 | | |
804 | 815 | | |
805 | 816 | | |
806 | 817 | | |
807 | | - | |
808 | | - | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
809 | 823 | | |
810 | 824 | | |
811 | 825 | | |
| |||
814 | 828 | | |
815 | 829 | | |
816 | 830 | | |
817 | | - | |
818 | | - | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
819 | 836 | | |
820 | 837 | | |
821 | 838 | | |
| |||
1308 | 1325 | | |
1309 | 1326 | | |
1310 | 1327 | | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
1311 | 1333 | | |
1312 | 1334 | | |
1313 | 1335 | | |
| |||
0 commit comments