Skip to content

Commit 0faa73f

Browse files
committed
use backslashes to escape quotes on windows when we are not using cmd.exe to run something
1 parent 8942e47 commit 0faa73f

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

graalpython/lib-graalpython/patches/numpy/numpy-1.26.4.patch

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
diff --git a/numpy/core/include/numpy/ndarrayobject.h b/numpy/core/include/numpy/ndarrayobject.h
22
index d4b73eb..af90a68 100644
3-
--- a/numpy/_build_utils/gitversion.py
4-
+++ b/numpy/_build_utils/gitversion.py
5-
@@ -28,7 +28,7 @@ def git_version(version):
6-
git_hash = ''
7-
try:
8-
p = subprocess.Popen(
9-
- ['git', 'log', '-1', '--format="%H %aI"'],
10-
+ ['git', 'log', '-1', "--format='%H %aI'"], # Workaround for GraalPy's emulated posix backend on Windows
11-
stdout=subprocess.PIPE,
12-
stderr=subprocess.PIPE,
13-
cwd=os.path.dirname(__file__),
143
--- a/vendored-meson/meson/mesonbuild/utils/universal.py
154
+++ b/vendored-meson/meson/mesonbuild/utils/universal.py
165
@@ -727,6 +727,7 @@ def windows_detect_native_arch() -> str:

graalpython/lib-python/3/subprocess.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,20 +1826,21 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
18261826
args = [comspec, "/u", "/c", *args]
18271827
else:
18281828
args = [comspec, "/u", "/c", list2cmdline(args)]
1829-
for idx, arg in enumerate(args):
1830-
# Adapted per the quoting rules from
1831-
# https://learn.microsoft.com/en-us/cpp/c-language/parsing-c-command-line-arguments
1832-
if idx == 0:
1833-
continue
1834-
modified = False
1835-
if '"' in args[idx]:
1836-
args[idx] = args[idx].replace('"', '""')
1837-
modified = True
1838-
if '\\' in args[idx] and (shell or modified):
1839-
args[idx] = args[idx].replace('\\', '\\\\')
1840-
modified = True
1841-
if modified:
1842-
warnings.warn(f"Replacing\n\t{arg!r}\nwith\n\t{args[idx]!r}", RuntimeWarning)
1829+
else:
1830+
for idx, arg in enumerate(args):
1831+
# Adapted per the quoting rules from
1832+
# https://learn.microsoft.com/en-us/cpp/c-language/parsing-c-command-line-arguments
1833+
if idx == 0:
1834+
continue
1835+
modified = False
1836+
if '\\' in args[idx] and (shell or modified):
1837+
args[idx] = args[idx].replace('\\', '\\\\')
1838+
modified = True
1839+
if '"' in args[idx]:
1840+
args[idx] = args[idx].replace('"', '\\"')
1841+
modified = True
1842+
if modified:
1843+
warnings.warn(f"Replacing\n\t{arg!r}\nwith\n\t{args[idx]!r}", RuntimeWarning)
18431844
# End Truffle change
18441845

18451846
if shell:

0 commit comments

Comments
 (0)