From e8d3e718ea26e7dd05d39f4d991e8bf5d477438d Mon Sep 17 00:00:00 2001 From: Michael Sarahan Date: Tue, 1 May 2018 08:25:54 -0500 Subject: [PATCH] optimize post regex --- conda_build/post.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/conda_build/post.py b/conda_build/post.py index abb2c2af40..9908ff6261 100644 --- a/conda_build/post.py +++ b/conda_build/post.py @@ -73,10 +73,12 @@ def fix_shebang(f, prefix, build_python, osx_is_app=False): bytes_ = True m = SHEBANG_PAT.match(mm) - python_pattern = (re.compile(br'\/python[w]?(?:$|\s|\Z)', re.M) if bytes_ else - re.compile(r'\/python[w]?(:$|\s|\z)', re.M)) - - if not (m and python_pattern.search(m.group())): + if m: + python_pattern = (re.compile(br'\/python[w]?(?:$|\s|\Z)', re.M) if bytes_ else + re.compile(r'\/python[w]?(:$|\s|\z)', re.M)) + if not python_pattern.search(m.group()): + return + else: return data = mm[:]