summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-10-14 21:02:57 (GMT)
committerGitHub <noreply@github.com>2018-10-14 21:02:57 (GMT)
commite890421e334ccf0c000c6b29c4a521d86cd12f47 (patch)
tree17b21008d8c8faf50ca3d512e670c9a71aab4318 /Objects/bytesobject.c
parentde2aea0ff02fa9486365ce9d215bef150fae3a0b (diff)
downloadcpython-e890421e334ccf0c000c6b29c4a521d86cd12f47.zip
cpython-e890421e334ccf0c000c6b29c4a521d86cd12f47.tar.gz
cpython-e890421e334ccf0c000c6b29c4a521d86cd12f47.tar.bz2
bpo-34974: Do not replace unexpected errors in bytes() and bytearray(). (GH-9852)
bytes and bytearray constructors converted unexpected exceptions (e.g. MemoryError and KeyboardInterrupt) to TypeError.
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index d51d1ba..22d4687 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -2596,7 +2596,7 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (PyIndex_Check(x)) {
size = PyNumber_AsSsize_t(x, PyExc_OverflowError);
if (size == -1 && PyErr_Occurred()) {
- if (PyErr_ExceptionMatches(PyExc_OverflowError))
+ if (!PyErr_ExceptionMatches(PyExc_TypeError))
return NULL;
PyErr_Clear(); /* fall through */
}
@@ -2778,6 +2778,9 @@ PyBytes_FromObject(PyObject *x)
Py_DECREF(it);
return result;
}
+ if (!PyErr_ExceptionMatches(PyExc_TypeError)) {
+ return NULL;
+ }
}
PyErr_Format(PyExc_TypeError,