[pypy-commit] pypy cpyext-gc-support-2: fix with comment

arigo pypy.commits at gmail.com
Sat Feb 13 11:38:22 EST 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: cpyext-gc-support-2
Changeset: r82228:72c05e2cc492
Date: 2016-02-13 17:37 +0100
http://bitbucket.org/pypy/pypy/changeset/72c05e2cc492/

Log:	fix with comment

diff --git a/pypy/module/cpyext/dictobject.py b/pypy/module/cpyext/dictobject.py
--- a/pypy/module/cpyext/dictobject.py
+++ b/pypy/module/cpyext/dictobject.py
@@ -14,13 +14,16 @@
 
 PyDict_Check, PyDict_CheckExact = build_type_checkers("Dict")
 
- at cpython_api([PyObject, PyObject], PyObject, error=CANNOT_FAIL)
+ at cpython_api([PyObject, PyObject], PyObject, error=CANNOT_FAIL, result_borrowed=True)
 def PyDict_GetItem(space, w_dict, w_key):
     try:
         w_res = space.getitem(w_dict, w_key)
     except:
         return None
-    return borrow_from(w_dict, w_res)
+    # NOTE: this works so far because all our dict strategies store
+    # *values* as full objects, which stay alive as long as the dict is
+    # alive and not modified.
+    return w_res
 
 @cpython_api([PyObject, PyObject, PyObject], rffi.INT_real, error=-1)
 def PyDict_SetItem(space, w_dict, w_key, w_obj):


More information about the pypy-commit mailing list