Skip to content
Snippets Groups Projects
Commit 713bc819 authored by Piotr Ożarowski's avatar Piotr Ożarowski
Browse files

don't fail if file with a shebang is not available

(f.e. when moved to another package)
parent 4112df0b
No related branches found
No related tags found
No related merge requests found
......@@ -118,13 +118,16 @@ def shebang2pyver(fname):
:rtype: tuple
:returns: pair of Python interpreter string and Python version
"""
with open(fname) as fp:
data = fp.read(32)
match = SHEBANG_RE.match(data)
if not match:
return None
res = match.groups()
if res != (None, None):
if res[1]:
res = res[0], getver(res[1])
return res
try:
with open(fname) as fp:
data = fp.read(32)
match = SHEBANG_RE.match(data)
if not match:
return None
res = match.groups()
if res != (None, None):
if res[1]:
res = res[0], getver(res[1])
return res
except IOError:
log.error('cannot open %s', fname)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment