summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-04-16 22:51:37 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-04-16 22:51:37 (GMT)
commit8380dd5aa42372929fe962ebdc3c180d929e497a (patch)
tree8d26a672eb08d5069ca549fb265d2e012363b657 /Objects
parent4c04583e790c424b9360774fe7055576e925b534 (diff)
downloadcpython-8380dd5aa42372929fe962ebdc3c180d929e497a.zip
cpython-8380dd5aa42372929fe962ebdc3c180d929e497a.tar.gz
cpython-8380dd5aa42372929fe962ebdc3c180d929e497a.tar.bz2
Merged revisions 80126 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80126 | benjamin.peterson | 2010-04-16 17:35:38 -0500 (Fri, 16 Apr 2010) | 1 line have a clear error when passing something > sys.maxsize to bytearray ........
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytearrayobject.c18
-rw-r--r--Objects/bytesobject.c12
2 files changed, 18 insertions, 12 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 8f833d8..4d32ea7 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -753,14 +753,18 @@ bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
}
/* Is it an int? */
- count = PyNumber_AsSsize_t(arg, PyExc_ValueError);
- if (count == -1 && PyErr_Occurred())
- PyErr_Clear();
- else {
- if (count < 0) {
- PyErr_SetString(PyExc_ValueError, "negative count");
+ count = PyNumber_AsSsize_t(arg, PyExc_OverflowError);
+ if (count == -1 && PyErr_Occurred()) {
+ if (PyErr_ExceptionMatches(PyExc_OverflowError))
return -1;
- }
+ else
+ PyErr_Clear();
+ }
+ else if (count < 0) {
+ PyErr_SetString(PyExc_ValueError, "negative count");
+ return -1;
+ }
+ else {
if (count > 0) {
if (PyByteArray_Resize((PyObject *)self, count))
return -1;
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 890d044..a05bf03 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -2545,15 +2545,17 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return new;
}
/* Is it an integer? */
- size = PyNumber_AsSsize_t(x, PyExc_ValueError);
+ size = PyNumber_AsSsize_t(x, PyExc_OverflowError);
if (size == -1 && PyErr_Occurred()) {
+ if (PyErr_ExceptionMatches(PyExc_OverflowError))
+ return NULL;
PyErr_Clear();
}
+ else if (size < 0) {
+ PyErr_SetString(PyExc_ValueError, "negative count");
+ return NULL;
+ }
else {
- if (size < 0) {
- PyErr_SetString(PyExc_ValueError, "negative count");
- return NULL;
- }
new = PyBytes_FromStringAndSize(NULL, size);
if (new == NULL) {
return NULL;