mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
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.
This commit is contained in:
parent
de2aea0ff0
commit
e890421e33
4 changed files with 24 additions and 5 deletions
|
|
@ -41,7 +41,6 @@ _getbytevalue(PyObject* arg, int *value)
|
|||
} else {
|
||||
PyObject *index = PyNumber_Index(arg);
|
||||
if (index == NULL) {
|
||||
PyErr_Format(PyExc_TypeError, "an integer is required");
|
||||
*value = -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -821,7 +820,7 @@ bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
|
|||
if (PyIndex_Check(arg)) {
|
||||
count = PyNumber_AsSsize_t(arg, PyExc_OverflowError);
|
||||
if (count == -1 && PyErr_Occurred()) {
|
||||
if (PyErr_ExceptionMatches(PyExc_OverflowError))
|
||||
if (!PyErr_ExceptionMatches(PyExc_TypeError))
|
||||
return -1;
|
||||
PyErr_Clear(); /* fall through */
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue