88
99#include "Python.h"
1010#include "pycore_abstract.h" // _PyIndex_Check()
11+ #include "pycore_cell.h" // PyCell_GetRef()
1112#include "pycore_code.h"
1213#include "pycore_emscripten_signal.h" // _Py_CHECK_EMSCRIPTEN_SIGNALS
1314#include "pycore_function.h"
@@ -1523,14 +1524,13 @@ dummy_func(
15231524
15241525 inst (DELETE_DEREF , (-- )) {
15251526 PyObject * cell = GETLOCAL (oparg );
1526- PyObject * oldobj = PyCell_GET (cell );
15271527 // Can't use ERROR_IF here.
15281528 // Fortunately we don't need its superpower.
1529+ PyObject * oldobj = PyCell_SwapTakeRef ((PyCellObject * )cell , NULL );
15291530 if (oldobj == NULL ) {
15301531 _PyEval_FormatExcUnbound (tstate , _PyFrame_GetCode (frame ), oparg );
15311532 ERROR_NO_POP ();
15321533 }
1533- PyCell_SET (cell , NULL );
15341534 Py_DECREF (oldobj );
15351535 }
15361536
@@ -1543,32 +1543,28 @@ dummy_func(
15431543 ERROR_NO_POP ();
15441544 }
15451545 if (!value ) {
1546- PyObject * cell = GETLOCAL (oparg );
1547- value = PyCell_GET (cell );
1546+ PyCellObject * cell = ( PyCellObject * ) GETLOCAL (oparg );
1547+ value = PyCell_GetRef (cell );
15481548 if (value == NULL ) {
15491549 _PyEval_FormatExcUnbound (tstate , _PyFrame_GetCode (frame ), oparg );
15501550 ERROR_NO_POP ();
15511551 }
1552- Py_INCREF (value );
15531552 }
15541553 Py_DECREF (class_dict );
15551554 }
15561555
15571556 inst (LOAD_DEREF , ( -- value )) {
1558- PyObject * cell = GETLOCAL (oparg );
1559- value = PyCell_GET (cell );
1557+ PyCellObject * cell = ( PyCellObject * ) GETLOCAL (oparg );
1558+ value = PyCell_GetRef (cell );
15601559 if (value == NULL ) {
15611560 _PyEval_FormatExcUnbound (tstate , _PyFrame_GetCode (frame ), oparg );
15621561 ERROR_IF (true, error );
15631562 }
1564- Py_INCREF (value );
15651563 }
15661564
15671565 inst (STORE_DEREF , (v -- )) {
1568- PyObject * cell = GETLOCAL (oparg );
1569- PyObject * oldobj = PyCell_GET (cell );
1570- PyCell_SET (cell , v );
1571- Py_XDECREF (oldobj );
1566+ PyCellObject * cell = (PyCellObject * )GETLOCAL (oparg );
1567+ PyCell_SetTakeRef (cell , v );
15721568 }
15731569
15741570 inst (COPY_FREE_VARS , (-- )) {
0 commit comments