Index: Lib/inspect.py =================================================================== --- Lib/inspect.py (revision 67665) +++ Lib/inspect.py (working copy) @@ -657,6 +657,7 @@ # (note that this only works for "def"/"class" blocks, # not e.g. for "if: else:" or "try: finally:" blocks) if self.indent <= 0: + self.last = srow raise EndOfBlock elif self.indent == 0 and type not in (tokenize.COMMENT, tokenize.NL): # any other token on the same indentation level end the previous