call site 2 for code.Source.__len__
code/testing/test_excinfo.py - line 184
178
179
180
181
182
183
184
185
   def test_tbentry_reinterpret(): 
       try: 
           hello("hello") 
       except TypeError: 
           excinfo = py.code.ExceptionInfo() 
       tbentry = excinfo.traceback[-1]
->     msg = tbentry.reinterpret() 
       assert msg.startswith("TypeError: ('hello' + 5)") 
code/traceback2.py - line 42
37
38
39
40
41
42
43
44
45
46
47
   def reinterpret(self):
       """Reinterpret the failing statement and returns a detailed information
              about what operations are performed."""
       if self.exprinfo is None:
           from py.__.magic import exprinfo
->         source = str(self.statement).strip()
           x = exprinfo.interpret(source, self.frame, should_fail=True)
           if not isinstance(x, str):
               raise TypeError, "interpret returned non-string %r" % (x,)
           self.exprinfo = x 
       return self.exprinfo
code/traceback2.py - line 25
22
23
24
25
   def statement(self):
       """ return a py.code.Source object for the current statement """
       source = self.frame.code.fullsource
->     return source.getstatement(self.lineno)
code/source.py - line 95
91
92
93
94
95
96
   def getstatement(self, lineno):
       """ return Source statement which contains the
               given linenumber (counted from 0).
           """
->     start, end = self.getstatementrange(lineno)
       return self[start:end]
code/source.py - line 104
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
   def getstatementrange(self, lineno):
       """ return (start, end) tuple which spans the minimal 
               statement region which containing the given lineno.
           """
       # XXX there must be a better than these heuristic ways ...
       # XXX there may even be better heuristics :-)
->     if not (0 <= lineno < len(self)):
           raise IndexError("lineno out of range")
   
       # 1. find the start of the statement
       from codeop import compile_command
       for start in range(lineno, -1, -1):
           trylines = self.lines[start:lineno+1]
           # quick hack to indent the source and get it as a string in one go
           trylines.insert(0, 'def xxx():')
           trysource = '\n '.join(trylines)
           #              ^ space here
           try:
               compile_command(trysource)
           except (SyntaxError, OverflowError, ValueError):
               pass
           else:
               break   # got a valid or incomplete statement
   
       # 2. find the end of the statement
       for end in range(lineno+1, len(self)+1):
           trysource = self[start:end]
           if trysource.isparseable():
               break
   
       return start, end