8000 gh-74929: Remove undesirable DECREF in PEP 667 implementation (#118583) · python/cpython@5dd3673 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5dd3673

Browse files
gh-74929: Remove undesirable DECREF in PEP 667 implementation (#118583)
With tests.
1 parent 1b22d80 commit 5dd3673

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Lib/test/test_frame.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,21 @@ def f():
364364
c = 0
365365
f()
366366

367+
def test_local_objects(self):
368+
o = object()
369+
k = '.'.join(['a', 'b', 'c'])
370+
f_locals = sys._getframe().f_locals
371+
f_locals['o'] = f_locals['k']
372+
self.assertEqual(o, 'a.b.c')
373+
374+
def test_update_with_self(self):
375+
def f():
376+
f_locals = sys._getframe().f_locals
377+
f_locals.update(f_locals)
378+
f_locals.update(f_locals)
379+
f_locals.update(f_locals)
380+
f()
381+
367382
def test_repr(self):
368383
x = 1
369384
# Introduce a reference cycle

Objects/frameobject.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ framelocalsproxy_setitem(PyObject *self, PyObject *key, PyObject *value)
171171
} else if (value != oldvalue) {
172172
Py_XSETREF(fast[i], Py_NewRef(value));
173173
}
174-
Py_XDECREF(value);
175174
return 0;
176175
}
177176
}

0 commit comments

Comments
 (0)
0