8
8
9
9
#include "Python.h"
10
10
#include "pycore_abstract.h" // _PyIndex_Check()
11
+ #include "pycore_cell.h" // PyCell_GetRef()
11
12
#include "pycore_code.h"
12
13
#include "pycore_emscripten_signal.h" // _Py_CHECK_EMSCRIPTEN_SIGNALS
13
14
#include "pycore_function.h"
@@ -1523,14 +1524,13 @@ dummy_func(
1523
1524
1524
1525
inst (DELETE_DEREF , (-- )) {
1525
1526
PyObject * cell = GETLOCAL (oparg );
1526
- PyObject * oldobj = PyCell_GET (cell );
1527
1527
// Can't use ERROR_IF here.
1528
1528
// Fortunately we don't need its superpower.
1529
+ PyObject * oldobj = PyCell_SwapTakeRef ((PyCellObject * )cell , NULL );
1529
1530
if (oldobj == NULL ) {
1530
1531
_PyEval_FormatExcUnbound (tstate , _PyFrame_GetCode (frame ), oparg );
1531
1532
ERROR_NO_POP ();
1532
1533
}
1533
- PyCell_SET (cell , NULL );
1534
1534
Py_DECREF (oldobj );
1535
1535
}
1536
1536
@@ -1543,32 +1543,28 @@ dummy_func(
1543
1543
ERROR_NO_POP ();
1544
1544
}
1545
1545
if (!value ) {
1546
- PyObject * cell = GETLOCAL (oparg );
1547
- value = PyCell_GET (cell );
1546
+ PyCellObject * cell = ( PyCellObject * ) GETLOCAL (oparg );
1547
+ value = PyCell_GetRef (cell );
1548
1548
if (value == NULL ) {
1549
1549
_PyEval_FormatExcUnbound (tstate , _PyFrame_GetCode (frame ), oparg );
1550
1550
ERROR_NO_POP ();
1551
1551
}
1552
- Py_INCREF (value );
1553
1552
}
1554
1553
Py_DECREF (class_dict );
1555
1554
}
1556
1555
1557
1556
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 );
1560
1559
if (value == NULL ) {
1561
1560
_PyEval_FormatExcUnbound (tstate , _PyFrame_GetCode (frame ), oparg );
1562
1561
ERROR_IF (true, error );
1563
1562
}
1564
- Py_INCREF (value );
1565
1563
}
1566
1564
1567
1565
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 );
1572
1568
}
1573
1569
1574
1570
inst (COPY_FREE_VARS , (-- )) {
0 commit comments