summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 175f5d6..2b28d8e 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -416,9 +416,14 @@ def findsource(object):
raise IOError, 'could not find code object'
def getcomments(object):
- """Get lines of comments immediately preceding an object's source code."""
- try: lines, lnum = findsource(object)
- except IOError: return None
+ """Get lines of comments immediately preceding an object's source code.
+
+ Returns None when source can't be found.
+ """
+ try:
+ lines, lnum = findsource(object)
+ except (IOError, TypeError):
+ return None
if ismodule(object):
# Look for a comment block at the top of the file.