Author: Armin Rigo <[email protected]>
Branch: cpyext-avoid-roundtrip
Changeset: r92677:8bbae2a41f6b
Date: 2017-10-09 16:26 +0200
http://bitbucket.org/pypy/pypy/changeset/8bbae2a41f6b/

Log:    (antocuni, arigo)

        Small refactoring to make it possible to return something different
        from make_ref()

diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -279,10 +279,7 @@
         return hop.inputconst(lltype.Bool, hop.s_result.const)
 
 @specialize.ll()
-def make_ref(space, obj, w_userdata=None, immortal=False):
-    """Increment the reference counter of the PyObject and return it.
-    Can be called with either a PyObject or a W_Root.
-    """
+def get_pyobj_and_incref(space, obj, w_userdata=None, immortal=False):
     if is_pyobj(obj):
         pyobj = rffi.cast(PyObject, obj)
         at_least = 1
@@ -295,6 +292,12 @@
         keepalive_until_here(obj)
     return pyobj
 
[email protected]()
+def make_ref(space, obj, w_userdata=None, immortal=False):
+    """Increment the reference counter of the PyObject and return it.
+    Can be called with either a PyObject or a W_Root.
+    """
+    return get_pyobj_and_incref(space, obj, w_userdata, immortal=False)
 
 @specialize.ll()
 def get_w_obj_and_decref(space, obj):
@@ -318,7 +321,7 @@
 
 @specialize.ll()
 def incref(space, obj):
-    make_ref(space, obj)
+    get_pyobj_and_incref(space, obj)
 
 @specialize.ll()
 def decref(space, obj):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to