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

Side by Side Diff: Python/ceval.c

Issue 11682: PEP 380 reference implementation for 3.3
Patch Set: Created 7 years, 11 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
« no previous file with comments | « Python/ast.c ('k') | Python/compile.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 x = POP(); 1820 x = POP();
1821 v = f->f_locals; 1821 v = f->f_locals;
1822 Py_XDECREF(v); 1822 Py_XDECREF(v);
1823 f->f_locals = x; 1823 f->f_locals = x;
1824 DISPATCH(); 1824 DISPATCH();
1825 1825
1826 TARGET(RETURN_VALUE) 1826 TARGET(RETURN_VALUE)
1827 retval = POP(); 1827 retval = POP();
1828 why = WHY_RETURN; 1828 why = WHY_RETURN;
1829 goto fast_block_end; 1829 goto fast_block_end;
1830
1831 TARGET(YIELD_FROM)
1832 u = POP();
1833 x = PyObject_GetIter(u);
1834 Py_DECREF(u);
1835 if (x == NULL)
1836 break;
1837 /* x is now the iterator, make the first next() call */
1838 retval = (*Py_TYPE(x)->tp_iternext)(x);
1839 if (!retval) {
1840 /* iter may be exhausted */
1841 Py_CLEAR(x);
1842 if (!PyErr_ExceptionMatches(PyExc_StopIteration)) {
1843 /* some other exception */
1844 break;
1845 }
1846 /* try to get return value from exception */
1847 PyObject *et, *ev, *tb;
1848 PyErr_Fetch(&et, &ev, &tb);
1849 Py_XDECREF(et);
1850 Py_XDECREF(tb);
1851 /* u is return value */
1852 u = NULL;
1853 if (ev) {
1854 u = PyObject_GetAttrString(ev, "value");
1855 Py_DECREF(ev);
1856 if (u == NULL) {
1857 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
1858 /* some other exception */
1859 break;
1860 }
1861 PyErr_Clear();
1862 }
1863 }
1864 if (u == NULL) {
1865 u = Py_None;
1866 Py_INCREF(u);
1867 }
1868 PUSH(u);
1869 continue;
1870 }
1871 /* x is iterator, retval is value to be yielded */
1872 f->f_yieldfrom = x;
1873 f->f_stacktop = stack_pointer;
1874 why = WHY_YIELD;
1875 goto fast_yield;
1830 1876
1831 TARGET(YIELD_VALUE) 1877 TARGET(YIELD_VALUE)
1832 retval = POP(); 1878 retval = POP();
1833 f->f_stacktop = stack_pointer; 1879 f->f_stacktop = stack_pointer;
1834 why = WHY_YIELD; 1880 why = WHY_YIELD;
1835 goto fast_yield; 1881 goto fast_yield;
1836 1882
1837 TARGET(POP_EXCEPT) 1883 TARGET(POP_EXCEPT)
1838 { 1884 {
1839 PyTryBlock *b = PyFrame_BlockPop(f); 1885 PyTryBlock *b = PyFrame_BlockPop(f);
(...skipping 2764 matching lines...) Expand 10 before | Expand all | Expand 10 after
4604 Py_DECREF(l); 4650 Py_DECREF(l);
4605 return NULL; 4651 return NULL;
4606 } 4652 }
4607 PyList_SetItem(l, i, x); 4653 PyList_SetItem(l, i, x);
4608 } 4654 }
4609 return l; 4655 return l;
4610 #endif 4656 #endif
4611 } 4657 }
4612 4658
4613 #endif 4659 #endif
OLDNEW
« no previous file with comments | « Python/ast.c ('k') | Python/compile.c » ('j') | no next file with comments »

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