mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
merge 3.2 (#11627)
This commit is contained in:
commit
e92cd0ce98
3 changed files with 19 additions and 0 deletions
|
@ -121,6 +121,15 @@ class TestRaise(unittest.TestCase):
|
||||||
else:
|
else:
|
||||||
self.fail("No exception raised")
|
self.fail("No exception raised")
|
||||||
|
|
||||||
|
def test_new_returns_invalid_instance(self):
|
||||||
|
# See issue #11627.
|
||||||
|
class MyException(Exception):
|
||||||
|
def __new__(cls, *args):
|
||||||
|
return object()
|
||||||
|
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
raise MyException
|
||||||
|
|
||||||
|
|
||||||
class TestCause(unittest.TestCase):
|
class TestCause(unittest.TestCase):
|
||||||
def test_invalid_cause(self):
|
def test_invalid_cause(self):
|
||||||
|
|
|
@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #11627: Fix segfault when __new__ on a exception returns a non-exception
|
||||||
|
class.
|
||||||
|
|
||||||
- Issue #12149: Update the method cache after a type's dictionnary gets
|
- Issue #12149: Update the method cache after a type's dictionnary gets
|
||||||
cleared by the garbage collector. This fixes a segfault when an instance
|
cleared by the garbage collector. This fixes a segfault when an instance
|
||||||
and its type get caught in a reference cycle, and the instance's
|
and its type get caught in a reference cycle, and the instance's
|
||||||
|
|
|
@ -3494,6 +3494,13 @@ do_raise(PyObject *exc, PyObject *cause)
|
||||||
value = PyObject_CallObject(exc, NULL);
|
value = PyObject_CallObject(exc, NULL);
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
goto raise_error;
|
goto raise_error;
|
||||||
|
if (!PyExceptionInstance_Check(value)) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"calling %R should have returned an instance of "
|
||||||
|
"BaseException, not %R",
|
||||||
|
type, Py_TYPE(value));
|
||||||
|
goto raise_error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (PyExceptionInstance_Check(exc)) {
|
else if (PyExceptionInstance_Check(exc)) {
|
||||||
value = exc;
|
value = exc;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue