lib/gen_pyobject.py: fix size checks
authorPaul Brossier <piem@piem.org>
Tue, 10 Dec 2013 22:57:54 +0000 (17:57 -0500)
committerPaul Brossier <piem@piem.org>
Tue, 10 Dec 2013 22:57:54 +0000 (17:57 -0500)
Signed-off-by: Paul Brossier <piem@piem.org>
python/lib/gen_pyobject.py

index d3f7261..ba8274e 100644 (file)
@@ -239,9 +239,9 @@ Py_%(name)s_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
             s += """\
 
   self->%(pname)s = %(defval)s;
-  if (%(pname)s > 0) {
+  if ((sint_t)%(pname)s > 0) {
     self->%(pname)s = %(pname)s;
-  } else if (%(pname)s < 0) {
+  } else if ((sint_t)%(pname)s < 0) {
     PyErr_SetString (PyExc_ValueError,
         "can not use negative value for %(pname)s");
     return NULL;