Skip to content

Commit 2059c7f

Browse files
committed
fixup news, modify test assertions
1 parent ef8e9ed commit 2059c7f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Change the handling of errors raised from descriptor :meth:`__get__`
1+
Change the handling of errors raised from descriptor ``__get__``
22
accessing some special (dunder) methods.
33

4-
* Raising :class:`AttributeError` from :meth:`__get__` will continue to treat the method *as though it was not defined*, and special methods that had a fallback will continue to fallback.
4+
* Raising ``AttributeError`` from ``__get__`` will continue to treat the method *as though it was not defined*, and special methods that had a fallback will continue to fallback.
55
* Other errors will be propagated as-is.
6-
* Directly affects :meth:`__eq__` (and other comparisons), :meth:`__hash__`, :meth:`__repr__`, :meth:`__iter__`.
7-
* :meth:`__del__` will report as un-raisable.
8-
* May affect :meth:`__contains__`, :meth:`__bool__`, :meth:`__await__`, :meth:`__aiter__`, :meth:`__anext__`.
6+
* Directly affects ``__eq__`` (and other comparisons), ``__hash__``, ``__repr__``, ``__iter__``.
7+
* ``__del__`` will report as un-raisable.
8+
* May affect ``__contains__``, ``__bool__``, ``__await__``, ``__aiter__``, ``__anext__``.

Objects/typeobject.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,8 +2814,9 @@ static PyObject *
28142814
lookup_maybe_method(PyObject *self, PyObject *attr, int *unbound, PyObject* exc_ignored)
28152815
{
28162816
PyObject *res = _PyType_LookupRef(Py_TYPE(self), attr);
2817+
assert(!PyErr_Occurred());
2818+
28172819
if (res == NULL) {
2818-
assert(!PyErr_Occurred());
28192820
Py_RETURN_NOTIMPLEMENTED;
28202821
}
28212822

@@ -2829,7 +2830,7 @@ lookup_maybe_method(PyObject *self, PyObject *attr, int *unbound, PyObject* exc_
28292830
if (f != NULL) {
28302831
Py_SETREF(res, f(res, self, (PyObject *)(Py_TYPE(self))));
28312832

2832-
assert(!!res || PyErr_Occurred());
2833+
assert((!res)^(!PyErr_Occurred()));
28332834

28342835
if(res == NULL && exc_ignored && PyErr_ExceptionMatches(exc_ignored)){
28352836
// TODO: even though the docs say check before calling PyErr_ExceptionMatches,
@@ -2918,6 +2919,7 @@ vectorcall_maybe(PyThreadState *tstate, PyObject *name,
29182919

29192920
int unbound;
29202921
PyObject *self = args[0];
2922+
// TODO: PyExc_AttributeError shouldn't be ignored in this case for some reason?
29212923
PyObject *func = lookup_maybe_method(self, name, &unbound, PyExc_AttributeError);
29222924
if (func == NULL || func == Py_NotImplemented) {
29232925
return func;

0 commit comments

Comments
 (0)