mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Make sure to iterate obj_dict's keys using list, not view
In Python3 `dict.keys()` returns a view object not a list
cherry-picked from master 22ce010e0
to stable for #2116.
This commit is contained in:
parent
f29edef477
commit
906d1c905d
@ -17,7 +17,8 @@ import inspect
|
||||
import traceback
|
||||
from types import FunctionType, BuiltinFunctionType, MethodType
|
||||
|
||||
from six import iteritems, itervalues, text_type, class_types, string_types
|
||||
from six import iterkeys, iteritems, itervalues, text_type, class_types, \
|
||||
string_types
|
||||
from docutils import nodes
|
||||
from docutils.utils import assemble_option_dict
|
||||
from docutils.statemachine import ViewList
|
||||
@ -598,7 +599,7 @@ class Documenter(object):
|
||||
# __dict__ contains only the members directly defined in
|
||||
# the class (but get them via getattr anyway, to e.g. get
|
||||
# unbound method objects instead of function objects);
|
||||
# using keys() because apparently there are objects for which
|
||||
# using list(iterkeys()) because apparently there are objects for which
|
||||
# __dict__ changes while getting attributes
|
||||
try:
|
||||
obj_dict = self.get_attr(self.object, '__dict__')
|
||||
@ -606,7 +607,7 @@ class Documenter(object):
|
||||
members = []
|
||||
else:
|
||||
members = [(mname, self.get_attr(self.object, mname, None))
|
||||
for mname in list(obj_dict.keys())]
|
||||
for mname in list(iterkeys(obj_dict))]
|
||||
membernames = set(m[0] for m in members)
|
||||
# add instance attributes from the analyzer
|
||||
for aname in analyzed_member_names:
|
||||
|
Loading…
Reference in New Issue
Block a user