@@ -231,9 +231,11 @@ static char *GeneratorExp_fields[]={
231231 "generators" ,
232232};
233233static PyTypeObject * Yield_type ;
234- _Py_IDENTIFIER (is_from );
235234static char * Yield_fields []= {
236- "is_from" ,
235+ "value" ,
236+ };
237+ static PyTypeObject * YieldFrom_type ;
238+ static char * YieldFrom_fields []= {
237239 "value" ,
238240};
239241static PyTypeObject * Compare_type ;
@@ -812,8 +814,10 @@ static int init_types(void)
812814 GeneratorExp_type = make_type ("GeneratorExp" , expr_type ,
813815 GeneratorExp_fields , 2 );
814816 if (!GeneratorExp_type ) return 0 ;
815- Yield_type = make_type ("Yield" , expr_type , Yield_fields , 2 );
817+ Yield_type = make_type ("Yield" , expr_type , Yield_fields , 1 );
816818 if (!Yield_type ) return 0 ;
819+ YieldFrom_type = make_type ("YieldFrom" , expr_type , YieldFrom_fields , 1 );
820+ if (!YieldFrom_type ) return 0 ;
817821 Compare_type = make_type ("Compare" , expr_type , Compare_fields , 3 );
818822 if (!Compare_type ) return 0 ;
819823 Call_type = make_type ("Call" , expr_type , Call_fields , 5 );
@@ -1749,20 +1753,33 @@ GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
17491753}
17501754
17511755expr_ty
1752- Yield (int is_from , expr_ty value , int lineno , int col_offset , PyArena * arena )
1756+ Yield (expr_ty value , int lineno , int col_offset , PyArena * arena )
17531757{
17541758 expr_ty p ;
17551759 p = (expr_ty )PyArena_Malloc (arena , sizeof (* p ));
17561760 if (!p )
17571761 return NULL ;
17581762 p -> kind = Yield_kind ;
1759- p -> v .Yield .is_from = is_from ;
17601763 p -> v .Yield .value = value ;
17611764 p -> lineno = lineno ;
17621765 p -> col_offset = col_offset ;
17631766 return p ;
17641767}
17651768
1769+ expr_ty
1770+ YieldFrom (expr_ty value , int lineno , int col_offset , PyArena * arena )
1771+ {
1772+ expr_ty p ;
1773+ p = (expr_ty )PyArena_Malloc (arena , sizeof (* p ));
1774+ if (!p )
1775+ return NULL ;
1776+ p -> kind = YieldFrom_kind ;
1777+ p -> v .YieldFrom .value = value ;
1778+ p -> lineno = lineno ;
1779+ p -> col_offset = col_offset ;
1780+ return p ;
1781+ }
1782+
17661783expr_ty
17671784Compare (expr_ty left , asdl_int_seq * ops , asdl_seq * comparators , int lineno ,
17681785 int col_offset , PyArena * arena )
@@ -2798,12 +2815,16 @@ ast2obj_expr(void* _o)
27982815 case Yield_kind :
27992816 result = PyType_GenericNew (Yield_type , NULL , NULL );
28002817 if (!result ) goto failed ;
2801- value = ast2obj_int (o -> v .Yield .is_from );
2818+ value = ast2obj_expr (o -> v .Yield .value );
28022819 if (!value ) goto failed ;
2803- if (_PyObject_SetAttrId (result , & PyId_is_from , value ) == -1 )
2820+ if (_PyObject_SetAttrId (result , & PyId_value , value ) == -1 )
28042821 goto failed ;
28052822 Py_DECREF (value );
2806- value = ast2obj_expr (o -> v .Yield .value );
2823+ break ;
2824+ case YieldFrom_kind :
2825+ result = PyType_GenericNew (YieldFrom_type , NULL , NULL );
2826+ if (!result ) goto failed ;
2827+ value = ast2obj_expr (o -> v .YieldFrom .value );
28072828 if (!value ) goto failed ;
28082829 if (_PyObject_SetAttrId (result , & PyId_value , value ) == -1 )
28092830 goto failed ;
@@ -5345,21 +5366,30 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
53455366 return 1 ;
53465367 }
53475368 if (isinstance ) {
5348- int is_from ;
53495369 expr_ty value ;
53505370
5351- if (_PyObject_HasAttrId (obj , & PyId_is_from )) {
5371+ if (_PyObject_HasAttrId (obj , & PyId_value )) {
53525372 int res ;
5353- tmp = _PyObject_GetAttrId (obj , & PyId_is_from );
5373+ tmp = _PyObject_GetAttrId (obj , & PyId_value );
53545374 if (tmp == NULL ) goto failed ;
5355- res = obj2ast_int (tmp , & is_from , arena );
5375+ res = obj2ast_expr (tmp , & value , arena );
53565376 if (res != 0 ) goto failed ;
53575377 Py_XDECREF (tmp );
53585378 tmp = NULL ;
53595379 } else {
5360- PyErr_SetString (PyExc_TypeError , "required field \"is_from\" missing from Yield" );
5361- return 1 ;
5380+ value = NULL ;
53625381 }
5382+ * out = Yield (value , lineno , col_offset , arena );
5383+ if (* out == NULL ) goto failed ;
5384+ return 0 ;
5385+ }
5386+ isinstance = PyObject_IsInstance (obj , (PyObject * )YieldFrom_type );
5387+ if (isinstance == -1 ) {
5388+ return 1 ;
5389+ }
5390+ if (isinstance ) {
5391+ expr_ty value ;
5392+
53635393 if (_PyObject_HasAttrId (obj , & PyId_value )) {
53645394 int res ;
53655395 tmp = _PyObject_GetAttrId (obj , & PyId_value );
@@ -5371,7 +5401,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
53715401 } else {
53725402 value = NULL ;
53735403 }
5374- * out = Yield ( is_from , value , lineno , col_offset , arena );
5404+ * out = YieldFrom ( value , lineno , col_offset , arena );
53755405 if (* out == NULL ) goto failed ;
53765406 return 0 ;
53775407 }
@@ -6928,6 +6958,8 @@ PyInit__ast(void)
69286958 (PyObject * )GeneratorExp_type ) < 0 ) return NULL ;
69296959 if (PyDict_SetItemString (d , "Yield" , (PyObject * )Yield_type ) < 0 ) return
69306960 NULL ;
6961+ if (PyDict_SetItemString (d , "YieldFrom" , (PyObject * )YieldFrom_type ) <
6962+ 0 ) return NULL ;
69316963 if (PyDict_SetItemString (d , "Compare" , (PyObject * )Compare_type ) < 0 )
69326964 return NULL ;
69336965 if (PyDict_SetItemString (d , "Call" , (PyObject * )Call_type ) < 0 ) return
0 commit comments