@@ -2605,3 +2605,111 @@ async_gen_athrow_new(PyAsyncGenObject *gen, PyObject *args)
26052605 _PyObject_GC_TRACK ((PyObject * )o );
26062606 return (PyObject * )o ;
26072607}
2608+
2609+ typedef struct {
2610+ PyObject_HEAD
2611+ PyObject * agyf_iterator ;
2612+ } _PyAsyncGenYieldFrom ;
2613+
2614+ #define _PyAsyncGenYieldFrom_CAST (op ) ((_PyAsyncGenYieldFrom *)op)
2615+
2616+ static int
2617+ async_gen_yield_from_traverse (PyObject * op , visitproc visit , void * arg )
2618+ {
2619+ assert (op != NULL );
2620+ _PyAsyncGenYieldFrom * self = _PyAsyncGenYieldFrom_CAST (op );
2621+ Py_VISIT (self -> agyf_iterator );
2622+ return 0 ;
2623+ }
2624+
2625+ static int
2626+ async_gen_yield_from_clear (PyObject * op )
2627+ {
2628+ assert (op != NULL );
2629+ _PyAsyncGenYieldFrom * self = _PyAsyncGenYieldFrom_CAST (op );
2630+ Py_CLEAR (self -> agyf_iterator );
2631+ return 0 ;
2632+ }
2633+
2634+ static void
2635+ async_gen_yield_from_dealloc (PyObject * op )
2636+ {
2637+ assert (op != NULL );
2638+ _PyAsyncGenYieldFrom * self = _PyAsyncGenYieldFrom_CAST (op );
2639+ _PyObject_GC_UNTRACK (op );
2640+ (void )async_gen_yield_from_clear (op );
2641+ PyObject_GC_Del (op );
2642+ }
2643+
2644+ static PyObject *
2645+ async_gen_yield_from_iternext (PyObject * op )
2646+ {
2647+ assert (op != NULL );
2648+ _PyAsyncGenYieldFrom * self = _PyAsyncGenYieldFrom_CAST (op );
2649+ PyObject * result = PyIter_Next (self -> agyf_iterator );
2650+ if (result == NULL ) {
2651+ return NULL ;
2652+ }
2653+
2654+ PyObject * wrapped = _PyAsyncGenValueWrapperNew (_PyThreadState_GET (), result );
2655+ Py_DECREF (result );
2656+ return wrapped ;
2657+ }
2658+
2659+ PyTypeObject _PyAsyncGenYieldFrom_Type = {
2660+ PyVarObject_HEAD_INIT (& PyType_Type , 0 )
2661+ "async_generator_yield_from" , /* tp_name */
2662+ sizeof (_PyAsyncGenYieldFrom ), /* tp_basicsize */
2663+ 0 , /* tp_itemsize */
2664+ /* methods */
2665+ async_gen_yield_from_dealloc , /* tp_dealloc */
2666+ 0 , /* tp_vectorcall_offset */
2667+ 0 , /* tp_getattr */
2668+ 0 , /* tp_setattr */
2669+ 0 , /* tp_as_async */
2670+ 0 , /* tp_repr */
2671+ 0 , /* tp_as_number */
2672+ 0 , /* tp_as_sequence */
2673+ 0 , /* tp_as_mapping */
2674+ 0 , /* tp_hash */
2675+ 0 , /* tp_call */
2676+ 0 , /* tp_str */
2677+ PyObject_GenericGetAttr , /* tp_getattro */
2678+ 0 , /* tp_setattro */
2679+ 0 , /* tp_as_buffer */
2680+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC , /* tp_flags */
2681+ 0 , /* tp_doc */
2682+ async_gen_yield_from_traverse , /* tp_traverse */
2683+ async_gen_yield_from_clear , /* tp_clear */
2684+ 0 , /* tp_richcompare */
2685+ 0 , /* tp_weaklistoffset */
2686+ PyObject_SelfIter , /* tp_iter */
2687+ async_gen_yield_from_iternext , /* tp_iternext */
2688+ 0 , /* tp_methods */
2689+ 0 , /* tp_members */
2690+ 0 , /* tp_getset */
2691+ 0 , /* tp_base */
2692+ 0 , /* tp_dict */
2693+ 0 , /* tp_descr_get */
2694+ 0 , /* tp_descr_set */
2695+ 0 , /* tp_dictoffset */
2696+ 0 , /* tp_init */
2697+ 0 , /* tp_alloc */
2698+ 0 , /* tp_new */
2699+ };
2700+
2701+
2702+ PyObject *
2703+ _PyAsyncGenYieldFrom_New (PyThreadState * tstate , PyObject * iterator )
2704+ {
2705+ assert (tstate != NULL );
2706+ assert (iterator != NULL );
2707+ _PyAsyncGenYieldFrom * yield_from = PyObject_GC_New (_PyAsyncGenYieldFrom ,
2708+ & _PyAsyncGenYieldFrom_Type );
2709+ if (yield_from == NULL ) {
2710+ return NULL ;
2711+ }
2712+ yield_from -> agyf_iterator = Py_NewRef (iterator );
2713+ _PyObject_GC_TRACK ((PyObject * )yield_from );
2714+ return (PyObject * )yield_from ;
2715+ }
0 commit comments