File tree 3 files changed +8
-12
lines changed
3 files changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,6 @@ def test_copy(self):
54
54
self .assertEqual (a , b )
55
55
self .assertEqual (type (a ), type (b ))
56
56
57
- # TODO: RUSTPYTHON
58
- @unittest .expectedFailure
59
57
def test_empty_sequence (self ):
60
58
b = self .type2test ()
61
59
self .assertEqual (len (b ), 0 )
Original file line number Diff line number Diff line change 4
4
def expect_cannot_fit_index_error (s , index ):
5
5
try :
6
6
s [index ]
7
- except IndexError :
8
- pass
9
- # TODO: Replace current except block with commented
10
- # after solving https://github.com/RustPython/RustPython/issues/322
11
- # except IndexError as error:
12
- # assert str(error) == "cannot fit 'int' into an index-sized integer"
7
+ except IndexError as error :
8
+ assert str (error ) == "cannot fit 'int' into an index-sized integer"
13
9
else :
14
10
assert False
15
11
Original file line number Diff line number Diff line change @@ -136,10 +136,12 @@ pub enum SequenceIndex {
136
136
impl TryFromObject for SequenceIndex {
137
137
fn try_from_object ( vm : & VirtualMachine , obj : PyObjectRef ) -> PyResult < Self > {
138
138
match_class ! ( match obj {
139
- i @ PyInt => Ok ( SequenceIndex :: Int ( isize :: try_from_object(
140
- vm,
141
- i. into_object( )
142
- ) ?) ) ,
139
+ i @ PyInt => i
140
+ . as_bigint( )
141
+ . to_isize( )
142
+ . map( SequenceIndex :: Int )
143
+ . ok_or_else( || vm
144
+ . new_index_error( "cannot fit 'int' into an index-sized integer" . to_owned( ) ) ) ,
143
145
s @ PySlice => Ok ( SequenceIndex :: Slice ( s) ) ,
144
146
obj => Err ( vm. new_type_error( format!(
145
147
"sequence indices be integers or slices, not {}" ,
You can’t perform that action at this time.
0 commit comments