@@ -87,8 +87,8 @@ def command_to_str(
8787 input : Optional [bytes ],
8888) -> bytes :
8989 """Reconstitute a macro call from its parsed form."""
90- args_string = b"(" + b"," .join (args ) + b")" if args is not None else b" "
91- input_string = b"{" + input + b"}" if input is not None else b" "
90+ args_string = b"" if args is None else b" (" + b"," .join (args ) + b")"
91+ input_string = b"" if input is None else b"{" + input + b"} "
9292 return b"$" + name + args_string + input_string
9393
9494
@@ -369,13 +369,13 @@ def do_macro(
369369 input : Optional [bytes ],
370370 ) -> bytes :
371371 debug (f"do_macro { command_to_str (name , args , input )} " )
372- name = name .decode ("iso-8859-1" )
373- args = [self .expand_arg (arg ) for arg in args ] if args is not None else None
374- input = self . expand_arg ( input ) if input is not None else None
372+ name_str = name .decode ("iso-8859-1" )
373+ args = None if args is None else [self .expand_arg (arg ) for arg in args ]
374+ input = None if input is None else self . expand_arg ( input )
375375 try :
376- return getattr (self ._macros , name )(args , input )
376+ return getattr (self ._macros , name_str )(args , input )
377377 except AttributeError :
378- raise ValueError (f"no such macro '${ name } '" )
378+ raise ValueError (f"no such macro '${ name_str } '" )
379379
380380 def expand (self , text : bytes ) -> bytes :
381381 """Expand `text`.
@@ -467,7 +467,7 @@ def outputpath(self, args: Optional[list[bytes]], input: Optional[bytes]) -> byt
467467 raise ValueError ("$outputpath does not take arguments" )
468468 if input is not None :
469469 raise ValueError ("$outputpath does not take an input" )
470- return bytes (self ._expand .output_file ) or b''
470+ return b'' if self . _expand . output_file is None else bytes (self ._expand .output_file )
471471
472472 def expand (self , args : Optional [list [bytes ]], input : Optional [bytes ]) -> bytes :
473473 if args is not None :
@@ -504,7 +504,7 @@ def run(self, args: Optional[list[bytes]], input: Optional[bytes]) -> bytes:
504504 debug (command_to_str (b"run" , args , input ))
505505
506506 exe_path = self ._expand .file_arg (args [0 ], exe = True )
507- expanded_input = self . _expand . expand ( input ) if input is not None else None
507+ expanded_input = None if input is None else self . _expand . expand ( input )
508508 return filter_bytes (expanded_input , exe_path , args [1 :])
509509
510510
0 commit comments