Diff of /Python/ceval.c [74747f] .. [f51dc9] Maximize Restore

  Switch to unified view

a/Python/ceval.c b/Python/ceval.c
...
...
508
Py_SetRecursionLimit(int new_limit)
508
Py_SetRecursionLimit(int new_limit)
509
{
509
{
510
    recursion_limit = new_limit;
510
    recursion_limit = new_limit;
511
}
511
}
512
512
513
int
514
_Py_CheckRecursiveCall(char *where)
515
{
516
  PyThreadState *tstate = PyThreadState_GET();
517
518
#ifdef USE_STACKCHECK
519
  if (PyOS_CheckStack()) {
520
      --tstate->recursion_depth;
521
      PyErr_SetString(PyExc_MemoryError, "Stack overflow");
522
      return -1;
523
  }
524
#endif
525
  if (tstate->recursion_depth > recursion_limit) {
526
      --tstate->recursion_depth;
527
      PyErr_Format(PyExc_RuntimeError,
528
               "maximum recursion depth exceeded%s",
529
               where);
530
      return -1;
531
  }
532
  return 0;
533
}
534
535
536
/* Status code for main loop (reason for stack unwind) */
513
/* Status code for main loop (reason for stack unwind) */
537
514
538
enum why_code {
515
enum why_code {
539
        WHY_NOT,    /* No error */
516
        WHY_NOT,    /* No error */
540
        WHY_EXCEPTION,  /* Exception occurred */
517
        WHY_EXCEPTION,  /* Exception occurred */
...
...
695
/* Start of code */
672
/* Start of code */
696
673
697
    if (f == NULL)
674
    if (f == NULL)
698
        return NULL;
675
        return NULL;
699
676
677
#ifdef USE_STACKCHECK
678
  if (tstate->recursion_depth%10 == 0 && PyOS_CheckStack()) {
679
      PyErr_SetString(PyExc_MemoryError, "Stack overflow");
680
      return NULL;
681
  }
682
#endif
683
700
    /* push frame */
684
    /* push frame */
701
  if (Py_EnterRecursiveCall(""))
685
  if (++tstate->recursion_depth > recursion_limit) {
686
      --tstate->recursion_depth;
687
      PyErr_SetString(PyExc_RuntimeError,
688
              "maximum recursion depth exceeded");
689
      tstate->frame = f->f_back;
702
        return NULL;
690
        return NULL;
691
  }
703
692
704
    tstate->frame = f;
693
    tstate->frame = f;
705
694
706
    if (tstate->use_tracing) {
695
    if (tstate->use_tracing) {
707
        if (tstate->c_tracefunc != NULL) {
696
        if (tstate->c_tracefunc != NULL) {
...
...
719
               The global trace function is also called
708
               The global trace function is also called
720
               whenever an exception is detected. */
709
               whenever an exception is detected. */
721
            if (call_trace(tstate->c_tracefunc, tstate->c_traceobj,
710
            if (call_trace(tstate->c_tracefunc, tstate->c_traceobj,
722
                       f, PyTrace_CALL, Py_None)) {
711
                       f, PyTrace_CALL, Py_None)) {
723
                /* Trace function raised an error */
712
                /* Trace function raised an error */
724
              goto exit_eval_frame;
713
              --tstate->recursion_depth;
714
              tstate->frame = f->f_back;
715
              return NULL;
725
            }
716
            }
726
        }
717
        }
727
        if (tstate->c_profilefunc != NULL) {
718
        if (tstate->c_profilefunc != NULL) {
728
            /* Similar for c_profilefunc, except it needn't
719
            /* Similar for c_profilefunc, except it needn't
729
               return itself and isn't called for "line" events */
720
               return itself and isn't called for "line" events */
730
            if (call_trace(tstate->c_profilefunc,
721
            if (call_trace(tstate->c_profilefunc,
731
                       tstate->c_profileobj,
722
                       tstate->c_profileobj,
732
                       f, PyTrace_CALL, Py_None)) {
723
                       f, PyTrace_CALL, Py_None)) {
733
                /* Profile function raised an error */
724
                /* Profile function raised an error */
734
              goto exit_eval_frame;
725
              --tstate->recursion_depth;
726
              tstate->frame = f->f_back;
727
              return NULL;
735
            }
728
            }
736
        }
729
        }
737
    }
730
    }
738
731
739
    co = f->f_code;
732
    co = f->f_code;
...
...
2433
    }
2426
    }
2434
2427
2435
    reset_exc_info(tstate);
2428
    reset_exc_info(tstate);
2436
2429
2437
    /* pop frame */
2430
    /* pop frame */
2438
    exit_eval_frame:
2431
  --tstate->recursion_depth;
2439
  Py_LeaveRecursiveCall();
2440
    tstate->frame = f->f_back;
2432
    tstate->frame = f->f_back;
2441
2433
2442
    return retval;
2434
    return retval;
2443
}
2435
}
2444
2436