diff options
author | Thomas Heller <theller@ctypes.org> | 2007-06-08 19:01:06 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2007-06-08 19:01:06 (GMT) |
commit | 6088f24df28051a9ac62b7b9c43930de8f32a9d2 (patch) | |
tree | d3441d570fa1df2fe841455aaa6c3a380542252e /Modules | |
parent | e81c9f6d5e22dbe4252ea578211710daea95347d (diff) | |
download | cpython-6088f24df28051a9ac62b7b9c43930de8f32a9d2.zip cpython-6088f24df28051a9ac62b7b9c43930de8f32a9d2.tar.gz cpython-6088f24df28051a9ac62b7b9c43930de8f32a9d2.tar.bz2 |
Fix gcc warnings intruduced by passing Py_ssize_t to PyErr_Format calls.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 11 | ||||
-rw-r--r-- | Modules/_ctypes/cfield.c | 20 | ||||
-rw-r--r-- | Modules/_ctypes/stgdict.c | 4 |
3 files changed, 24 insertions, 11 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 838dcaf..34b6829 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -1769,7 +1769,12 @@ converters_from_argtypes(PyObject *ob) Py_XDECREF(converters); Py_DECREF(ob); PyErr_Format(PyExc_TypeError, - "item %d in _argtypes_ has no from_param method", i+1); +#if (PY_VERSION_HEX < 0x02050000) + "item %d in _argtypes_ has no from_param method", +#else + "item %zd in _argtypes_ has no from_param method", +#endif + i+1); return NULL; } @@ -3191,7 +3196,11 @@ _build_callargs(CFuncPtrObject *self, PyObject *argtypes, message is misleading. See unittests/test_paramflags.py */ PyErr_Format(PyExc_TypeError, +#if (PY_VERSION_HEX < 0x02050000) "call takes exactly %d arguments (%d given)", +#else + "call takes exactly %d arguments (%zd given)", +#endif inargs_index, actual_args); goto error; } diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index b5f1b8a..ccdab0a 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -220,21 +220,13 @@ CField_get(CFieldObject *self, PyObject *inst, PyTypeObject *type) static PyObject * CField_get_offset(PyObject *self, void *data) { -#if (PY_VERSION_HEX < 0x02050000) - return PyInt_FromLong(((CFieldObject *)self)->offset); -#else return PyInt_FromSsize_t(((CFieldObject *)self)->offset); -#endif } static PyObject * CField_get_size(PyObject *self, void *data) { -#if (PY_VERSION_HEX < 0x02050000) - return PyInt_FromLong(((CFieldObject *)self)->size); -#else return PyInt_FromSsize_t(((CFieldObject *)self)->size); -#endif } static PyGetSetDef CField_getset[] = { @@ -279,7 +271,7 @@ CField_repr(CFieldObject *self) #if (PY_VERSION_HEX < 0x02050000) "<Field type=%s, ofs=%d:%d, bits=%d>", #else - "<Field type=%s, ofs=%zd:%d, bits=%d>", + "<Field type=%s, ofs=%zd:%zd, bits=%zd>", #endif name, self->offset, size, bits); else @@ -287,7 +279,7 @@ CField_repr(CFieldObject *self) #if (PY_VERSION_HEX < 0x02050000) "<Field type=%s, ofs=%d, size=%d>", #else - "<Field type=%s, ofs=%zd, size=%d>", + "<Field type=%s, ofs=%zd, size=%zd>", #endif name, self->offset, size); return result; @@ -1263,7 +1255,11 @@ U_set(void *ptr, PyObject *value, Py_ssize_t length) size = PyUnicode_GET_SIZE(value); if (size > length) { PyErr_Format(PyExc_ValueError, +#if (PY_VERSION_HEX < 0x02050000) "string too long (%d, maximum length %d)", +#else + "string too long (%zd, maximum length %zd)", +#endif size, length); Py_DECREF(value); return NULL; @@ -1316,7 +1312,11 @@ s_set(void *ptr, PyObject *value, Py_ssize_t length) ++size; } else if (size > length) { PyErr_Format(PyExc_ValueError, +#if (PY_VERSION_HEX < 0x02050000) "string too long (%d, maximum length %d)", +#else + "string too long (%zd, maximum length %zd)", +#endif size, length); return NULL; } diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index 5815fea..b72bf67 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -406,7 +406,11 @@ StructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct) if (dict == NULL) { Py_DECREF(pair); PyErr_Format(PyExc_TypeError, +#if (PY_VERSION_HEX < 0x02050000) "second item in _fields_ tuple (index %d) must be a C type", +#else + "second item in _fields_ tuple (index %zd) must be a C type", +#endif i); return -1; } |