Add object to the stack and record its filename and line information. Args: obj: An object to store on the stack. offset: Integer. If 0, the caller's stack frame is used. If 1, the caller's caller's stack frame is used. Returns: TraceableObject.SUCCESS if appr
(self, obj, offset=0)
| 90 | self._stack = existing_stack[:] if existing_stack else [] |
| 91 | |
| 92 | def push_obj(self, obj, offset=0): |
| 93 | """Add object to the stack and record its filename and line information. |
| 94 | |
| 95 | Args: |
| 96 | obj: An object to store on the stack. |
| 97 | offset: Integer. If 0, the caller's stack frame is used. If 1, |
| 98 | the caller's caller's stack frame is used. |
| 99 | |
| 100 | Returns: |
| 101 | TraceableObject.SUCCESS if appropriate stack information was found, |
| 102 | TraceableObject.HEURISTIC_USED if the stack was smaller than expected, |
| 103 | and TraceableObject.FAILURE if the stack was empty. |
| 104 | """ |
| 105 | traceable_obj = TraceableObject(obj) |
| 106 | self._stack.append(traceable_obj) |
| 107 | # Offset is defined in "Args" as relative to the caller. We are 1 frame |
| 108 | # beyond the caller and need to compensate. |
| 109 | return traceable_obj.set_filename_and_line_from_caller(offset + 1) |
| 110 | |
| 111 | def pop_obj(self): |
| 112 | """Remove last-inserted object and return it, without filename/line info.""" |