From: Mark Wooding Date: Tue, 7 Mar 2006 14:12:42 +0000 (+0000) Subject: util: Report ValuError (not TypeError) for failed integer conversions. X-Git-Url: https://git.distorted.org.uk/~mdw/pyke/commitdiff_plain/799dffb291a9e8600ca2385ce9545ac3559863f8 util: Report ValuError (not TypeError) for failed integer conversions. --- diff --git a/util.c b/util.c index 86b7aba..27af83a 100644 --- a/util.c +++ b/util.c @@ -62,7 +62,7 @@ int convulong(PyObject *o, void *pp) if (PyInt_Check(o)) { i = PyInt_AS_LONG(o); - if (i < 0) TYERR("must be nonnegative"); + if (i < 0) VALERR("must be nonnegative"); *p = i; } else { if ((t = PyNumber_Long(o)) == 0) goto end; @@ -82,7 +82,7 @@ end: uint##n *p = pp; \ \ if (!convulong(o, &u)) goto end; \ - if (u > MASK##n) TYERR("out of range"); \ + if (u > MASK##n) VALERR("out of range"); \ *p = u; \ return (1); \ end: \ @@ -96,7 +96,7 @@ int convuint(PyObject *o, void *pp) unsigned *p = pp; if (!convulong(o, &u)) goto end; - if (u > UINT_MAX) TYERR("out of range"); + if (u > UINT_MAX) VALERR("out of range"); *p = u; return (1); end: @@ -109,7 +109,7 @@ int convmpw(PyObject *o, void *pp) unsigned *p = pp; if (!convulong(o, &u)) goto end; - if (u > MPW_MAX) TYERR("out of range"); + if (u > MPW_MAX) VALERR("out of range"); *p = u; return (1); end: @@ -122,7 +122,7 @@ int convszt(PyObject *o, void *pp) size_t *p = pp; if (!convulong(o, &u)) goto end; - if (u > ~(size_t)0) TYERR("out of range"); + if (u > ~(size_t)0) VALERR("out of range"); *p = u; return (1); end: