[pypy-commit] pypy py3k: Fix some cpyext compilation warnings

rlamy pypy.commits at gmail.com
Fri May 13 15:55:15 EDT 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3k
Changeset: r84427:6f241f23a344
Date: 2016-05-13 20:54 +0100
http://bitbucket.org/pypy/pypy/changeset/6f241f23a344/

Log:	Fix some cpyext compilation warnings

diff --git a/pypy/module/cpyext/floatobject.py b/pypy/module/cpyext/floatobject.py
--- a/pypy/module/cpyext/floatobject.py
+++ b/pypy/module/cpyext/floatobject.py
@@ -68,7 +68,9 @@
     backward compatibility."""
     return space.call_function(space.w_float, w_obj)
 
- at cpython_api([CONST_STRING, rffi.INT_real], rffi.DOUBLE, error=-1.0)
+UCHARP = lltype.Ptr(lltype.Array(
+    rffi.UCHAR, hints={'nolength':True, 'render_as_const':True}))
+ at cpython_api([UCHARP, rffi.INT_real], rffi.DOUBLE, error=-1.0)
 def _PyFloat_Unpack4(space, ptr, le):
     input = rffi.charpsize2str(ptr, 4)
     if rffi.cast(lltype.Signed, le):
@@ -76,11 +78,10 @@
     else:
         return runpack.runpack(">f", input)
 
- at cpython_api([CONST_STRING, rffi.INT_real], rffi.DOUBLE, error=-1.0)
+ at cpython_api([UCHARP, rffi.INT_real], rffi.DOUBLE, error=-1.0)
 def _PyFloat_Unpack8(space, ptr, le):
     input = rffi.charpsize2str(ptr, 8)
     if rffi.cast(lltype.Signed, le):
         return runpack.runpack("<d", input)
     else:
         return runpack.runpack(">d", input)
-
diff --git a/pypy/module/cpyext/longobject.py b/pypy/module/cpyext/longobject.py
--- a/pypy/module/cpyext/longobject.py
+++ b/pypy/module/cpyext/longobject.py
@@ -88,7 +88,7 @@
 def PyLong_AsSize_t(space, w_long):
     """Return a C size_t representation of of pylong.  pylong must be
     an instance of PyLongObject.
-    
+
     Raise OverflowError if the value of pylong is out of range for a
     size_t."""
     return space.uint_w(w_long)
@@ -232,7 +232,8 @@
     assert isinstance(w_long, W_LongObject)
     return w_long.num.sign
 
-UCHARP = rffi.CArrayPtr(rffi.UCHAR)
+UCHARP = lltype.Ptr(lltype.Array(
+    rffi.UCHAR, hints={'nolength':True, 'render_as_const':True}))
 @cpython_api([UCHARP, rffi.SIZE_T, rffi.INT_real, rffi.INT_real], PyObject)
 def _PyLong_FromByteArray(space, bytes, n, little_endian, signed):
     little_endian = rffi.cast(lltype.Signed, little_endian)
diff --git a/pypy/module/cpyext/sliceobject.py b/pypy/module/cpyext/sliceobject.py
--- a/pypy/module/cpyext/sliceobject.py
+++ b/pypy/module/cpyext/sliceobject.py
@@ -64,7 +64,7 @@
         w_step = space.w_None
     return W_SliceObject(w_start, w_stop, w_step)
 
- at cpython_api([PySliceObject, Py_ssize_t, Py_ssize_tP, Py_ssize_tP, Py_ssize_tP,
+ at cpython_api([PyObject, Py_ssize_t, Py_ssize_tP, Py_ssize_tP, Py_ssize_tP,
                 Py_ssize_tP], rffi.INT_real, error=-1)
 def PySlice_GetIndicesEx(space, w_slice, length, start_p, stop_p, step_p,
                          slicelength_p):
@@ -73,7 +73,7 @@
     length length, and store the length of the slice in slicelength.  Out
     of bounds indices are clipped in a manner consistent with the handling of
     normal slices.
-    
+
     Returns 0 on success and -1 on error with exception set."""
     if not PySlice_Check(space, w_slice):
         PyErr_BadInternalCall(space)
@@ -82,17 +82,17 @@
             w_slice.indices4(space, length)
     return 0
 
- at cpython_api([PySliceObject, Py_ssize_t, Py_ssize_tP, Py_ssize_tP, Py_ssize_tP],
+ at cpython_api([PyObject, Py_ssize_t, Py_ssize_tP, Py_ssize_tP, Py_ssize_tP],
                 rffi.INT_real, error=-1)
 def PySlice_GetIndices(space, w_slice, length, start_p, stop_p, step_p):
     """Retrieve the start, stop and step indices from the slice object slice,
     assuming a sequence of length length. Treats indices greater than
     length as errors.
-    
+
     Returns 0 on success and -1 on error with no exception set (unless one of
     the indices was not None and failed to be converted to an integer,
     in which case -1 is returned with an exception set).
-    
+
     You probably do not want to use this function.  If you want to use slice
     objects in versions of Python prior to 2.3, you would probably do well to
     incorporate the source of PySlice_GetIndicesEx(), suitably renamed,
diff --git a/pypy/module/cpyext/test/array.c b/pypy/module/cpyext/test/array.c
--- a/pypy/module/cpyext/test/array.c
+++ b/pypy/module/cpyext/test/array.c
@@ -1738,7 +1738,7 @@
 
     typecode = (Py_UNICODE)typecode_int;
 
-    if (!PyType_Check(arraytype)) {
+    if (!PyType_Check((PyObject *)arraytype)) {
         PyErr_Format(PyExc_TypeError,
             "first argument must a type object, not %.200s",
             Py_TYPE(arraytype)->tp_name);


More information about the pypy-commit mailing list