File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -197,7 +197,7 @@ macro_rules! py_argparse_parse_plist_impl {
197197 // TT muncher macro that does the main work for py_argparse_parse_plist!.
198198
199199 // Base case: all parameters handled
200- { $callback: ident { $( $initial_arg: tt) * } $output: tt ( ) } => {
200+ { $callback: ident { $( $initial_arg: tt) * } $output: tt ( $ ( , ) ? ) } => {
201201 $crate:: $callback! { $( $initial_arg) * $output }
202202 } ;
203203 // Kwargs parameter with reference extraction
Original file line number Diff line number Diff line change @@ -80,6 +80,32 @@ fn one_arg() {
8080 assert ! ( obj. call( py, NoArgs , Some ( & dict) ) . is_err( ) ) ;
8181}
8282
83+ #[ test]
84+ fn trailing_comma ( ) {
85+ fn f ( _py : Python , i : usize , j : usize ) -> PyResult < usize > {
86+ Ok ( i + j)
87+ }
88+
89+ let gil = Python :: acquire_gil ( ) ;
90+ let py = gil. python ( ) ;
91+ // Define a function where the parameters are on separate
92+ // lines with trailing commas.
93+ let obj = py_fn ! (
94+ py,
95+ f(
96+ first_parameter_with_long_name: usize ,
97+ second_parameter_with_long_name: usize ,
98+ )
99+ ) ;
100+ assert_eq ! (
101+ obj. call( py, ( 1 , 1 ) , None )
102+ . unwrap( )
103+ . extract:: <i32 >( py)
104+ . unwrap( ) ,
105+ 2
106+ ) ;
107+ }
108+
83109#[ test]
84110fn inline_two_args ( ) {
85111 let gil = Python :: acquire_gil ( ) ;
You can’t perform that action at this time.
0 commit comments