File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ mod decl {
22
22
VirtualMachine ,
23
23
} ;
24
24
use crossbeam_utils:: atomic:: AtomicCell ;
25
+ use malachite_bigint:: BigInt ;
26
+ use num_traits:: One ;
27
+
25
28
use num_traits:: { Signed , ToPrimitive } ;
26
29
use std:: fmt;
27
30
@@ -1965,7 +1968,7 @@ mod decl {
1965
1968
#[ derive( FromArgs ) ]
1966
1969
struct BatchedNewArgs {
1967
1970
#[ pyarg( positional) ]
1968
- iterable : PyIter ,
1971
+ iterable_ref : PyObjectRef ,
1969
1972
#[ pyarg( positional) ]
BDF7
td>1970
1973
n : PyIntRef ,
1971
1974
}
@@ -1975,14 +1978,18 @@ mod decl {
1975
1978
1976
1979
fn py_new (
1977
1980
cls : PyTypeRef ,
1978
- Self :: Args { iterable , n } : Self :: Args ,
1981
+ Self :: Args { iterable_ref , n } : Self :: Args ,
1979
1982
vm : & VirtualMachine ,
1980
1983
) -> PyResult {
1981
1984
let n = n. as_bigint ( ) ;
1982
- if n. is_negative ( ) {
1985
+ if n. lt ( & BigInt :: one ( ) ) {
1983
1986
return Err ( vm. new_value_error ( "n must be at least one" . to_owned ( ) ) ) ;
1984
1987
}
1985
1988
let n = n. to_usize ( ) . unwrap ( ) ;
1989
+ let iterable = match iterable_ref. get_iter ( vm) {
1990
+ Ok ( it) => it,
1991
+ Err ( e) => return Err ( e) ,
1992
+ } ;
1986
1993
1987
1994
Self {
1988
1995
iterable,
You can’t perform that action at this time.
0 commit comments