8000 Fix command line quoting for Windows (#169) · sajith/codecov-python@4ec70db · GitHub
[go: up one dir, main page]

Skip to content

Commit 4ec70db

Browse files
authored
Fix command line quoting for Windows (codecov#169)
1 parent 6ba8cbc commit 4ec70db

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

codecov/__init__.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,22 @@
2727
except ImportError: # pragma: no cover
2828
from urllib import urlencode
2929

30-
try:
31-
from shlex import quote
32-
except ImportError: # pragma: no cover
33-
from pipes import quote
30+
quote = None
31+
if sys.platform == 'win32': # pragma: no cover
32+
try:
33+
# https://github.com/python/cpython/blob/3.7/Lib/subprocess.py#L174-L175
34+
from subprocess import list2cmdline
35+
36+
def quote(arg):
37+
return list2cmdline([arg])
38+
except ImportError:
39+
pass
40+
41+
if quote is None:
42+
try:
43+
from shlex import quote
44+
except ImportError: # pragma: no cover
45+
from pipes import quote
3446

3547
import subprocess
3648

0 commit comments

Comments
 (0)
0