Author: Ronan Lamy <[email protected]>
Branch: 
Changeset: r89493:83b73296760e
Date: 2017-01-11 16:05 +0000
http://bitbucket.org/pypy/pypy/changeset/83b73296760e/

Log:    Cleanup: avoid confusion between the api object and the api module,
        don't use api.PyXXX magic

diff --git a/pypy/module/cpyext/test/test_api.py 
b/pypy/module/cpyext/test/test_api.py
--- a/pypy/module/cpyext/test/test_api.py
+++ b/pypy/module/cpyext/test/test_api.py
@@ -2,20 +2,14 @@
 from rpython.rtyper.lltypesystem import lltype
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.module.cpyext.state import State
-from pypy.module.cpyext import api
+from pypy.module.cpyext.api import (
+    slot_function, cpython_api, copy_header_files, INTERPLEVEL_API,
+    Py_ssize_t, Py_ssize_tP, PyObject)
 from pypy.module.cpyext.test.test_cpyext import freeze_refcnts, 
LeakCheckingTest
-PyObject = api.PyObject
 from pypy.interpreter.error import OperationError
 from rpython.rlib import rawrefcount
 import os
 
[email protected]_api([PyObject], lltype.Void)
-def PyPy_GetWrapped(space, w_arg):
-    assert isinstance(w_arg, W_Root)
[email protected]_api([PyObject], lltype.Void)
-def PyPy_GetReference(space, arg):
-    assert lltype.typeOf(arg) ==  PyObject
-
 class BaseApiTest(LeakCheckingTest):
     def setup_class(cls):
         space = cls.space
@@ -35,7 +29,7 @@
             def __getattr__(self, name):
                 return getattr(cls.space, name)
         cls.api = CAPI()
-        CAPI.__dict__.update(api.INTERPLEVEL_API)
+        CAPI.__dict__.update(INTERPLEVEL_API)
 
         print 'DONT_FREE_ANY_MORE'
         rawrefcount._dont_free_any_more()
@@ -71,20 +65,28 @@
         if self.check_and_print_leaks():
             assert False, "Test leaks or loses object(s)."
 
[email protected]_api([api.Py_ssize_t], api.Py_ssize_t, error=-1)
+@slot_function([PyObject], lltype.Void)
+def PyPy_GetWrapped(space, w_arg):
+    assert isinstance(w_arg, W_Root)
+
+@slot_function([PyObject], lltype.Void)
+def PyPy_GetReference(space, arg):
+    assert lltype.typeOf(arg) ==  PyObject
+
+@cpython_api([Py_ssize_t], Py_ssize_t, error=-1)
 def PyPy_TypedefTest1(space, arg):
-    assert lltype.typeOf(arg) == api.Py_ssize_t
+    assert lltype.typeOf(arg) == Py_ssize_t
     return 0
 
[email protected]_api([api.Py_ssize_tP], api.Py_ssize_tP)
+@cpython_api([Py_ssize_tP], Py_ssize_tP)
 def PyPy_TypedefTest2(space, arg):
-    assert lltype.typeOf(arg) == api.Py_ssize_tP
+    assert lltype.typeOf(arg) == Py_ssize_tP
     return None
 
 class TestConversion(BaseApiTest):
-    def test_conversions(self, space, api):
-        api.PyPy_GetWrapped(space.w_None)
-        api.PyPy_GetReference(space.w_None)
+    def test_conversions(self, space):
+        PyPy_GetWrapped(space, space.w_None)
+        PyPy_GetReference(space, space.w_None)
 
     def test_typedef(self, space):
         from rpython.translator.c.database import LowLevelDatabase
@@ -95,7 +97,7 @@
         assert PyPy_TypedefTest2.api_func.get_c_args(db) == 'Py_ssize_t *arg0'
 
         PyPy_TypedefTest1(space, 0)
-        ppos = lltype.malloc(api.Py_ssize_tP.TO, 1, flavor='raw')
+        ppos = lltype.malloc(Py_ssize_tP.TO, 1, flavor='raw')
         ppos[0] = 0
         PyPy_TypedefTest2(space, ppos)
         lltype.free(ppos, flavor='raw')
@@ -103,7 +105,7 @@
 @pytest.mark.skipif(os.environ.get('USER')=='root',
                     reason='root can write to all files')
 def test_copy_header_files(tmpdir):
-    api.copy_header_files(tmpdir, True)
+    copy_header_files(tmpdir, True)
     def check(name):
         f = tmpdir.join(name)
         assert f.check(file=True)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to