Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(244044)

Side by Side Diff: Python/ceval.c

Issue 11682: PEP 380 reference implementation for 3.3
Patch Set: Created 7 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* Execute compiled code */ 2 /* Execute compiled code */
3 3
4 /* XXX TO DO: 4 /* XXX TO DO:
5 XXX speed up searching for keywords by using a dictionary 5 XXX speed up searching for keywords by using a dictionary
6 XXX document it! 6 XXX document it!
7 */ 7 */
8 8
9 /* enable more aggressive intra-module optimizations, where available */ 9 /* enable more aggressive intra-module optimizations, where available */
10 #define PY_LOCAL_AGGRESSIVE 10 #define PY_LOCAL_AGGRESSIVE
(...skipping 1811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 v = f->f_locals; 1822 v = f->f_locals;
1823 Py_XDECREF(v); 1823 Py_XDECREF(v);
1824 f->f_locals = x; 1824 f->f_locals = x;
1825 DISPATCH(); 1825 DISPATCH();
1826 1826
1827 TARGET(RETURN_VALUE) 1827 TARGET(RETURN_VALUE)
1828 retval = POP(); 1828 retval = POP();
1829 why = WHY_RETURN; 1829 why = WHY_RETURN;
1830 goto fast_block_end; 1830 goto fast_block_end;
1831 1831
1832 TARGET(YIELD_FROM)
1833 u = POP();
1834 x = PyObject_GetIter(u);
1835 Py_DECREF(u);
1836 if (!x)
1837 break;
1838 /* x is now the iterator, make the first next() call */
1839 retval = (*x->ob_type->tp_iternext)(x);
Benjamin Peterson 2011/07/09 18:41:14 Py_TYPE
Nick Coghlan 2011/09/20 13:21:02 Done.
1840 if (!retval) {
1841 /* iter may be exhausted */
1842 Py_DECREF(x);
1843 if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
1844 /* try to get return value from exception */
1845 PyObject *et, *ev, *tb;
1846 PyErr_Fetch(&et, &ev, &tb);
1847 Py_XDECREF(et); Py_XDECREF(tb);
Benjamin Peterson 2011/07/09 18:41:14 Two lines!
Nick Coghlan 2011/09/20 13:21:02 Done.
1848 u = NULL;
1849 if (ev) {
1850 u = PyObject_GetAttrString(ev, "value");
1851 Py_DECREF(ev);
1852 if (!u) PyErr_Clear();
Benjamin Peterson 2011/07/09 18:41:14 Kindly check for AttributeError only as well as sp
Nick Coghlan 2011/09/20 13:21:02 Done.
1853 }
1854 if (!u) {
1855 u = Py_None;
1856 Py_INCREF(u);
1857 }
1858 /* u is return value */
1859 PUSH(u);
1860 continue;
1861 }
1862 /* some other exception */
1863 x = NULL;
1864 break;
1865 }
1866 /* x is iterator, retval is value to be yielded */
1867 f->f_yieldfrom = x;
1868 goto yield_retval;
Benjamin Peterson 2011/07/09 18:41:14 Uh, how about copying those 3 lines? At least figu
Nick Coghlan 2011/09/20 13:21:02 Done.
1869
1832 TARGET(YIELD_VALUE) 1870 TARGET(YIELD_VALUE)
1833 retval = POP(); 1871 retval = POP();
1872 yield_retval:
1834 f->f_stacktop = stack_pointer; 1873 f->f_stacktop = stack_pointer;
1835 why = WHY_YIELD; 1874 why = WHY_YIELD;
1836 goto fast_yield; 1875 goto fast_yield;
1837 1876
1838 TARGET(POP_EXCEPT) 1877 TARGET(POP_EXCEPT)
1839 { 1878 {
1840 PyTryBlock *b = PyFrame_BlockPop(f); 1879 PyTryBlock *b = PyFrame_BlockPop(f);
1841 if (b->b_type != EXCEPT_HANDLER) { 1880 if (b->b_type != EXCEPT_HANDLER) {
1842 PyErr_SetString(PyExc_SystemError, 1881 PyErr_SetString(PyExc_SystemError,
1843 "popped block is not an except handler"); 1882 "popped block is not an except handler");
(...skipping 2783 matching lines...) Expand 10 before | Expand all | Expand 10 after
4627 Py_DECREF(l); 4666 Py_DECREF(l);
4628 return NULL; 4667 return NULL;
4629 } 4668 }
4630 PyList_SetItem(l, i, x); 4669 PyList_SetItem(l, i, x);
4631 } 4670 }
4632 return l; 4671 return l;
4633 #endif 4672 #endif
4634 } 4673 }
4635 4674
4636 #endif 4675 #endif
OLDNEW

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+