This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: inspect.getmembers will call the instance __bases__ attribute, which may cause an exception
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.11
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ethan.furman, hongweipeng, ping, pitrou, terry.reedy, yselivanov
Priority: normal Keywords: patch

Created on 2021-12-16 15:40 by hongweipeng, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 30147 merged hongweipeng, 2021-12-16 15:46
Messages (3)
msg408717 - (view) Author: hongweipeng (hongweipeng) * Date: 2021-12-16 15:40
root@debian:/workspace/cpython# ./python
Python 3.11.0a3+ (heads/main-dirty:b123ad8030, Dec 16 2021, 06:16:15) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> class Foo:
...   def __getattr__(self, attr):
...     return None
>>> inspect.getmembers(Foo())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/workspace/cpython/Lib/", line 488, in getmembers
    return _getmembers(object, predicate, getattr)
  File "/workspace/cpython/Lib/", line 455, in _getmembers
    for base in object.__bases__:
TypeError: 'NoneType' object is not iterable
msg408827 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-12-18 00:20
PR edits inspect._getmembers. I nosied people who have edited it previously.
msg411389 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2022-01-23 17:40
New changeset 691506f4e9408a1205166f99640946ad7822e302 by Weipeng Hong in branch 'main':
bpo-46103: Fix inspect.getmembers to only get __bases__ from class (GH-30147)
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90261
2022-01-23 17:40:42ethan.furmansetmessages: + msg411389
2021-12-18 00:20:58terry.reedysetnosy: + yselivanov
2021-12-18 00:20:00terry.reedysetnosy: + terry.reedy, ethan.furman, pitrou, ping
messages: + msg408827
2021-12-16 15:46:53hongweipengsetkeywords: + patch
stage: patch review
pull_requests: + pull_request28367
2021-12-16 15:40:43hongweipengcreate