@@ -629,31 +629,29 @@ def call_module(self, module: str, args: str | list[str]):
629629
630630 # 'args' can be (1) a single string or (2) a list of strings.
631631 argv : bytes | ctp .Array [ctp .c_char_p ] | None
632- if isinstance (args , str ):
633- # 'args' is a single string that contains whitespace-separated arguments.
634- # In this way, we need to correctly handle option arguments that contain
635- # whitespaces or quotation marks. It's used in PyGMT <= v0.11.0 but is no
636- # longer recommended.
637- mode = self ["GMT_MODULE_CMD" ]
638- argv = args .encode ()
639- elif isinstance (args , list ):
632+ if isinstance (args , list ):
640633 # 'args' is a list of strings and each string contains a module argument.
641634 # In this way, GMT can correctly handle option arguments with whitespaces or
642635 # quotation marks. This is the preferred way to pass arguments to the GMT
643636 # API and is used for PyGMT >= v0.12.0.
644637 mode = len (args ) # 'mode' is the number of arguments.
645638 # Pass a null pointer if no arguments are specified.
646639 argv = strings_to_ctypes_array (args ) if mode != 0 else None
640+ elif isinstance (args , str ):
641+ # 'args' is a single string that contains whitespace-separated arguments.
642+ # In this way, we need to correctly handle option arguments that contain
643+ # whitespaces or quotation marks. It's used in PyGMT <= v0.11.0 but is no
644+ # longer recommended.
645+ mode = self ["GMT_MODULE_CMD" ]
646+ argv = args .encode ()
647647 else :
648- raise GMTInvalidInput (
649- "'args' must be either a string or a list of strings."
650- )
648+ msg = "'args' must either be a list of strings (recommended) or a string."
649+ raise GMTInvalidInput (msg )
651650
652651 status = c_call_module (self .session_pointer , module .encode (), mode , argv )
653652 if status != 0 :
654- raise GMTCLibError (
655- f"Module '{ module } ' failed with status code { status } :\n { self ._error_message } "
656- )
653+ msg = f"Module '{ module } ' failed with status code { status } :\n { self ._error_message } "
654+ raise GMTCLibError (msg )
657655
658656 def create_data (
659657 self ,
0 commit comments