File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -296,7 +296,7 @@ _PyCode_Validate(struct _PyCodeConstructor *con)
296
296
}
297
297
298
298
static void
299
- init_code (PyCodeObject * co , struct _PyCodeConstructor * con )
299
+ init_code (PyCodeObject * co , struct _PyCodeConstructor * con , bool is_new )
300
300
{
301
301
if (con -> localsplusnames ) {
302
302
int nlocalsplus = (int )PyTuple_GET_SIZE (con -> localsplusnames );
@@ -318,6 +318,11 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor *con)
318
318
co -> co_nfreevars = 0 ;
319
319
}
320
320
321
+ if (!is_new ) {
322
+ Py_XDECREF (co -> co_filename );
323
+ Py_XDECREF (co -> co_name );
324
+ Py_XDECREF (co -> co_qualname );
325
+ }
321
326
Py_INCREF (con -> filename );
322
327
co -> co_filename = con -> filename ;
323
328
Py_INCREF (con -> name );
@@ -420,7 +425,8 @@ _PyCode_New(struct _PyCodeConstructor *con)
420
425
PyErr_NoMemory ();
421
426
return NULL ;
422
427
}
423
- init_code (co , con );
428
+
429
+ init_code (co , con , true);
424
430
425
431
return co ;
426
432
}
@@ -442,7 +448,7 @@ _PyCode_Update(struct _PyCodeConstructor *con, PyCodeObject *code)
442
448
con -> columntable = Py_None ;
443
449
}
444
450
445
- init_code (code , con ); // TODO: This leaks!
451
+ init_code (code , con , false);
446
452
447
453
return code ;
448
454
}
You can’t perform that action at this time.
0 commit comments