File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -2633,3 +2633,52 @@ match 2:
2633
2633
"
2634
2634
) ;
2635
2635
}
2636
+
2637
+ #[ test]
2638
+ fn except_star_before_py311 ( ) {
2639
+ let stdin = r#"
2640
+ try:
2641
+ raise Exception
2642
+ except* TypeError as e:
2643
+ pass
2644
+ "# ;
2645
+
2646
+ // ok on 3.11
2647
+ assert_cmd_snapshot ! ( Command :: new( get_cargo_bin( BIN_NAME ) )
2648
+ . args( STDIN_BASE_OPTIONS )
2649
+ . args( [ "--stdin-filename" , "test.py" ] )
2650
+ . arg( "--target-version=py311" )
2651
+ . arg( "-" )
2652
+ . pass_stdin( stdin) ,
2653
+ @r"
2654
+ success: false
2655
+ exit_code: 1
2656
+ ----- stdout -----
2657
+ test.py:4:22: F841 [*] Local variable `e` is assigned to but never used
2658
+ Found 1 error.
2659
+ [*] 1 fixable with the `--fix` option.
2660
+
2661
+ ----- stderr -----
2662
+ "
2663
+ ) ;
2664
+
2665
+ // error on 3.10
2666
+ assert_cmd_snapshot ! ( Command :: new( get_cargo_bin( BIN_NAME ) )
2667
+ . args( STDIN_BASE_OPTIONS )
2668
+ . args( [ "--stdin-filename" , "test.py" ] )
2669
+ . arg( "--target-version=py310" )
2670
+ . arg( "-" )
2671
+ . pass_stdin( stdin) ,
2672
+ @r"
2673
+ success: false
2674
+ exit_code: 1
2675
+ ----- stdout -----
2676
+ test.py:2:1: SyntaxError: Cannot use `except*` on Python 3.10 (syntax was new in Python 3.11)
2677
+ test.py:4:22: F841 [*] Local variable `e` is assigned to but never used
2678
+ Found 2 errors.
2679
+ [*] 1 fixable with the `--fix` option.
2680
+
2681
+ ----- stderr -----
2682
+ "
2683
+ ) ;
2684
+ }
You can’t perform that action at this time.
0 commit comments