[PATCH] Make koji.plugin.export_in() decorator working

Mike McLean mikem at redhat.com
Thu Apr 2 19:56:04 UTC 2015


On 04/02/2015 11:31 AM, Pavol Babincak wrote:
> Python raised problem with local variable before:
>
>      UnboundLocalError: local variable 'alias' referenced before
>      assignment
> ---
>   koji/plugin.py | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/koji/plugin.py b/koji/plugin.py
> index 1b83365..e189d1f 100644
> --- a/koji/plugin.py
> +++ b/koji/plugin.py
> @@ -118,12 +118,12 @@ def export_in(module, alias=None):
>       """
>       def dec(f):
>           if alias is None:
> -            alias = "%s.%s" % (module, f.__name__)
> +            local_alias = "%s.%s" % (module, f.__name__)
>           else:
> -            alias = "%s.%s" % (module, alias)
> +            local_alias = "%s.%s" % (module, alias)
>           setattr(f, 'exported', True)
>           setattr(f, 'export_module', module)
> -        setattr(f, 'export_alias', alias)
> +        setattr(f, 'export_alias', local_alias)
>           return f
>       return dec
>

ack. I guess you're the first person to use that one :)






More information about the buildsys mailing list