[pygobject] Fix error messages for out of range numbers
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Fix error messages for out of range numbers
- Date: Fri, 28 Sep 2012 05:59:10 +0000 (UTC)
commit 34270a109d2af20391c80e88874ee7303eaf5c09
Author: Martin Pitt <martinpitt gnome org>
Date: Fri Sep 28 07:42:51 2012 +0200
Fix error messages for out of range numbers
PyErr_Format() does not understand %lli and %li, it needs to be %lld and %ld.
So we cannot use those and G_GINT64_FORMAT.
Also remove the "if (long_ < G_MININT64 || long_ > G_MAXINT64)" check, as long_
is a gint64 which can't possibly overflow its own data type. It would also have
an unprintable error message.
https://bugzilla.gnome.org/show_bug.cgi?id=684314
gi/pygi-marshal-from-py.c | 21 ++++++++-------------
1 files changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c
index a6572ef..d3e61da 100644
--- a/gi/pygi-marshal-from-py.c
+++ b/gi/pygi-marshal-from-py.c
@@ -376,12 +376,12 @@ _pygi_marshal_from_py_uint16 (PyGIInvokeState *state,
if (PyErr_Occurred ()) {
PyErr_Clear ();
- PyErr_Format (PyExc_ValueError, "%li not in range %d to %d", long_, 0, 65535);
+ PyErr_Format (PyExc_ValueError, "%ld not in range %d to %d", long_, 0, 65535);
return FALSE;
}
if (long_ < 0 || long_ > 65535) {
- PyErr_Format (PyExc_ValueError, "%li not in range %d to %d", long_, 0, 65535);
+ PyErr_Format (PyExc_ValueError, "%ld not in range %d to %d", long_, 0, 65535);
return FALSE;
}
@@ -460,12 +460,12 @@ _pygi_marshal_from_py_uint32 (PyGIInvokeState *state,
if (PyErr_Occurred ()) {
PyErr_Clear ();
- PyErr_Format (PyExc_ValueError, "%lli not in range %i to %u", long_, 0, G_MAXUINT32);
+ PyErr_Format (PyExc_ValueError, "%lld not in range %i to %u", long_, 0, G_MAXUINT32);
return FALSE;
}
if (long_ < 0 || long_ > G_MAXUINT32) {
- PyErr_Format (PyExc_ValueError, "%lli not in range %i to %u", long_, 0, G_MAXUINT32);
+ PyErr_Format (PyExc_ValueError, "%lld not in range %i to %u", long_, 0, G_MAXUINT32);
return FALSE;
}
@@ -531,18 +531,13 @@ _pygi_marshal_from_py_int64 (PyGIInvokeState *state,
Py_DECREF (py_str);
}
- PyErr_Format (PyExc_ValueError, "%s not in range %" G_GINT64_FORMAT " to %" G_GINT64_FORMAT,
- long_str, G_MININT64, G_MAXINT64);
+ PyErr_Format (PyExc_ValueError, "%s not in range %lld to %lld",
+ long_str, (long long) G_MININT64, (long long) G_MAXINT64);
g_free (long_str);
return FALSE;
}
- if (long_ < G_MININT64 || long_ > G_MAXINT64) {
- PyErr_Format (PyExc_ValueError, "%" G_GINT64_FORMAT " not in range %" G_GINT64_FORMAT " to %" G_GINT64_FORMAT, long_, G_MININT64, G_MAXINT64);
- return FALSE;
- }
-
arg->v_int64 = long_;
return TRUE;
@@ -741,8 +736,8 @@ _pygi_marshal_from_py_unichar (PyGIInvokeState *state,
}
if (size != 1) {
- PyErr_Format (PyExc_TypeError, "Must be a one character string, not %" G_GINT64_FORMAT " characters",
- (gint64) size);
+ PyErr_Format (PyExc_TypeError, "Must be a one character string, not %lld characters",
+ (long long) size);
g_free (string_);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]