call site 14 for code.Frame.eval
code/testing/test_safe_repr.py - line 27
26
27
   def test_string_exception():
->     assert 'unknown' in safe_repr._repr(BrokenRepr("string"))
magic/assertion.py - line 22
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
   def __init__(self, *args):
       BuiltinAssertionError.__init__(self, *args)
       if args: 
           self.msg = str(args[0])
       else: 
           f = sys._getframe(1)
           try:
               source = py.code.Frame(f).statement
               source = str(source.deindent()).strip()
           except py.error.ENOENT:
               source = None
               # this can also occur during reinterpretation, when the
               # co_filename is set to "<run>".
           if source:
->             self.msg = exprinfo.interpret(source, f, should_fail=True)
               if not self.args:
                   self.args = (self.msg,)
           else:
               self.msg = None
magic/exprinfo.py - line 422
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
   def interpret(source, frame, should_fail=False):
       module = Interpretable(parse(source, 'exec').node)
       #print "got module", module
       if isinstance(frame, py.std.types.FrameType):
           frame = py.code.Frame(frame)
       try:
->         module.run(frame)
       except Failure, e:
           return getfailure(e)
       except passthroughex:
           raise
       except:
           import traceback
           traceback.print_exc()
       if should_fail:
           return "(inconsistently failed then succeeded)"
       else:
           return None
magic/exprinfo.py - line 382
379
380
381
382
   def run(self, frame):
       for stmt in self.nodes:
           stmt = Interpretable(stmt)
->         stmt.run(frame)
magic/exprinfo.py - line 331
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
   def run(self, frame):
       test = Interpretable(self.test)
->     test.eval(frame)
       # simplify 'assert False where False = ...'
       if (test.explanation.startswith('False\n{False = ') and
           test.explanation.endswith('\n}')):
           test.explanation = test.explanation[15:-2]
       # print the result as  'assert <explanation>'
       self.result = test.result
       self.explanation = 'assert ' + test.explanation
       if not frame.is_true(test.result):
           try:
               raise BuiltinAssertionError
           except passthroughex:
               raise
           except:
               raise Failure(self)
magic/exprinfo.py - line 126
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
   def eval(self, frame):
       expr = Interpretable(self.expr)
       expr.eval(frame)
       for operation, expr2 in self.ops:
           expr2 = Interpretable(expr2)
->         expr2.eval(frame)
           self.explanation = "%s %s %s" % (
               expr.explanation, operation, expr2.explanation)
           co = compile("__exprinfo_left %s __exprinfo_right" % operation,
                        '?', 'eval')
           try:
               self.result = frame.eval(co, __exprinfo_left=expr.result,
                                            __exprinfo_right=expr2.result)
           except passthroughex:
               raise
           except:
               raise Failure(self)
           if not frame.is_true(self.result):
               break
           expr = expr2
magic/exprinfo.py - line 243
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
   def eval(self, frame):
       node = Interpretable(self.node)
->     node.eval(frame)
       explanations = []
       vars = {'__exprinfo_fn': node.result}
       source = '__exprinfo_fn('
       for a in self.args:
           if isinstance(a, ast.Keyword):
               keyword = a.name
               a = a.expr
           else:
               keyword = None
           a = Interpretable(a)
           a.eval(frame)
           argname = '__exprinfo_%d' % len(vars)
           vars[argname] = a.result
           if keyword is None:
               source += argname + ','
               explanations.append(a.explanation)
           else:
               source += '%s=%s,' % (keyword, argname)
               explanations.append('%s=%s' % (keyword, a.explanation))
       if self.star_args:
           star_args = Interpretable(self.star_args)
           star_args.eval(frame)
           argname = '__exprinfo_star'
           vars[argname] = star_args.result
           source += '*' + argname + ','
           explanations.append('*' + star_args.explanation)
       if self.dstar_args:
           dstar_args = Interpretable(self.dstar_args)
           dstar_args.eval(frame)
           argname = '__exprinfo_kwds'
           vars[argname] = dstar_args.result
           source += '**' + argname + ','
           explanations.append('**' + dstar_args.explanation)
       self.explanation = "%s(%s)" % (
           node.explanation, ', '.join(explanations))
       if source.endswith(','):
           source = source[:-1]
       source += ')'
       co = compile(source, '?', 'eval')
       try:
           self.result = frame.eval(co, **vars)
       except passthroughex:
           raise
       except:
           raise Failure(self)
       if not node.is_builtin(frame) or not self.is_bool(frame):
           r = frame.repr(self.result)
           self.explanation = '%s\n{%s = %s\n}' % (r, r, self.explanation)
magic/exprinfo.py - line 313
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
   def eval(self, frame):
       expr = Interpretable(self.expr)
       expr.eval(frame)
       co = compile('__exprinfo_expr.%s' % self.attrname, '?', 'eval')
       try:
           self.result = frame.eval(co, __exprinfo_expr=expr.result)
       except passthroughex:
           raise
       except:
           raise Failure(self)
       self.explanation = '%s.%s' % (expr.explanation, self.attrname)
       # if the attribute comes from the instance, its value is interesting
       co = compile('hasattr(__exprinfo_expr, "__dict__") and '
                    '%r in __exprinfo_expr.__dict__' % self.attrname,
                    '?', 'eval')
       try:
           from_instance = frame.is_true(
->             frame.eval(co, __exprinfo_expr=expr.result))
       except passthroughex:
           raise
       except:
           from_instance = True
       if from_instance:
           r = frame.repr(self.result)
           self.explanation = '%s\n{%s = %s\n}' % (r, r, self.explanation)