@@ -5,10 +5,10 @@ use crate::{
55 atomic_func,
66 class:: PyClassImpl ,
77 function:: { OptionalArg , PyComparisonValue , PySetterValue } ,
8- protocol:: { PyMappingMethods , PySequenceMethods } ,
8+ protocol:: { PyIter , PyIterReturn , PyMappingMethods , PySequenceMethods } ,
99 types:: {
10- AsMapping , AsSequence , Comparable , Constructor , GetAttr , PyComparisonOp , Representable ,
11- SetAttr ,
10+ AsMapping , AsSequence , Comparable , Constructor , GetAttr , IterNext , Iterable ,
11+ PyComparisonOp , Representable , SetAttr ,
1212 } ,
1313 Context , Py , PyObject , PyObjectRef , PyPayload , PyRef , PyResult , VirtualMachine ,
1414} ;
@@ -71,7 +71,8 @@ crate::common::static_cell! {
7171 Comparable ,
7272 AsSequence ,
7373 AsMapping ,
74- Representable
74+ Representable ,
75+ IterNext
7576) ) ]
7677impl PyWeakProxy {
7778 fn try_upgrade ( & self , vm : & VirtualMachine ) -> PyResult {
@@ -122,6 +123,19 @@ impl PyWeakProxy {
122123 obj. del_item ( & * needle, vm)
123124 }
124125}
126+ impl Iterable for PyWeakProxy {
127+ fn iter ( zelf : PyRef < Self > , vm : & VirtualMachine ) -> PyResult {
128+ let obj = zelf. try_upgrade ( vm) ?;
129+ Ok ( obj. get_iter ( vm) ?. into ( ) )
130+ }
131+ }
132+
133+ impl IterNext for PyWeakProxy {
134+ fn next ( zelf : & Py < Self > , vm : & VirtualMachine ) -> PyResult < PyIterReturn > {
135+ let obj = zelf. try_upgrade ( vm) ?;
136+ PyIter :: new ( obj) . next ( vm)
137+ }
138+ }
125139
126140fn new_reference_error ( vm : & VirtualMachine ) -> PyRef < super :: PyBaseException > {
127141 vm. new_exception_msg (
0 commit comments