[Piglit] [PATCH] bugzilla 71822: Fix regression introduced to piglit-run.py

Brian Paul brianp at vmware.com
Wed Nov 20 16:13:34 PST 2013


On 11/20/2013 05:10 PM, Dylan Baker wrote:
> The commit 0618aa38d4a8a7c82994fb28a41576da9a2cc414 introduces a
> regression when using the -t/--include-filter or -x/--exclude-filter
> options. This is caused by the __iter__ magic method in the
> core.Environment class returning self.__dict__.iteritems(), which
> returns compiled regex objects. This will cause the json encoder to
> choke.
>
> This patch corrects the __iter__ method in core.Environment to yield
> regex items as regex.pattern, and attribute storing the original string
> used to create the pattern.
>
> cc: brianp at vmware.com
> cc: vlee at freedesktop.org
> Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
> ---
>   framework/core.py | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/framework/core.py b/framework/core.py
> index 91969dd..5a9e8b0 100644
> --- a/framework/core.py
> +++ b/framework/core.py
> @@ -417,7 +417,14 @@ class Environment:
>               self.exclude_filter.append(re.compile(each))
>
>       def __iter__(self):
> -        return self.__dict__.iteritems()
> +        for key, values in self.__dict__.iteritems():
> +            # If the values are regex compiled then yield their pattern
> +            # attribute, which is the original plaintext they were compiled
> +            # from, otherwise yield them normally.
> +            if key in ['filter', 'exclude_filter']:
> +                yield (key, [x.pattern for x in values])
> +            else:
> +                yield (key, values)
>
>       def run(self, command):
>           try:
>

Tested-by: Brian Paul <brianp at vmware.com>

Thanks, Dylan!

-Brian



More information about the Piglit mailing list