[pypy-svn] r73716 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test

afa at codespeak.net afa at codespeak.net
Tue Apr 13 13:09:48 CEST 2010


Author: afa
Date: Tue Apr 13 13:09:47 2010
New Revision: 73716

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/api.py
   pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py
Log:
Expose more type objects


Modified: pypy/branch/cpython-extension/pypy/module/cpyext/api.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/api.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/api.py	Tue Apr 13 13:09:47 2010
@@ -259,8 +259,12 @@
         "Dict": "space.w_dict",
         "Tuple": "space.w_tuple",
         "List": "space.w_list",
+        "String": "space.w_str",
         "Unicode": "space.w_unicode",
-        'Bool': 'space.w_bool',
+        "Int": "space.w_int",
+        "Bool": "space.w_bool",
+        "Float": "space.w_float",
+        "Long": "space.w_long",
         'None': 'space.type(space.w_None)',
         'NotImplemented': 'space.type(space.w_NotImplemented)',
         }.items():
@@ -505,9 +509,11 @@
 
     # populate static data
     for name, (type, expr) in GLOBALS.iteritems():
+        w_obj = eval(expr)
         name = name.replace("#", "")
+        INTERPLEVEL_API[name] = w_obj
+
         name = name.replace('Py', 'PyPy')
-        w_obj = eval(expr)
         ptr = ctypes.c_void_p.in_dll(bridge, name)
         ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(make_ref(space, w_obj)),
             ctypes.c_void_p).value

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py	Tue Apr 13 13:09:47 2010
@@ -97,5 +97,11 @@
         
     def test_TypeCheck(self, space, api):
         assert api.PyObject_TypeCheck(space.wrap(1), space.w_int)
+        assert api.PyObject_TypeCheck(space.wrap(1), api.PyInt_Type)
         assert api.PyObject_TypeCheck(space.wrap('foo'), space.w_str)
+        assert api.PyObject_TypeCheck(space.wrap('foo'), api.PyString_Type)
         assert api.PyObject_TypeCheck(space.wrap('foo'), space.w_object)
+        assert api.PyObject_TypeCheck(space.wrap(1L), api.PyLong_Type)
+        assert api.PyObject_TypeCheck(space.wrap(True), api.PyBool_Type)
+        assert api.PyObject_TypeCheck(space.wrap(1.2), api.PyFloat_Type)
+        assert api.PyObject_TypeCheck(space.w_int, api.PyType_Type)



More information about the Pypy-commit mailing list