@@ -1593,7 +1593,7 @@ mod decl {
15931593 let iterators = iterators. into_vec ( ) ;
15941594 PyItertoolsZipLongest {
15951595 iterators,
1596- fillvalue,
1596+ fillvalue : PyRwLock :: new ( fillvalue ) ,
15971597 }
15981598 . into_ref_with_type ( vm, cls)
15991599 . map ( Into :: into)
@@ -1605,11 +1605,32 @@ mod decl {
16051605 #[ derive( Debug , PyPayload ) ]
16061606 struct PyItertoolsZipLongest {
16071607 iterators : Vec < PyIter > ,
1608- fillvalue : PyObjectRef ,
1608+ fillvalue : PyRwLock < PyObjectRef > ,
16091609 }
16101610
16111611 #[ pyclass( with( IterNext , Constructor ) ) ]
1612- impl PyItertoolsZipLongest { }
1612+ impl PyItertoolsZipLongest {
1613+ #[ pymethod( magic) ]
1614+ fn reduce ( zelf : PyRef < Self > , vm : & VirtualMachine ) -> PyResult < PyTupleRef > {
1615+ let args: Vec < PyObjectRef > = zelf
1616+ . iterators
1617+ . to_owned ( )
1618+ . into_iter ( )
1619+ . map ( |i| i. to_pyobject ( vm) )
1620+ . collect ( ) ;
1621+ Ok ( vm. new_tuple ( (
1622+ zelf. class ( ) . to_owned ( ) ,
1623+ vm. new_tuple ( args) ,
1624+ zelf. fillvalue . read ( ) . to_owned ( ) ,
1625+ ) ) )
1626+ }
1627+
1628+ #[ pymethod( magic) ]
1629+ fn setstate ( zelf : PyRef < Self > , state : PyObjectRef , _vm : & VirtualMachine ) -> PyResult < ( ) > {
1630+ * zelf. fillvalue . write ( ) = state. to_owned ( ) ;
1631+ Ok ( ( ) )
1632+ }
1633+ }
16131634 impl IterNextIterable for PyItertoolsZipLongest { }
16141635 impl IterNext for PyItertoolsZipLongest {
16151636 fn next ( zelf : & Py < Self > , vm : & VirtualMachine ) -> PyResult < PyIterReturn > {
@@ -1627,7 +1648,7 @@ mod decl {
16271648 if numactive == 0 {
16281649 return Ok ( PyIterReturn :: StopIteration ( v) ) ;
16291650 }
1630- zelf. fillvalue . clone ( )
1651+ zelf. fillvalue . read ( ) . clone ( )
16311652 }
16321653 } ;
16331654 result. push ( next_obj) ;
0 commit comments