Commit e4ec46f
Make _coconut_partial a proper class with __get__ for method binding
Replace the old function-based _coconut_partial (which just wrapped
functools.partial and set __name__) with a class-based implementation
that subclasses functools.partial. The new class adds:
- __get__ descriptor support so partials work correctly as methods
when assigned as class attributes (resolves #891)
- __repr__ that delegates to functools.partial's repr for consistency
- Proper __name__ propagation via __new__
The class is defined in root.py (for both Python 2 and 3 headers) and
is now also used internally by the compiler modules (compiler.py,
grammar.py, header.py, util.py) instead of functools.partial.
Also updates remaining uses of _coconut.functools.partial in the
runtime header template to use _coconut_partial, and adds tests for
partial-as-method with both positional and keyword argument binding.
Co-Authored-By: Claude (fennec-v8-fast) <noreply@anthropic.com>1 parent bca524e commit e4ec46f
File tree
7 files changed
+58
-15
lines changed- coconut
- compiler
- templates
- tests/src/cocotest/agnostic
7 files changed
+58
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
| 32 | + | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | 69 | | |
75 | 70 | | |
76 | 71 | | |
| |||
699 | 694 | | |
700 | 695 | | |
701 | 696 | | |
702 | | - | |
| 697 | + | |
703 | 698 | | |
704 | 699 | | |
705 | 700 | | |
| |||
725 | 720 | | |
726 | 721 | | |
727 | 722 | | |
728 | | - | |
| 723 | + | |
729 | 724 | | |
730 | 725 | | |
731 | 726 | | |
| |||
2028 | 2023 | | |
2029 | 2024 | | |
2030 | 2025 | | |
2031 | | - | |
| 2026 | + | |
2032 | 2027 | | |
2033 | 2028 | | |
2034 | 2029 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
80 | 99 | | |
81 | 100 | | |
82 | 101 | | |
| |||
87 | 106 | | |
88 | 107 | | |
89 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
90 | 128 | | |
91 | 129 | | |
92 | 130 | | |
| |||
487 | 525 | | |
488 | 526 | | |
489 | 527 | | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
490 | 531 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| 370 | + | |
| 371 | + | |
370 | 372 | | |
371 | 373 | | |
| 374 | + | |
372 | 375 | | |
373 | 376 | | |
374 | 377 | | |
| |||
0 commit comments