https://github.com/python/cpython/commit/5dd36732c850084ce262b7869ed90d73a281296a
commit: 5dd36732c850084ce262b7869ed90d73a281296a
branch: main
author: Tian Gao <[email protected]>
committer: gvanrossum <[email protected]>
date: 2024-05-05T03:06:42Z
summary:
gh-74929: Remove undesirable DECREF in PEP 667 implementation (#118583)
With tests.
files:
M Lib/test/test_frame.py
M Objects/frameobject.c
diff --git a/Lib/test/test_frame.py b/Lib/test/test_frame.py
index 93d0ea839d16eb..212255374bddd1 100644
--- a/Lib/test/test_frame.py
+++ b/Lib/test/test_frame.py
@@ -364,6 +364,21 @@ def f():
c = 0
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):
x = 1
# Introduce a reference cycle
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 8030ecb6853674..1cb00e318d9163 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -171,7 +171,6 @@ framelocalsproxy_setitem(PyObject *self, PyObject *key,
PyObject *value)
} else if (value != oldvalue) {
Py_XSETREF(fast[i], Py_NewRef(value));
}
- Py_XDECREF(value);
return 0;
}
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]