Skip to content
Prev Previous commit
Next Next commit
fix build on mac/ubuntu
  • Loading branch information
iritkatriel committed May 11, 2021
commit c1d592f62a10bd38d34e43ba54b8cf91d15a758a
2 changes: 1 addition & 1 deletion Lib/test/test_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def non_Python_modules(): r"""

>>> import builtins
>>> tests = doctest.DocTestFinder().find(builtins)
>>> 816 < len(tests) < 838 # approximate number of objects with docstrings
>>> 816 < len(tests) < 840 # approximate number of objects with docstrings
True
>>> real_tests = [t for t in tests if len(t.examples) > 0]
>>> len(real_tests) # objects that actually have doctests
Expand Down
30 changes: 16 additions & 14 deletions Objects/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,14 @@ ComplexExtendsException(PyExc_BaseException, SystemExit, SystemExit,
* ExceptionGroup extends BaseExceptionGroup and Exception
*/

static PyObject *PyExc_ExceptionGroup;
PyObject *PyExc_ExceptionGroup;

static inline PyBaseExceptionGroupObject*
_PyBaseExceptionGroupObject_cast(PyObject *exc)
{
assert(PyObject_TypeCheck(exc, (PyTypeObject *)PyExc_BaseExceptionGroup));
return (PyBaseExceptionGroupObject *)exc;
}

static PyObject *
BaseExceptionGroup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Expand Down Expand Up @@ -696,7 +703,7 @@ BaseExceptionGroup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}

PyBaseExceptionGroupObject *self =
(PyBaseExceptionGroupObject*)BaseException_new(cls, args, kwds);
_PyBaseExceptionGroupObject_cast(BaseException_new(cls, args, kwds));
self->msg = Py_NewRef(msg);
self->excs = PySequence_Tuple(excs);
return (PyObject*)self;
Expand Down Expand Up @@ -752,9 +759,8 @@ BaseExceptionGroup_str(PyBaseExceptionGroupObject *self)
}

static PyObject *
BaseExceptionGroup_derive(PyBaseExceptionGroupObject *self,
PyObject *args, PyObject *kwds) {

BaseExceptionGroup_derive(PyObject *self_, PyObject *args, PyObject *kwds) {
PyBaseExceptionGroupObject *self = _PyBaseExceptionGroupObject_cast(self_);
PyObject *excs = NULL;
if (!PyArg_ParseTuple(args, "O", &excs)) {
return NULL;
Expand Down Expand Up @@ -861,7 +867,7 @@ exceptiongroup_split_recursive(PyObject *exc, PyObject *matcher, int complement)
}
else {
/* Partial match */
PyBaseExceptionGroupObject *eg = (PyBaseExceptionGroupObject *)exc;
PyBaseExceptionGroupObject *eg = _PyBaseExceptionGroupObject_cast(exc);
PyObject *match_list = NULL;
PyObject *rest_list = NULL;
PyObject *match_exc = NULL;
Expand Down Expand Up @@ -941,31 +947,27 @@ exceptiongroup_split_recursive(PyObject *exc, PyObject *matcher, int complement)
}

static PyObject *
BaseExceptionGroup_split(PyBaseExceptionGroupObject *self,
PyObject *args,
PyObject *kwds)
BaseExceptionGroup_split(PyObject *self, PyObject *args, PyObject *kwds)
{
PyObject *matcher = NULL;
if (!PyArg_UnpackTuple(args, "split", 1, 1, &matcher)) {
return NULL;
}

return exceptiongroup_split_recursive(
(PyObject*)self, matcher, 1 /* with_complement */);
self, matcher, 1 /* with_complement */);
}

static PyObject *
BaseExceptionGroup_subgroup(PyBaseExceptionGroupObject *self,
PyObject *args,
PyObject *kwds)
BaseExceptionGroup_subgroup(PyObject *self, PyObject *args, PyObject *kwds)
{
PyObject *matcher = NULL;
if (!PyArg_UnpackTuple(args, "subgroup", 1, 1, &matcher)) {
return NULL;
}

PyObject *ret = exceptiongroup_split_recursive(
(PyObject*)self, matcher, 0 /* without complement */);
self, matcher, 0 /* without complement */);

if (!ret) {
return NULL;
Expand Down