File tree 2 files changed +14
-6
lines changed 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -209,10 +209,15 @@ impl PyByteArray {
209
209
210
210
fn _getitem ( & self , needle : & PyObject , vm : & VirtualMachine ) -> PyResult {
211
211
match SequenceIndex :: try_from_borrowed_object ( vm, needle) ? {
212
- SequenceIndex :: Int ( i) => self . borrow_buf ( ) . get_item_by_index ( vm, i) . map ( |x| vec ! [ x] ) ,
213
- SequenceIndex :: Slice ( slice) => self . borrow_buf ( ) . get_item_by_slice ( vm, slice) ,
212
+ SequenceIndex :: Int ( i) => self
213
+ . borrow_buf ( )
214
+ . get_item_by_index ( vm, i)
215
+ . map ( |x| vm. ctx . new_int ( x) . into ( ) ) ,
216
+ SequenceIndex :: Slice ( slice) => self
217
+ . borrow_buf ( )
218
+ . get_item_by_slice ( vm, slice)
219
+ . map ( |x| Self :: new_ref ( x, & vm. ctx ) . into ( ) ) ,
214
220
}
215
- . map ( |x| vm. ctx . new_bytes ( x) . into ( ) )
216
221
}
217
222
218
223
#[ pymethod( magic) ]
Original file line number Diff line number Diff line change @@ -173,10 +173,13 @@ impl PyBytes {
173
173
. inner
174
174
. elements
175
175
. get_item_by_index ( vm, i)
176
- . map ( |x| vec ! [ x] ) ,
177
- SequenceIndex :: Slice ( slice) => self . inner . elements . get_item_by_slice ( vm, slice) ,
176
+ . map ( |x| vm. ctx . new_int ( x) . into ( ) ) ,
177
+ SequenceIndex :: Slice ( slice) => self
178
+ . inner
179
+ . elements
180
+ . get_item_by_slice ( vm, slice)
181
+ . map ( |x| vm. ctx . new_bytes ( x) . into ( ) ) ,
178
182
}
179
- . map ( |x| vm. ctx . new_bytes ( x) . into ( ) )
180
183
}
181
184
182
185
#[ pymethod( magic) ]
You can’t perform that action at this time.
0 commit comments