Skip to content

Commit 676f705

Browse files
author
Shiva Poudel
committed
Merge pull request voxpupuli#238 from xaque208/python3factfix
Check that we have results before returning a value
2 parents 2111486 + 44728ef commit 676f705

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/facter/python_version.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
def get_python_version(executable)
44
if Facter::Util::Resolution.which(executable)
5-
Facter::Util::Resolution.exec("#{executable} -V 2>&1").match(/^.*(\d+\.\d+\.\d+)$/)[1]
5+
results = Facter::Util::Resolution.exec("#{executable} -V 2>&1").match(/^.*(\d+\.\d+\.\d+)$/)
6+
if results
7+
results[1]
8+
end
69
end
710
end
811

0 commit comments

Comments
 (0)