summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-04-16 23:19:11 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-04-16 23:19:11 (GMT)
commit0ff8a505c6ae5bcca275bf04e5738e99fd6ec96d (patch)
tree1152ac33fed229b3f644f58852086d2adc5b3f08 /Objects/bytesobject.c
parent466e9266d1fb057219624f8adb0d6872d9cc0b18 (diff)
downloadcpython-0ff8a505c6ae5bcca275bf04e5738e99fd6ec96d.zip
cpython-0ff8a505c6ae5bcca275bf04e5738e99fd6ec96d.tar.gz
cpython-0ff8a505c6ae5bcca275bf04e5738e99fd6ec96d.tar.bz2
Merged revisions 80125,80128,80130 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r80125 | benjamin.peterson | 2010-04-16 17:35:32 -0500 (Fri, 16 Apr 2010) | 13 lines Merged revisions 80123-80124 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r80123 | benjamin.peterson | 2010-04-16 17:24:16 -0500 (Fri, 16 Apr 2010) | 1 line bytearray -> type2test ........ r80124 | benjamin.peterson | 2010-04-16 17:25:57 -0500 (Fri, 16 Apr 2010) | 1 line fix typo ........ ................ r80128 | benjamin.peterson | 2010-04-16 17:51:37 -0500 (Fri, 16 Apr 2010) | 9 lines 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 ........ ................ r80130 | benjamin.peterson | 2010-04-16 18:00:53 -0500 (Fri, 16 Apr 2010) | 9 lines Merged revisions 80129 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r80129 | benjamin.peterson | 2010-04-16 17:52:44 -0500 (Fri, 16 Apr 2010) | 1 line tiny simplification ........ ................
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 6584462..36d71c0 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -2949,15 +2949,17 @@ PyBytes_FromObject(PyObject *x)
}
/* Is it an int? */
- 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;