Commits

Mark Shannon  committed aa6ec85 Draft

Correct order of events for gen-enter in DOC

  • Participants
  • Parent commits d082aa4

Comments (0)

Files changed (2)

File Python/ceval.c

             dict = PyObject_GenericGetDict(w, NULL);
             if (dict == NULL) {
                 PyErr_SetString(PyExc_SystemError, "object has no dictionary");
+                x = NULL;
                 break;
             }
             if ((err = PyDict_SetItem(dict, v, u)) != 0) {

File Python/trace_D_O_C.c

 #define SHOW_STACK() show_stack(x)
 #define SHOW_FRAME() show_frames(x);
 
+static char *
+show_blocks(char *buf, DeferredFrame *f)
+{
+    int i;
+    PyTryBlock *b;
+    buf += sprintf(buf, "Blocks: ");
+    for (i = 0; i < f->blockcount; i++) {
+        b = &f->blockstack[i];
+        buf += sprintf(buf, "%s %d %d, ",
+                       _HotPy_Instruction_Names[b->b_type],
+                       b->b_handler, b->b_level);
+    }
+    buf[0] = '\n';
+    buf[1] = 0;
+    return buf + 1;
+}
+
 static void
 show_frame(HotPyOptimiser *x, DeferredFrame *f)
 {
         else
             strcat(buf, "null, ");
     }
+    if (f->blockcount) {
+        show_blocks(buf + strlen(buf), f);
+    }
     x->next->comment(x->next, buf);
     PyMem_Free(buf);
 }
     for (i = 0; i < f->blockcount; i++) {
         write_int(buffer, f->blockstack[i].b_type);
         /* b_handler can be -1 for SETUP_EXCEPT_HANDLER */
-        write_int(buffer, (unsigned short)f->blockstack[i].b_handler);
+        write_int(buffer, f->blockstack[i].b_handler+1);
         write_int(buffer, f->blockstack[i].b_level);
     }
     write_int(buffer, f->lasti);
     f->blockcount = read_int(code);
     for (i = 0; i < f->blockcount; i++) {
          f->blockstack[i].b_type = read_int(code);
-         f->blockstack[i].b_handler = (signed short)read_int(code);
+         f->blockstack[i].b_handler = read_int(code)-1;
          f->blockstack[i].b_level = read_int(code);
     }
     f->lasti = read_int(code);
             b = &f->blockstack[i];
             buf += sprintf(buf, "%s %d %d, ",
                            _HotPy_Instruction_Names[b->b_type],
-                           b->b_level, b->b_handler);
+                           b->b_handler, b->b_level);
         }
     }
     buf[0] = '\n';
     blocks = read_int(code);
     for (i = 0; i < blocks; i++) {
         int type = read_int(code);
-        int handler = (signed short)read_int(code);
+        int handler = read_int(code)-1;
         int level = read_int(code);
         PyFrame_BlockSetup(f, type, handler, level);
     }
     f->allocated = 1;
     f->locals_base_register = opt->top_frame->locals_base_register +
                               opt->top_frame->lcount;
+    push_frame(x, f);
     materialise(x, v);
     x->next->gen_enter(x->next, code);
-    push_frame(x, f);
     SHOW_FRAME();
 }
 
     if (op == SETUP_EXCEPT_HANDLER) {
         /* Don't optimise this for now */
         /* XXX -- This could be optimised but it is a bit tricky */
+        assert(handler == -1);
         materialise_blocks(x, f);
         materialise_stack_top(x, STACK_DEPTH());
         x->next->setup_block(x->next, op, handler, level);