diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-10-14 21:32:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-14 21:32:03 (GMT) |
commit | 08ba7eb89d5353af31ef9e66a5337abea1b676ef (patch) | |
tree | 5e9ec56963b8e0fc4ebe7f1b08bdf6e9aa991775 /Objects/bytesobject.c | |
parent | 7c1c42b3209f1d2546daab6cd77f953eb255df6c (diff) | |
download | cpython-08ba7eb89d5353af31ef9e66a5337abea1b676ef.zip cpython-08ba7eb89d5353af31ef9e66a5337abea1b676ef.tar.gz cpython-08ba7eb89d5353af31ef9e66a5337abea1b676ef.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.
(cherry picked from commit e890421e334ccf0c000c6b29c4a521d86cd12f47)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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 04ebe0b..cd39ad6 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2606,7 +2606,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 */ } @@ -2788,6 +2788,9 @@ PyBytes_FromObject(PyObject *x) Py_DECREF(it); return result; } + if (!PyErr_ExceptionMatches(PyExc_TypeError)) { + return NULL; + } } PyErr_Format(PyExc_TypeError, |