~pythonregexp2.7/python/issue2636-09-01+10

« back to all changes in this revision

Viewing changes to Objects/frameobject.c

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 21:39:45 UTC
  • mfrom: (39055.1.33 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922213945-23717m5eiqpamcyn
Merged in changes from the Single-Loop Engine branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
508
508
        }
509
509
}
510
510
 
 
511
static PyObject *
 
512
frame_sizeof(PyFrameObject *f)
 
513
{
 
514
        Py_ssize_t res, extras, ncells, nfrees;
 
515
 
 
516
        ncells = PyTuple_GET_SIZE(f->f_code->co_cellvars);
 
517
        nfrees = PyTuple_GET_SIZE(f->f_code->co_freevars);
 
518
        extras = f->f_code->co_stacksize + f->f_code->co_nlocals +
 
519
                 ncells + nfrees;
 
520
        // subtract one as it is already included in PyFrameObject
 
521
        res = sizeof(PyFrameObject) + (extras-1) * sizeof(PyObject *);
 
522
 
 
523
        return PyInt_FromSsize_t(res);
 
524
}
 
525
 
 
526
PyDoc_STRVAR(sizeof__doc__,
 
527
"F.__sizeof__() -> size of F in memory, in bytes");
 
528
 
 
529
static PyMethodDef frame_methods[] = {
 
530
        {"__sizeof__",  (PyCFunction)frame_sizeof,      METH_NOARGS,
 
531
         sizeof__doc__},
 
532
        {NULL,          NULL}   /* sentinel */
 
533
};
511
534
 
512
535
PyTypeObject PyFrame_Type = {
513
536
        PyVarObject_HEAD_INIT(&PyType_Type, 0)
537
560
        0,                                      /* tp_weaklistoffset */
538
561
        0,                                      /* tp_iter */
539
562
        0,                                      /* tp_iternext */
540
 
        0,                                      /* tp_methods */
 
563
        frame_methods,                          /* tp_methods */
541
564
        frame_memberlist,                       /* tp_members */
542
565
        frame_getsetlist,                       /* tp_getset */
543
566
        0,                                      /* tp_base */
881
904
        if (ncells || nfreevars) {
882
905
                dict_to_map(co->co_cellvars, ncells,
883
906
                            locals, fast + co->co_nlocals, 1, clear);
884
 
                dict_to_map(co->co_freevars, nfreevars,
885
 
                            locals, fast + co->co_nlocals + ncells, 1, 
886
 
                            clear);
 
907
                /* Same test as in PyFrame_FastToLocals() above. */
 
908
                if (co->co_flags & CO_OPTIMIZED) {
 
909
                        dict_to_map(co->co_freevars, nfreevars,
 
910
                                locals, fast + co->co_nlocals + ncells, 1, 
 
911
                                clear);
 
912
                }
887
913
        }
888
914
        PyErr_Restore(error_type, error_value, error_traceback);
889
915
}