File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 34
34
b = bytes ([1 , 2 , 3 ])
35
35
assert a == b
36
36
37
- try :
37
+ with assert_raises ( TypeError ) :
38
38
bytes ([object ()])
39
- except TypeError :
40
- pass
39
+
40
+ with assert_raises (TypeError ):
41
+ bytes (1.0 )
41
42
42
43
with assert_raises (ValueError ):
43
44
bytes (- 1 )
Original file line number Diff line number Diff line change @@ -105,13 +105,13 @@ impl ByteInnerNewOptions {
105
105
obj => {
106
106
let elements = vm. extract_elements( & obj) . or_else( |_| {
107
107
Err ( vm. new_type_error( format!(
108
- "cannot convert {} object to bytes" ,
108
+ "cannot convert '{}' object to bytes" ,
109
109
obj. class( ) . name
110
110
) ) )
111
111
} ) ;
112
112
113
113
let mut data_bytes = vec![ ] ;
114
- for elem in elements. unwrap ( ) {
114
+ for elem in elements? {
115
115
let v = objint:: to_int( vm, & elem, & BigInt :: from( 10 ) ) ?;
116
116
if let Some ( i) = v. to_u8( ) {
117
117
data_bytes. push( i) ;
You can’t perform that action at this time.
0 commit comments