Commit b30c50ae authored by Chris Toshok's avatar Chris Toshok

use None as the sentinel value for traceback chains

parent 544be22e
......@@ -732,7 +732,7 @@ static std::unique_ptr<PythonFrameIteratorImpl> getTopPythonFrame() {
// 4. Unless we've hit the end of the stack, go to 2 and keep unwinding.
//
static StatCounter us_gettraceback("us_gettraceback");
BoxedTraceback* getTraceback() {
Box* getTraceback() {
STAT_TIMER(t0, "us_timer_gettraceback");
if (!ENABLE_FRAME_INTROSPECTION) {
static bool printed_warning = false;
......@@ -740,7 +740,7 @@ BoxedTraceback* getTraceback() {
printed_warning = true;
fprintf(stderr, "Warning: can't get traceback since ENABLE_FRAME_INTROSPECTION=0\n");
}
return new BoxedTraceback();
return None;
}
if (!ENABLE_TRACEBACKS) {
......@@ -749,12 +749,12 @@ BoxedTraceback* getTraceback() {
printed_warning = true;
fprintf(stderr, "Warning: can't get traceback since ENABLE_TRACEBACKS=0\n");
}
return new BoxedTraceback();
return None;
}
Timer _t("getTraceback", 1000);
Box* tb = new BoxedTraceback();
Box* tb = None;
unwindPythonStack([&](PythonFrameIteratorImpl* frame_iter) {
BoxedTraceback::here(lineInfoForFrame(frame_iter), &tb);
return false;
......
......@@ -39,7 +39,7 @@ Box* getGlobals(); // returns either the module or a globals dict
Box* getGlobalsDict(); // always returns a dict-like object
CompiledFunction* getCFForAddress(uint64_t addr);
BoxedTraceback* getTraceback();
Box* getTraceback();
class PythonUnwindSession;
PythonUnwindSession* beginPythonUnwindSession();
......
......@@ -47,7 +47,7 @@ void showBacktrace() {
}
void raiseExc(Box* exc_obj) {
throw ExcInfo(exc_obj->cls, exc_obj, new BoxedTraceback());
throw ExcInfo(exc_obj->cls, exc_obj, None);
}
// Have a special helper function for syntax errors, since we want to include the location
......@@ -245,7 +245,7 @@ ExcInfo excInfoForRaise(Box* type, Box* value, Box* tb) {
assert(PyExceptionClass_Check(type));
if (tb == NULL) {
tb = new BoxedTraceback();
tb = None;
}
return ExcInfo(type, value, tb);
......
......@@ -102,11 +102,9 @@ Box* BoxedTraceback::getLines(Box* b) {
if (!tb->py_lines) {
BoxedList* lines = new BoxedList();
for (BoxedTraceback* wtb = tb; wtb && wtb != None; wtb = static_cast<BoxedTraceback*>(wtb->tb_next)) {
if (wtb->has_line) {
auto& line = wtb->line;
auto l = BoxedTuple::create({ boxString(line.file), boxString(line.func), boxInt(line.line) });
listAppendInternal(lines, l);
}
auto& line = wtb->line;
auto l = BoxedTuple::create({ boxString(line.file), boxString(line.func), boxInt(line.line) });
listAppendInternal(lines, l);
}
tb->py_lines = lines;
}
......
......@@ -28,12 +28,10 @@ extern "C" BoxedClass* traceback_cls;
class BoxedTraceback : public Box {
public:
Box* tb_next;
bool has_line;
LineInfo line;
Box* py_lines;
BoxedTraceback(LineInfo line, Box* tb_next) : tb_next(tb_next), has_line(true), line(line), py_lines(NULL) {}
BoxedTraceback() : tb_next(None), has_line(false), line(-1, -1, "", ""), py_lines(NULL) {}
BoxedTraceback(LineInfo line, Box* tb_next) : tb_next(tb_next), line(line), py_lines(NULL) {}
DEFAULT_CLASS(traceback_cls);
......
import sys
import subprocess
me = sys.executable
p = subprocess.Popen([me, "-c", "1/0"], stdout=subprocess.PIPE)
print p.stdout.read()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment