[New-bugs-announce] [issue35108] inspect.getmembers passes exceptions from object's properties through

Roman Inflianskas report at bugs.python.org
Tue Oct 30 04:20:35 EDT 2018


New submission from Roman Inflianskas <infroma at gmail.com>:

I use inspect.getmembers for getting members of splinter.webdriver.BaseWebDriver. The problem is that it has a property status_code raises NotImplementedError: https://github.com/cobrateam/splinter/blob/master/splinter/driver/webdriver/__init__.py#L191. This exception passes through try block in https://github.com/python/cpython/blob/master/Lib/inspect.py#L343 because it doesn't contain:
except Exception:
    pass
section.
In the result, instead of members of the object, I get an exception.

I think there are two possible expected behaviors:
1. Just ignore the exceptions and return members without the members, that raise exceptions.
2. Instead of members, return tuple like:
...
try:
    ...
except Exception as e:
    RAISES_EXCEPTION = object()
    value = (RAISES_EXCEPTION, e)
...

----------
components: Library (Lib)
messages: 328885
nosy: rominf
priority: normal
severity: normal
status: open
title: inspect.getmembers passes exceptions from object's properties through
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35108>
_______________________________________


More information about the New-bugs-announce mailing list