File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -319,21 +319,25 @@ Type Objects
319319 * If not found, set *\* attr * to ``NULL `` and return ``0 ``.
320320 * On error, set an exception and return ``-1 ``.
321321
322- Python pseudo-code (return :exc: `AttributeError ` if not found instead of
323- raising an exception)::
322+ Python pseudo-code::
324323
325324 def PyType_Lookup(type, name):
326325 if not isinstance(name, str):
327326 raise TypeError
328327
329- for klass in type.mro():
328+ for superclass in type.mro():
329+ superclass_dict = superclass.__dict__
330330 try:
331- return klass.__dict__ [name]
331+ return superclass_dict [name]
332332 except KeyError:
333333 pass
334334
335335 # not found
336- return AttributeError
336+ return NULL
337+
338+ Note that this function uses :c:member: `~PyTypeObject.tp_dict ` and
339+ :c:member: `~PyTypeObject.tp_mro ` directly; it does not look up
340+ ``__dict__ `` and ``mro `` as Python attributes.
337341
338342 .. versionadded :: next
339343
You can’t perform that action at this time.
0 commit comments