spacepaste

  1.  
  2. diff -r 4ffa41843837 py/_code/source.py
  3. --- a/py/_code/source.py Sun Oct 21 23:35:10 2012 -0600
  4. +++ b/py/_code/source.py Mon Oct 22 16:25:14 2012 +0200
  5. @@ -118,7 +118,7 @@
  6. # 1. find the start of the statement
  7. from codeop import compile_command
  8. end = None
  9. - for start in range(lineno, -1, -1):
  10. + for start in range(lineno, -1, max(-1, lineno - 10)):
  11. if assertion:
  12. line = self.lines[start]
  13. # the following lines are not fully tested, change with care
  14. @@ -135,9 +135,9 @@
  15. compile_command(trysource)
  16. except (SyntaxError, OverflowError, ValueError):
  17. continue
  18. -
  19. +
  20. # 2. find the end of the statement
  21. - for end in range(lineno+1, len(self)+1):
  22. + for end in range(lineno+1, min(len(self)+1, lineno + 10)):
  23. trysource = self[start:end]
  24. if trysource.isparseable():
  25. return start, end
  26.