diff options
| author | Christoph Reiter <reiter.christoph@gmail.com> | 2018-04-05 16:16:21 +0200 |
|---|---|---|
| committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-04-05 16:18:58 +0200 |
| commit | 25a5b066467523547d3b3c1947ae3722c3fc38d5 (patch) | |
| tree | a90ba0efe551631824b4376f5f2e57f54bd47161 /gi/pygi-util.c | |
| parent | 5f961b426b9bd25956e5364770c71c34c414d4e6 (diff) | |
| download | pygobject-25a5b066467523547d3b3c1947ae3722c3fc38d5.tar.gz | |
More compiler warning fixes for Windows/32bit #191
Diffstat (limited to 'gi/pygi-util.c')
| -rw-r--r-- | gi/pygi-util.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gi/pygi-util.c b/gi/pygi-util.c index 734d02fc..ee322238 100644 --- a/gi/pygi-util.c +++ b/gi/pygi-util.c @@ -18,6 +18,20 @@ #include "pygi-util.h" +gboolean +pygi_guint_from_pyssize (Py_ssize_t pyval, guint *result) +{ + if (pyval < 0) { + PyErr_SetString (PyExc_ValueError, "< 0"); + return FALSE; + } else if (G_MAXUINT < PY_SSIZE_T_MAX && pyval > (Py_ssize_t)G_MAXUINT) { + PyErr_SetString (PyExc_ValueError, "too large"); + return FALSE; + } + *result = (guint)pyval; + return TRUE; +} + /* Better alternative to PyImport_ImportModule which tries to import from * sys.modules first */ PyObject * |
