Skip to content

Commit 945dcdf

Browse files
committed
Merge pull request #11 from kermit666/listcomp-py3
BUG: listcomp -> for-loop (listcopms create a new scope in py3), bypass AttributeError
2 parents adcc5da + b58dd60 commit 945dcdf

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

numpydoc/docscrape.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,14 @@ def splitlines_x(s):
499499
for field, items in [('Methods', self.methods),
500500
('Attributes', self.properties)]:
501501
if not self[field]:
502-
self[field] = [
503-
(name, '',
504-
splitlines_x(pydoc.getdoc(getattr(self._cls, name))))
505-
for name in sorted(items)]
502+
doc_list = []
503+
for name in sorted(items):
504+
try:
505+
doc_item = pydoc.getdoc(getattr(self._cls, name))
506+
doc_list.append((name, '', splitlines_x(doc_item)))
507+
except AttributeError:
508+
pass # method doesn't exist
509+
self[field] = doc_list
506510

507511
@property
508512
def methods(self):

0 commit comments

Comments
 (0)