From 4830e9523d067492aa77d27ac53eaaa7e96074f3 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 30 Jan 2016 14:40:19 -0600 Subject: [PATCH] Py2.6/2.7 bug compatibility: no list comprehensions in function with exec --- bin/loopy | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bin/loopy b/bin/loopy index c9fc8f516..00231174e 100644 --- a/bin/loopy +++ b/bin/loopy @@ -226,16 +226,25 @@ def main(): code = "\n\n".join(codes) + # {{{ edit code if requested + import os edit_kernel_env = os.environ.get("LOOPY_EDIT_KERNEL") - if (args.edit_code - or ( - edit_kernel_env is not None - and - any(edit_kernel_env.lower() in k.name.lower() for k in kernels))): + need_edit = args.edit_code + if not need_edit and edit_kernel_env is not None: + # Do not replace with "any()"--Py2.6/2.7 bug doesn't like + # comprehensions in functions with exec(). + + for k in kernels: + if edit_kernel_env.lower() in k.name.lower(): + need_edit = True + + if need_edit: from pytools import invoke_editor code = invoke_editor(code, filename="edit.cl") + # }}} + if outfile == "-": sys.stdout.write(code) else: -- GitLab