[pacman-dev] [PATCH 2/8] Use Python's "exec" instead of deprecated "execfile".

Allan McRae allan at archlinux.org
Wed Oct 9 23:06:20 EDT 2013


On 10/10/13 10:35, Jeremy Heiner wrote:
> This was the only issue reported by "python2 -3".
> 
> Signed-off-by: Jeremy Heiner <ScalaProtractor at gmail.com>
> ---
>  test/pacman/pmtest.py | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
> index b343d55..c183161 100644
> --- a/test/pacman/pmtest.py
> +++ b/test/pacman/pmtest.py
> @@ -100,7 +100,11 @@ def load(self):
>          if os.path.isfile(self.name):
>              # all tests expect this to be available
>              from pmpkg import pmpkg
> -            execfile(self.name)
> +            input = open(self.name)
> +            try: # a "with" would be perfect here...
> +                exec(input.read())
> +            finally: # ...but isn't available in Python 2.5

Why is that comment split in two?   Anyway, there is no python-2.5, so
use the with.

> +                input.close()
>          else:
>              raise IOError("file %s does not exist!" % self.name)
>  
> 



More information about the pacman-dev mailing list