Skip to content

Commit d87f79c

Browse files
evhubclaude
andcommitted
Fix _coconut_partial.__new__ clashing with func= keyword argument
The __new__ method used `func` as a named parameter, which caused TypeError when user code passed `func` as a keyword argument (e.g., f$(func=1) compiling to _coconut_partial(f, func=1)). Changed to *args/**kwargs and access self.func after construction instead. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e4ec46f commit d87f79c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

coconut/root.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ def wrap(new_func):
7979
exec("_coconut_exec = exec")
8080
class _coconut_partial(_coconut_functools.partial):
8181
__slots__ = ()
82-
def __new__(cls, func, *args, **kwargs):
83-
self = _coconut_functools.partial.__new__(cls, func, *args, **kwargs)
84-
self.__name__ = _coconut.getattr(func, "__name__", None)
82+
def __new__(cls, *args, **kwargs):
83+
self = _coconut_functools.partial.__new__(cls, *args, **kwargs)
84+
self.__name__ = _coconut.getattr(self.func, "__name__", None)
8585
return self
8686
def __get__(self, obj, objtype=None):
8787
if obj is None:
@@ -108,9 +108,9 @@ def __repr__(self):
108108
from io import open
109109
class _coconut_partial(_coconut_functools.partial):
110110
__slots__ = ()
111-
def __new__(cls, func, *args, **kwargs):
112-
self = _coconut_functools.partial.__new__(cls, func, *args, **kwargs)
113-
self.__name__ = _coconut.getattr(func, "__name__", None)
111+
def __new__(cls, *args, **kwargs):
112+
self = _coconut_functools.partial.__new__(cls, *args, **kwargs)
113+
self.__name__ = _coconut.getattr(self.func, "__name__", None)
114114
return self
115115
def __get__(self, obj, objtype=None):
116116
if obj is None:

0 commit comments

Comments
 (0)