Skip to content

Commit 57aca39

Browse files
committed
gh-152315: Compute missing self hint only when error is raised
1 parent f9fd4da commit 57aca39

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Python/ceval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,6 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func,
17931793

17941794
/* Copy all positional arguments into local variables */
17951795
Py_ssize_t j, n;
1796-
int missing_self_hint = suggest_missing_self(func, co, args, argcount);
17971796
if (argcount > co->co_argcount) {
17981797
n = co->co_argcount;
17991798
}
@@ -1936,6 +1935,7 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func,
19361935

19371936
/* Check the number of positional arguments */
19381937
if ((argcount > co->co_argcount) && !(co->co_flags & CO_VARARGS)) {
1938+
int missing_self_hint = suggest_missing_self(func, co, args, argcount);
19391939
too_many_positional(tstate, co, argcount, func->func_defaults, localsplus,
19401940
func->func_qualname, missing_self_hint);
19411941
goto fail_post_args;

0 commit comments

Comments
 (0)