diff options
author | Georg Brandl <georg@python.org> | 2009-01-01 12:15:31 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-01-01 12:15:31 (GMT) |
commit | 6269fec171191a38e418dc6b94697ca4fe6e4160 (patch) | |
tree | 9f3999fff773c450ef8a3873069e22cc4a69381a /Modules | |
parent | 775c30706882291fe6385066899f702f768ed95f (diff) | |
download | cpython-6269fec171191a38e418dc6b94697ca4fe6e4160.zip cpython-6269fec171191a38e418dc6b94697ca4fe6e4160.tar.gz cpython-6269fec171191a38e418dc6b94697ca4fe6e4160.tar.bz2 |
#4228: Pack negative values the same way as 2.4
in struct's L format.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_struct.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c index 30feaa6..b8f1525 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -663,7 +663,7 @@ np_int(char *p, PyObject *v, const formatdef *f) return -1; #if (SIZEOF_LONG > SIZEOF_INT) if ((x < ((long)INT_MIN)) || (x > ((long)INT_MAX))) - return _range_error(f, 0); + RANGE_ERROR(x, f, 0, -1); #endif y = (int)x; memcpy(p, (char *)&y, sizeof y); @@ -675,12 +675,12 @@ np_uint(char *p, PyObject *v, const formatdef *f) { unsigned long x; unsigned int y; - if (get_ulong(v, &x) < 0) - return _range_error(f, 1); + if (get_wrapped_ulong(v, &x) < 0) + return -1; y = (unsigned int)x; #if (SIZEOF_LONG > SIZEOF_INT) if (x > ((unsigned long)UINT_MAX)) - return _range_error(f, 1); + RANGE_ERROR(y, f, 1, -1); #endif memcpy(p, (char *)&y, sizeof y); return 0; @@ -700,8 +700,8 @@ static int np_ulong(char *p, PyObject *v, const formatdef *f) { unsigned long x; - if (get_ulong(v, &x) < 0) - return _range_error(f, 1); + if (get_wrapped_ulong(v, &x) < 0) + return -1; memcpy(p, (char *)&x, sizeof x); return 0; } |