File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -157,7 +157,6 @@ def __index__(self):
157
157
158
158
self .assertEqual (self .type2test (B (b"foobar" )), b"foobar" )
159
159
160
- @unittest .skip ("TODO: RUSTPYTHON" )
161
160
def test_from_ssize (self ):
162
161
self .assertEqual (self .type2test (0 ), b'' )
163
162
self .assertEqual (self .type2test (1 ), b'\x00 ' )
Original file line number Diff line number Diff line change @@ -85,9 +85,19 @@ impl ByteInnerNewOptions {
85
85
let value = if let OptionalArg :: Present ( ival) = self . val_option {
86
86
match_class ! ( match ival. clone( ) {
87
87
i @ PyInt => {
88
- let size = objint:: get_value( & i. into_object( ) )
89
- . to_usize( )
90
- . ok_or_else( || vm. new_value_error( "negative count" . to_owned( ) ) ) ?;
88
+ let size =
89
+ objint:: get_value( & i. into_object( ) )
90
+ . to_isize( )
91
+ . ok_or_else( || {
92
+ vm. new_overflow_error(
93
+ "cannot fit 'int' into an index-sized integer" . to_owned( ) ,
94
+ )
95
+ } ) ?;
96
+ let size = if size < 0 {
97
+ return Err ( vm. new_value_error( "negative count" . to_owned( ) ) ) ;
98
+ } else {
99
+ size as usize
100
+ } ;
91
101
Ok ( vec![ 0 ; size] )
92
102
}
93
103
_l @ PyString => {
You can’t perform that action at this time.
0 commit comments