diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-10-15 00:02:57 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-15 00:02:57 +0300 |
commit | e890421e334ccf0c000c6b29c4a521d86cd12f47 (patch) | |
tree | 17b21008d8c8faf50ca3d512e670c9a71aab4318 /Objects/bytesobject.c | |
parent | de2aea0ff02fa9486365ce9d215bef150fae3a0b (diff) | |
download | cpython-git-e890421e334ccf0c000c6b29c4a521d86cd12f47.tar.gz |
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.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index d51d1ba023..22d46878a3 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, |