Skip to content

Commit c8eb125

Browse files
committed
Update
[ghstack-poisoned]
1 parent 5ccbf15 commit c8eb125

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

torch/_dynamo/polyfills/operator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ def getter(obj: Any) -> tuple[Any, ...]: # type: ignore[misc]
100100
# Reference: https://docs.python.org/3/library/operator.html#operator.methodcaller
101101
@substitute_in_graph(operator.methodcaller, is_embedded_type=True) # type: ignore[arg-type]
102102
def methodcaller(name: str, /, *args: Any, **kwargs: Any) -> Callable[[Any], Any]:
103+
if not isinstance(name, str):
104+
raise TypeError("method name must be a string")
105+
103106
def caller(obj: Any) -> Any:
104107
return getattr(obj, name)(*args, **kwargs)
105108

0 commit comments

Comments
 (0)