8000 gh-88696: clean up dead argument to compiler_make_closure (GH-100806) · python/cpython@7116030 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7116030

Browse files
authored
gh-88696: clean up dead argument to compiler_make_closure (GH-100806)
1 parent 9e7d726 commit 7116030

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

Python/compile.c

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,11 +2246,8 @@ compiler_lookup_arg(PyObject *dict, PyObject *name)
22462246

22472247
static int
22482248
compiler_make_closure(struct compiler *c, location loc,
2249-
PyCodeObject *co, Py_ssize_t flags, PyObject *qualname)
2249+
PyCodeObject *co, Py_ssize_t flags)
22502250
{
2251-
if (qualname == NULL)
2252-
qualname = co->co_name;
2253-
22542251
if (co->co_nfreevars) {
22552252
int i = PyCode_GetFirstFree(co);
22562253
for (; i < co->co_nlocalsplus; ++i) {
@@ -2605,7 +2602,7 @@ static int
26052602
compiler_function(struct compiler *c, stmt_ty s, int is_async)
26062603
{
26072604
PyCodeObject *co;
2608-
PyObject *qualname, *docstring = NULL;
2605+
PyObject *docstring = NULL;
26092606
arguments_ty args;
26102607
expr_ty returns;
26112608
identifier name;
@@ -2682,19 +2679,15 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async)
26822679
}
26832680
}
26842681
co = assemble(c, 1);
2685-
qualname = Py_NewRef(c->u->u_qualname);
26862682
compiler_exit_scope(c);
26872683
if (co == NULL) {
2688-
Py_XDECREF(qualname);
26892684
Py_XDECREF(co);
26902685
return ERROR;
26912686
}
2692-
if (compiler_make_closure(c, loc, co, funcflags, qualname) < 0) {
2693-
Py_DECREF(qualname);
2687+
if (compiler_make_closure(c, loc, co, funcflags) < 0) {
26942688
Py_DECREF(co);
26952689
return ERROR;
26962690
}
2697-
Py_DECREF(qualname);
26982691
Py_DECREF(co);
26992692

27002693
RETURN_IF_ERROR(compiler_apply_decorators(c, decos));
@@ -2794,7 +2787,7 @@ compiler_class(struct compiler *c, stmt_ty s)
27942787
ADDOP(c, loc, LOAD_BUILD_CLASS);
27952788

27962789
/* 3. load a function (or closure) made from the code object */
2797-
if (compiler_make_closure(c, loc, co, 0, NULL) < 0) {
2790+
if (compiler_make_closure(c, loc, co, 0) < 0) {
27982791
Py_DECREF(co);
27992792
return ERROR;
28002793
}
@@ -3015,7 +3008,6 @@ static int
30153008
compiler_lambda(struct compiler *c, expr_ty e)
30163009
{
30173010
PyCodeObject *co;
3018-
PyObject *qualname;
30193011
Py_ssize_t funcflags;
30203012
arguments_ty args = e->v.Lambda.args;
30213013
assert(e->kind == Lambda_kind);
@@ -3049,19 +3041,15 @@ compiler_lambda(struct compiler *c, expr_ty e)
30493041
ADDOP_IN_SCOPE(c, loc, RETURN_VALUE);
30503042
co = assemble(c, 1);
30513043
}
3052-
qualname = Py_NewRef(c->u->u_qualname);
30533044
compiler_exit_scope(c);
30543045
if (co == NULL) {
3055-
Py_DECREF(qualname);
30563046
return ERROR;
30573047
}
30583048

3059-
if (compiler_make_closure(c, loc, co, funcflags, qualname) < 0) {
3060-
Py_DECREF(qualname);
3049+
if (compiler_make_closure(c, loc, co, funcflags) < 0) {
30613050
Py_DECREF(co);
30623051
return ERROR;
30633052
}
3064-
Py_DECREF(qualname);
30653053
Py_DECREF(co);
30663054

30673055
return SUCCESS;
@@ -5392,7 +5380,6 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type,
53925380
{
53935381
PyCodeObject *co = NULL;
53945382
comprehension_ty outermost;
5395-
PyObject *qualname = NULL;
53965383
int scope_type = c->u->u_scope_type;
53975384
int is_async_generator = 0;
53985385
int is_top_level_await = IS_TOP_LEVEL_AWAIT(c);
@@ -5453,7 +5440,6 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type,
54535440
}
54545441

54555442
co = assemble(c, 1);
5456-
qualname = Py_NewRef(c->u->u_qualname);
54575443
compiler_exit_scope(c);
54585444
if (is_top_level_await && is_async_generator){
54595445
c->u->u_ste->ste_coroutine = 1;
@@ -5463,10 +5449,9 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type,
54635449
}
54645450

54655451
loc = LOC(e);
5466-
if (compiler_make_closure(c, loc, co, 0, qualname) < 0) {
5452+
if (compiler_make_closure(c, loc, co, 0) < 0) {
54675453
goto error;
54685454
}
5469-
Py_DECREF(qualname);
54705455
Py_DECREF(co);
54715456

54725457
VISIT(c, expr, outermost->iter);
@@ -5490,7 +5475,6 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type,
54905475
error_in_scope:
54915476
compiler_exit_scope(c);
54925477
error:
5493-
Py_XDECREF(qualname);
54945478
Py_XDECREF(co);
54955479
return ERROR;
54965480
}
@@ -8671,7 +8655,7 @@ opcode_metadata_is_sane(cfg_builder *g) {
86718655
for (int i = 0; i < b->b_iused; i++) {
86728656
struct instr *instr = &b->b_instr[i];
86738657
int opcode = instr->i_opcode;
8674-
assert(opcode <= MAX_REAL_OPCODE);
8658+
assert(opcode <= MAX_REAL_OPCODE);
86758659
int pushed = _PyOpcode_opcode_metadata[opcode].n_pushed;
86768660
int popped = _PyOpcode_opcode_metadata[opcode].n_popped;
86778661
assert((pushed < 0) == (popped < 0));

0 commit comments

Comments
 (0)
0