Skip to content

Commit bf64b96

Browse files
committed
gh-152315: Initialize first_argument before the fail_pre_positional exit
1 parent 6ec11c7 commit bf64b96

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Python/ceval.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,9 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func,
17741774
/* Create a dictionary for keyword parameters (**kwags) */
17751775
PyObject *kwdict;
17761776
Py_ssize_t i;
1777+
/* Set below once the "too many positional arguments" precondition is
1778+
known; must be initialized before the fail_pre_positional exit. */
1779+
PyObject *first_argument = NULL;
17771780
if (co->co_flags & CO_VARKEYWORDS) {
17781781
kwdict = PyDict_New();
17791782
if (kwdict == NULL) {
@@ -1794,7 +1797,6 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func,
17941797
argument cleanup below may close args[0] before the hint is computed.
17951798
The pin is only needed when the "too many positional arguments"
17961799
error is about to be raised. */
1797-
PyObject *first_argument = NULL;
17981800
if (argcount > co->co_argcount && !(co->co_flags & CO_VARARGS)) {
17991801
first_argument = Py_NewRef(PyStackRef_AsPyObjectBorrow(args[0]));
18001802
}

0 commit comments

Comments
 (0)