diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-10-14 14:26:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-14 14:26:28 -0700 |
commit | 1370832af24cc6f0f464354b9ec3ecdb343d35ce (patch) | |
tree | 93c714cf7ec6865db609ed1addb320a771f7c1fa /Objects/bytesobject.c | |
parent | 91b863d93b93e15799af10d9117982840ecf3462 (diff) | |
download | cpython-git-1370832af24cc6f0f464354b9ec3ecdb343d35ce.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.
(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 32ff5afe3e..5b62842093 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2597,7 +2597,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 */ } @@ -2779,6 +2779,9 @@ PyBytes_FromObject(PyObject *x) Py_DECREF(it); return result; } + if (!PyErr_ExceptionMatches(PyExc_TypeError)) { + return NULL; + } } PyErr_Format(PyExc_TypeError, |