[chirp_devel] [PATCH] Fixes case where column order setting parsing was calling split on None

Dan Smith
Sun Nov 19 06:58:16 PST 2017


> # HG changeset patch
> # User Christopher Hoover <ch at murgatroid.com>
> # Date 1510451669 28800
> #      Sat Nov 11 17:54:29 2017 -0800
> # Node ID daba4a5f7acefe52f5fa4f036c9df59865c8df1e
> # Parent  0e0470d3e892bfd4818bfb972b8b85d58f2b00d4
> Fixes case where column order setting parsing was calling split on None.

Same for this one.

> 
> diff -r 0e0470d3e892 -r daba4a5f7ace chirp/ui/memedit.py
> --- a/chirp/ui/memedit.py       Fri Nov 03 20:24:29 2017 -0400
> +++ b/chirp/ui/memedit.py       Sat Nov 11 17:54:29 2017 -0800
> @@ -961,15 +961,19 @@
> 
>          default_col_order = [x for x, y, z in self.cols if z]
>          try:
> -            col_order = self._config.get("column_order_%s" %
> -                                         self.__class__.__name__).split(",")
> -            if len(col_order) != len(default_col_order):
> -                raise Exception()
> -            for i in col_order:
> -                if i not in default_col_order:
> +            config_setting = self._config.get("column_order_%s" %
> +                                              self.__class__.__name__)
> +            if config_setting is None:

Did you actually experience this happening or are you just being defensive since it’s technically possible?

> +                col_order = default_col_order
> +            else:
> +                col_order = config_setting.split(",")
> +                if len(col_order) != len(default_col_order):
>                      raise Exception()
> +                for i in col_order:
> +                    if i not in default_col_order:
> +                        raise Exception()


One other way to do this would be to just make it:

  for i in col_order or default_col_order:

Thus avoiding the extra conditional and indent. But, that’s just a nit.

Thanks!

—Dan


More information about the chirp_devel mailing list