Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6492bf7

Browse files
committed
SF patch 103589: Fix handling of cell vars that are either * or ** parameters.
(Nick Mathewson) Remove to XXX comments
1 parent cb17ae8 commit 6492bf7

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

Python/compile.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,10 +2486,6 @@ com_assert_stmt(struct compiling *c, node *n)
24862486
where <message> is the second test, if present.
24872487
*/
24882488

2489-
/* XXX should __debug__ and AssertionError get inserted into
2490-
the symbol table? they don't follow the normal rules
2491-
because they are always loaded as globals */
2492-
24932489
if (Py_OptimizeFlag)
24942490
return;
24952491
com_addop_name(c, LOAD_GLOBAL, "__debug__");
@@ -3524,10 +3520,6 @@ com_fplist(struct compiling *c, node *n)
35243520
}
35253521
}
35263522

3527-
/* XXX This function could probably be made simpler, because it
3528-
doesn't do anything except generate code for complex arguments.
3529-
*/
3530-
35313523
static void
35323524
com_arglist(struct compiling *c, node *n)
35333525
{
@@ -3579,12 +3571,22 @@ com_arglist(struct compiling *c, node *n)
35793571
REQ(ch, STAR);
35803572
ch = CHILD(n, i+1);
35813573
if (TYPE(ch) == NAME) {
3574+
PyObject *v;
35823575
i += 3;
3576+
v = PyDict_GetItemString(c->c_cellvars,
3577+
STR(ch));
3578+
if (v) {
3579+
com_addoparg(c, LOAD_FAST, narg);
3580+
com_addoparg(c, STORE_DEREF,
3581+
PyInt_AS_LONG(v));
35833582
}
3583+
narg++;
35843584
}
35853585
}
3586+
}
35863587
/* Handle **keywords */
35873588
if (i < nch) {
3589+
PyObject *v;
35883590
node *ch;
35893591
ch = CHILD(n, i);
35903592
if (TYPE(ch) != DOUBLESTAR) {
@@ -3596,6 +3598,11 @@ com_arglist(struct compiling *c, node *n)
35963598
else
35973599
ch = CHILD(n, i+1);
35983600
REQ(ch, NAME);
3601+
v = PyDict_GetItemString(c->c_cellvars, STR(ch));
3602+
if (v) {
3603+
com_addoparg(c, LOAD_FAST, narg);
3604+
com_addoparg(c, STORE_DEREF, PyInt_AS_LONG(v));
3605+
}
35993606
}
36003607
if (complex) {
36013608
/* Generate code for complex arguments only after

0 commit comments

Comments
 (0)