| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* Generator object implementation */ | 1 /* Generator object implementation */ |
| 2 | 2 |
| 3 #include "Python.h" | 3 #include "Python.h" |
| 4 #include "frameobject.h" | 4 #include "frameobject.h" |
| 5 #include "genobject.h" | 5 #include "genobject.h" |
| 6 #include "ceval.h" | 6 #include "ceval.h" |
| 7 #include "structmember.h" | 7 #include "structmember.h" |
| 8 #include "opcode.h" | 8 #include "opcode.h" |
| 9 | 9 |
| 10 static int | 10 static int |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 PyDoc_STRVAR(gen__name__doc__, | 305 PyDoc_STRVAR(gen__name__doc__, |
| 306 "Return the name of the generator's associated code object."); | 306 "Return the name of the generator's associated code object."); |
| 307 | 307 |
| 308 static PyGetSetDef gen_getsetlist[] = { | 308 static PyGetSetDef gen_getsetlist[] = { |
| 309 {"__name__", (getter)gen_get_name, NULL, NULL, gen__name__doc__}, | 309 {"__name__", (getter)gen_get_name, NULL, NULL, gen__name__doc__}, |
| 310 {NULL} | 310 {NULL} |
| 311 }; | 311 }; |
| 312 | 312 |
| 313 | 313 |
| 314 static PyMemberDef gen_memberlist[] = { | 314 static PyMemberDef gen_memberlist[] = { |
| 315 » {"gi_frame",» T_OBJECT, offsetof(PyGenObject, gi_frame),» RO}, | 315 » {"gi_frame",» T_OBJECT, offsetof(PyGenObject, gi_frame), |
| 316 » {"gi_running",» T_INT, offsetof(PyGenObject, gi_running),» RO}, | 316 » RO|RESTRICTED}, |
| GvR 2009/02/25 17:42:41 Given the restrictions on frames, do you still nee asktav 2009/02/25 21:00:57 Good point. But I'd like to keep this restriction | |
| 317 {"gi_code", T_OBJECT, offsetof(PyGenObject, gi_code), RO}, | 317 » {"gi_running",» T_INT, offsetof(PyGenObject, gi_running), RO}, |
| 318 » {"gi_code", T_OBJECT, offsetof(PyGenObject, gi_code), | |
| 319 » RO|RESTRICTED}, | |
| GvR 2009/02/25 17:42:41 Again, why do you restrict the code object? (I gu asktav 2009/02/25 21:00:57 code_object.co_consts | |
| 318 {NULL} /* Sentinel */ | 320 {NULL} /* Sentinel */ |
| 319 }; | 321 }; |
| 320 | 322 |
| 321 static PyMethodDef gen_methods[] = { | 323 static PyMethodDef gen_methods[] = { |
| 322 {"send",(PyCFunction)gen_send, METH_O, send_doc}, | 324 {"send",(PyCFunction)gen_send, METH_O, send_doc}, |
| 323 {"throw",(PyCFunction)gen_throw, METH_VARARGS, throw_doc}, | 325 {"throw",(PyCFunction)gen_throw, METH_VARARGS, throw_doc}, |
| 324 {"close",(PyCFunction)gen_close, METH_NOARGS, close_doc}, | 326 {"close",(PyCFunction)gen_close, METH_NOARGS, close_doc}, |
| 325 {NULL, NULL} /* Sentinel */ | 327 {NULL, NULL} /* Sentinel */ |
| 326 }; | 328 }; |
| 327 | 329 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 /* Any block type besides a loop requires cleanup. */ | 407 /* Any block type besides a loop requires cleanup. */ |
| 406 i = f->f_iblock; | 408 i = f->f_iblock; |
| 407 while (--i >= 0) { | 409 while (--i >= 0) { |
| 408 if (f->f_blockstack[i].b_type != SETUP_LOOP) | 410 if (f->f_blockstack[i].b_type != SETUP_LOOP) |
| 409 return 1; | 411 return 1; |
| 410 } | 412 } |
| 411 | 413 |
| 412 /* No blocks except loops, it's safe to skip finalization. */ | 414 /* No blocks except loops, it's safe to skip finalization. */ |
| 413 return 0; | 415 return 0; |
| 414 } | 416 } |
| OLD | NEW |