diff options
author | Armin Rigo <arigo@tunes.org> | 2019-04-02 16:39:56 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2019-04-02 16:39:56 +0200 |
commit | f474398bd2ca7eea2fdb7e61ce9d4b8dd1aa7afa (patch) | |
tree | 67f458fdee73c70c07378e06beb14df054030ce6 /c/_cffi_backend.c | |
parent | 2746f3611a64a46e91b516ea1bf9c045d9dfcf69 (diff) | |
download | cffi-f474398bd2ca7eea2fdb7e61ce9d4b8dd1aa7afa.tar.gz |
Shut down a warning from recent CPython versions: int() should
always return an int, not a bool
Diffstat (limited to 'c/_cffi_backend.c')
-rw-r--r-- | c/_cffi_backend.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c index ac0bc2a..bc7de37 100644 --- a/c/_cffi_backend.c +++ b/c/_cffi_backend.c @@ -2193,7 +2193,10 @@ static PyObject *cdata_int(CDataObject *cd) return PyInt_FromLong(value); } if (cd->c_type->ct_flags & (CT_PRIMITIVE_SIGNED|CT_PRIMITIVE_UNSIGNED)) { - return convert_to_object(cd->c_data, cd->c_type); + PyObject *result = convert_to_object(cd->c_data, cd->c_type); + if (result != NULL && PyBool_Check(result)) + result = PyInt_FromLong(PyInt_AsLong(result)); + return result; } else if (cd->c_type->ct_flags & CT_PRIMITIVE_CHAR) { /*READ(cd->c_data, cd->c_type->ct_size)*/ |