Author: Armin Rigo <[email protected]>
Branch: cpyext-avoid-roundtrip
Changeset: r92532:6046c5c9f4c2
Date: 2017-10-01 17:06 +0200
http://bitbucket.org/pypy/pypy/changeset/6046c5c9f4c2/

Log:    (antocuni, arigo, ronan around): same with Py_IncRef()

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -596,7 +596,8 @@
     'Py_FrozenFlag', 'Py_TabcheckFlag', 'Py_UnicodeFlag', 
'Py_IgnoreEnvironmentFlag',
     'Py_DivisionWarningFlag', 'Py_DontWriteBytecodeFlag', 
'Py_NoUserSiteDirectory',
     '_Py_QnewFlag', 'Py_Py3kWarningFlag', 'Py_HashRandomizationFlag', 
'_Py_PackageContext',
-    '_PyTraceMalloc_Track', '_PyTraceMalloc_Untrack', 'PyMem_Malloc', 
'Py_DecRef',
+    '_PyTraceMalloc_Track', '_PyTraceMalloc_Untrack', 'PyMem_Malloc',
+    'Py_IncRef', 'Py_DecRef',
 ]
 TYPES = {}
 FORWARD_DECLS = []
diff --git a/pypy/module/cpyext/include/object.h 
b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -47,8 +47,9 @@
 #define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0)
 #endif
 
+PyAPI_FUNC(void) Py_IncRef(PyObject *);
 PyAPI_FUNC(void) Py_DecRef(PyObject *);
-    
+
 #define Py_CLEAR(op)                        \
         do {                                   \
                 if (op) {                      \
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
@@ -332,13 +332,7 @@
         get_w_obj_and_decref(space, obj)
 
 
-@cpython_api([PyObject], lltype.Void)
-def Py_IncRef(space, obj):
-    incref(space, obj)
-
-## @cpython_api([PyObject], lltype.Void)
-## def Py_DecRef(space, obj):
-##     decref(space, obj)
+Py_IncRef = incref # XXX remove me and kill all the Py_IncRef usages from 
RPython
 Py_DecRef = decref # XXX remove me and kill all the Py_DecRef usages from 
RPython
 
 @cpython_api([PyObject], lltype.Void)
diff --git a/pypy/module/cpyext/src/object.c b/pypy/module/cpyext/src/object.c
--- a/pypy/module/cpyext/src/object.c
+++ b/pypy/module/cpyext/src/object.c
@@ -3,8 +3,13 @@
 #include "Python.h"
 
 void
+Py_IncRef(PyObject *o)
+{
+    Py_XINCREF(o);
+}
+
+void
 Py_DecRef(PyObject *o)
 {
     Py_XDECREF(o);
 }
-
diff --git a/pypy/module/cpyext/test/test_cpyext.py 
b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -436,7 +436,7 @@
         {
             if (self)
             {
-                Py_INCREF(self);
+                Py_IncRef(self);
                 return self;
             }
             else
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to