[pypy-svn] r73461 - pypy/branch/cpython-extension/pypy/module/cpyext

afa at codespeak.net afa at codespeak.net
Tue Apr 6 18:33:47 CEST 2010


Author: afa
Date: Tue Apr  6 18:33:44 2010
New Revision: 73461

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/api.py
   pypy/branch/cpython-extension/pypy/module/cpyext/pycobject.py
   pypy/branch/cpython-extension/pypy/module/cpyext/pyerrors.py
   pypy/branch/cpython-extension/pypy/module/cpyext/unicodeobject.py
Log:
Various translation fixes


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  6 18:33:44 2010
@@ -169,7 +169,7 @@
                             arg = input_arg
                     elif ARG is PyObject and is_wrapped:
                         # convert to a wrapped object
-                        if rffi._isllptr(input_arg):
+                        if input_arg and rffi._isllptr(input_arg):
                             arg = from_ref(space, input_arg)
                         else:
                             arg = input_arg
@@ -324,8 +324,7 @@
             print >>sys.stderr, callable,
         for i, (typ, is_wrapped) in argtypes_enum_ui:
             arg = args[i]
-            if (typ is PyObject and
-                is_wrapped):
+            if typ is PyObject and is_wrapped:
                 if arg:
                     arg_conv = from_ref(space, arg)
                 else:

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/pycobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/pycobject.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/pycobject.py	Tue Apr  6 18:33:44 2010
@@ -19,7 +19,7 @@
     def __init__(self, space, voidp):
         W_PyCObject.__init__(self, space)
         self.voidp = voidp
-        self.pyo = lltype.nullptr(PyObject.TO)
+        self.pyo = lltype.nullptr(PyCObject.TO)
 
     def set_pycobject(self, pyo):
         self.pyo = pyo
@@ -33,6 +33,7 @@
     """Create a PyCObject from the void * cobj.  The destr function
     will be called when the object is reclaimed, unless it is NULL."""
     w_pycobject = space.wrap(W_PyCObjectFromVoidPtr(space, cobj))
+    assert isinstance(w_pycobject, W_PyCObjectFromVoidPtr)
     pyo = make_ref(space, w_pycobject)
     pycobject = rffi.cast(PyCObject, pyo)
     w_pycobject.set_pycobject(pycobject)

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/pyerrors.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/pyerrors.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/pyerrors.py	Tue Apr  6 18:33:44 2010
@@ -156,6 +156,6 @@
     calling PyErr_WarnEx() with a stacklevel of 1.
     
     Deprecated; use PyErr_WarnEx() instead."""
-    return PyErr_WarnEx(w_category, message, 1)
+    return PyErr_WarnEx(space, w_category, message, 1)
 
 

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/unicodeobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/unicodeobject.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/unicodeobject.py	Tue Apr  6 18:33:44 2010
@@ -10,49 +10,49 @@
 Py_UNICODE = lltype.UniChar
 
 @cpython_api([Py_UNICODE], rffi.INT_real, error=CANNOT_FAIL)
-def Py_UNICODE_ISSPACE(space, w_ch):
+def Py_UNICODE_ISSPACE(space, ch):
     """Return 1 or 0 depending on whether ch is a whitespace character."""
-    return unicodedb.isspace(w_ch)
+    return unicodedb.isspace(ord(ch))
 
 @cpython_api([Py_UNICODE], rffi.INT_real, error=CANNOT_FAIL)
-def Py_UNICODE_ISALNUM(space, w_ch):
+def Py_UNICODE_ISALNUM(space, ch):
     """Return 1 or 0 depending on whether ch is an alphanumeric character."""
-    return unicodedb.isalnum(w_ch)
+    return unicodedb.isalnum(ord(ch))
 
 @cpython_api([Py_UNICODE], rffi.INT_real, error=CANNOT_FAIL)
-def Py_UNICODE_ISLINEBREAK(space, w_ch):
+def Py_UNICODE_ISLINEBREAK(space, ch):
     """Return 1 or 0 depending on whether ch is a linebreak character."""
-    return unicodedb.islinebreak(w_ch)
+    return unicodedb.islinebreak(ord(ch))
 
 @cpython_api([Py_UNICODE], rffi.INT_real, error=CANNOT_FAIL)
-def Py_UNICODE_ISSPACE(space, w_ch):
+def Py_UNICODE_ISSPACE(space, ch):
     """Return 1 or 0 depending on whether ch is a whitespace character."""
-    return unicodedb.isspace(w_ch)
+    return unicodedb.isspace(ord(ch))
 
 @cpython_api([Py_UNICODE], rffi.INT_real, error=CANNOT_FAIL)
-def Py_UNICODE_ISALNUM(space, w_ch):
+def Py_UNICODE_ISALNUM(space, ch):
     """Return 1 or 0 depending on whether ch is an alphanumeric character."""
-    return unicodedb.isalnum(w_ch)
+    return unicodedb.isalnum(ord(ch))
 
 @cpython_api([Py_UNICODE], rffi.INT_real, error=CANNOT_FAIL)
-def Py_UNICODE_ISDECIMAL(space, w_ch):
+def Py_UNICODE_ISDECIMAL(space, ch):
     """Return 1 or 0 depending on whether ch is a decimal character."""
-    return unicodedb.isdecimal(w_ch)
+    return unicodedb.isdecimal(ord(ch))
 
 @cpython_api([Py_UNICODE], rffi.INT_real, error=CANNOT_FAIL)
-def Py_UNICODE_ISLOWER(space, w_ch):
+def Py_UNICODE_ISLOWER(space, ch):
     """Return 1 or 0 depending on whether ch is a lowercase character."""
-    return unicodedb.islower(w_ch)
+    return unicodedb.islower(ord(ch))
 
 @cpython_api([Py_UNICODE], rffi.INT_real, error=CANNOT_FAIL)
-def Py_UNICODE_ISUPPER(space, w_ch):
+def Py_UNICODE_ISUPPER(space, ch):
     """Return 1 or 0 depending on whether ch is an uppercase character."""
-    return unicodedb.isupper(w_ch)
+    return unicodedb.isupper(ord(ch))
 
 @cpython_api([Py_UNICODE], Py_UNICODE, error=CANNOT_FAIL)
-def Py_UNICODE_TOLOWER(space, w_ch):
+def Py_UNICODE_TOLOWER(space, ch):
     """Return the character ch converted to lower case."""
-    return unicodedb.tolower(w_ch)
+    return unicodedb.tolower(ord(ch))
 
 @cpython_api([PyObject], rffi.CCHARP, error=CANNOT_FAIL)
 def PyUnicode_AS_DATA(space, ref):
@@ -67,10 +67,10 @@
     return rffi.cast(rffi.CCHARP, ref_unicode.c_buffer)
 
 @cpython_api([PyObject], Py_ssize_t, error=CANNOT_FAIL)
-def PyUnicode_GET_DATA_SIZE(space, obj):
+def PyUnicode_GET_DATA_SIZE(space, w_obj):
     """Return the size of the object's internal buffer in bytes.  o has to be a
     PyUnicodeObject (not checked)."""
-    return rffi.sizeof(lltype.UniChar) * PyUnicode_GET_SIZE(space, obj)
+    return rffi.sizeof(lltype.UniChar) * PyUnicode_GET_SIZE(space, w_obj)
 
 @cpython_api([PyObject], Py_ssize_t, error=CANNOT_FAIL)
 def PyUnicode_GET_SIZE(space, w_obj):



More information about the Pypy-commit mailing list