Skip to content

Commit

Permalink
Fixed #135: Expose and document the enquote_executable() function.
Browse files Browse the repository at this point in the history
  • Loading branch information
vsajip committed Jun 12, 2020
1 parent 78231f0 commit d111c4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions distlib/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'''


def _enquote_executable(executable):
def enquote_executable(executable):
if ' ' in executable:
# make sure we quote only the executable in case of env
# for example /usr/bin/env "/dir with spaces/bin/jython"
Expand Down Expand Up @@ -186,7 +186,7 @@ def _get_shebang(self, encoding, post_interp=b'', options=None):
# If the user didn't specify an executable, it may be necessary to
# cater for executable paths with spaces (not uncommon on Windows)
if enquote:
executable = _enquote_executable(executable)
executable = enquote_executable(executable)
# Issue #51: don't use fsencode, since we later try to
# check that the shebang is decodable using utf-8.
executable = executable.encode('utf-8')
Expand Down
5 changes: 2 additions & 3 deletions tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from distlib import DistlibException
from distlib.compat import fsencode, sysconfig
from distlib.scripts import ScriptMaker, _enquote_executable
from distlib.scripts import ScriptMaker, enquote_executable
from distlib.util import get_executable

HERE = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -391,8 +391,7 @@ def test_enquote_executable(self):
('/usr/bin/env with spaces', '/usr/bin/env "with spaces"'),
('/usr/bin/env "pre spaced"', '/usr/bin/env "pre spaced"')
):
self.assertEqual(_enquote_executable(executable),
expected)
self.assertEqual(enquote_executable(executable), expected)


if __name__ == '__main__': # pragma: no cover
Expand Down

0 comments on commit d111c4d

Please sign in to comment.