File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -393,6 +393,31 @@ mod tests {
393393 )
394394 }
395395
396+ #[ test]
397+ fn test_parse_dict_comprehension ( ) {
398+ let source = String :: from ( "{x1: x2 for y in z}" ) ;
399+ let parse_ast = parse_expression ( & source) . unwrap ( ) ;
400+ assert_eq ! (
401+ parse_ast,
402+ ast:: Expression {
403+ location: ast:: Location :: new( 1 , 1 ) ,
404+ node: ast:: ExpressionType :: Comprehension {
405+ kind: Box :: new( ast:: ComprehensionKind :: Dict {
406+ key: mk_ident( "x1" , 1 , 2 ) ,
407+ value: mk_ident( "x2" , 1 , 6 ) ,
408+ } ) ,
409+ generators: vec![ ast:: Comprehension {
410+ location: ast:: Location :: new( 1 , 9 ) ,
411+ target: mk_ident( "y" , 1 , 13 ) ,
412+ iter: mk_ident( "z" , 1 , 18 ) ,
413+ ifs: vec![ ] ,
414+ is_async: false ,
415+ } ] ,
416+ }
417+ }
418+ ) ;
419+ }
420+
396421 #[ test]
397422 fn test_parse_list_comprehension ( ) {
398423 let source = String :: from ( "[x for y in z]" ) ;
Original file line number Diff line number Diff line change @@ -273,6 +273,13 @@ def __int__(self):
273273
274274assert int (F (1.2 )) == 3
275275
276+ class BadInt (int ):
277+ def __int__ (self ):
278+ return 42.0
279+
280+ with assert_raises (TypeError ):
281+ int (BadInt ())
282+
276283assert isinstance ((0 ).__round__ (), int )
277284assert isinstance ((1 ).__round__ (), int )
278285assert (0 ).__round__ () == 0
Original file line number Diff line number Diff line change @@ -419,6 +419,7 @@ impl PyContext {
419419 )
420420 }
421421
422+ #[ inline]
422423 pub fn new_bool ( & self , b : bool ) -> PyObjectRef {
423424 let value = if b {
424425 & self . true_value
Original file line number Diff line number Diff line change @@ -643,6 +643,7 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
643643 "htons" => ctx. new_rustfunc( socket_hton:: <u16 >) ,
644644 "ntohl" => ctx. new_rustfunc( socket_ntoh:: <u32 >) ,
645645 "ntohs" => ctx. new_rustfunc( socket_ntoh:: <u16 >) ,
646+ "has_ipv6" => ctx. new_bool( false ) ,
646647 "getdefaulttimeout" => ctx. new_rustfunc( |vm: & VirtualMachine | vm. get_none( ) ) ,
647648 "getaddrinfo" => ctx. new_rustfunc( socket_getaddrinfo) ,
648649 "gethostbyaddr" => ctx. new_rustfunc( socket_gethostbyaddr) ,
You can’t perform that action at this time.
0 commit comments