mirror of https://github.com/python/cpython
gh-74929: Remove undesirable DECREF in PEP 667 implementation (#118583)
With tests.
This commit is contained in:
parent
1b22d801b8
commit
5dd36732c8
|
@ -364,6 +364,21 @@ class TestFrameLocals(unittest.TestCase):
|
||||||
c = 0
|
c = 0
|
||||||
f()
|
f()
|
||||||
|
|
||||||
|
def test_local_objects(self):
|
||||||
|
o = object()
|
||||||
|
k = '.'.join(['a', 'b', 'c'])
|
||||||
|
f_locals = sys._getframe().f_locals
|
||||||
|
f_locals['o'] = f_locals['k']
|
||||||
|
self.assertEqual(o, 'a.b.c')
|
||||||
|
|
||||||
|
def test_update_with_self(self):
|
||||||
|
def f():
|
||||||
|
f_locals = sys._getframe().f_locals
|
||||||
|
f_locals.update(f_locals)
|
||||||
|
f_locals.update(f_locals)
|
||||||
|
f_locals.update(f_locals)
|
||||||
|
f()
|
||||||
|
|
||||||
def test_repr(self):
|
def test_repr(self):
|
||||||
x = 1
|
x = 1
|
||||||
# Introduce a reference cycle
|
# Introduce a reference cycle
|
||||||
|
|
|
@ -171,7 +171,6 @@ framelocalsproxy_setitem(PyObject *self, PyObject *key, PyObject *value)
|
||||||
} else if (value != oldvalue) {
|
} else if (value != oldvalue) {
|
||||||
Py_XSETREF(fast[i], Py_NewRef(value));
|
Py_XSETREF(fast[i], Py_NewRef(value));
|
||||||
}
|
}
|
||||||
Py_XDECREF(value);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue