New submission from Serhiy Storchaka:

Initially hasattr() suppressed all raised exceptions. In issue2196 hasattr() 
was changed to suppress only Exception exceptions and propagate exceptions like 
SystemExit and KeyboardInterrupt. In issue9666 hasattr() was changed to 
suppress only AttributeError.

But C API functions, PyObject_HasAttr() and like, were not changed. 
PyObject_HasAttr() is documented as an equivalent of hasattr(), but there is 
undocumented difference. The C code that uses PyObject_HasAttr() starves from 
the same problem as the Python code that used old hasattr().

The only solution of this problem is getting rid of PyObject_HasAttr() if favor 
of PyObject_GetAttr(). In this issue I'm going to propose a set of PRs that 
replace PyObject_HasAttr() invocations in different components with more 
correct code.

----------
components: Extension Modules, Interpreter Core
messages: 302873
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Avoid suppressing all exceptions in PyObject_HasAttr()
type: behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31572>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to