Skip to content

Commit 41da0a5

Browse files
committed
Revert "remove _JAVA_OPTIONS and JAVA_TOOL_OPTIONS from our environment"
This reverts commit 36d2969be337bd87bc5cb7b80ccf67829f53372d.
1 parent e77bcef commit 41da0a5

File tree

2 files changed

+3
-42
lines changed

2 files changed

+3
-42
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@
8282
import java.util.Set;
8383
import java.util.concurrent.TimeUnit;
8484

85-
import org.graalvm.nativeimage.ImageInfo;
86-
8785
import com.oracle.graal.python.PythonLanguage;
8886
import com.oracle.graal.python.builtins.Builtin;
8987
import com.oracle.graal.python.builtins.CoreFunctions;
@@ -280,18 +278,6 @@ public void postInitialize(PythonCore core) {
280278
Map<String, String> getenv = System.getenv();
281279
PDict environ = core.factory().createDict();
282280
for (Entry<String, String> entry : getenv.entrySet()) {
283-
if (!ImageInfo.inImageCode()) {
284-
// both _JAVA_OPTIONS and JAVA_TOOL_OPTIONS are adeed during JVM
285-
// startup automatically. We do not want to repeat these, they
286-
// are already in our ExecutableList if we're running on the
287-
// JVM. OTOH, some script may set these explicitly later on. So
288-
// whatever they are right now, we'll empty them, so that any
289-
// subprocess launched later will not inherit them.
290-
if ("_JAVA_OPTIONS".equals(entry.getKey()) || "JAVA_TOOL_OPTIONS".equals(entry.getKey())) {
291-
continue;
292-
}
293-
}
294-
295281
String value;
296282
if ("__PYVENV_LAUNCHER__".equals(entry.getKey())) {
297283
// On Mac, the CPython launcher uses this env variable to specify the real Python
@@ -364,7 +350,6 @@ Object doExecuteInternal(PythonModule thisModule, String path, PSequence args) t
364350
PDict environ = (PDict) thisModule.getAttribute("environ");
365351
ProcessBuilder builder = new ProcessBuilder(cmd);
366352
Map<String, String> environment = builder.environment();
367-
environment.clear();
368353
environ.entries().forEach(entry -> {
369354
environment.put(new String(toBytes.execute(null, entry.key)), new String(toBytes.execute(null, entry.value)));
370355
});
@@ -1496,12 +1481,11 @@ PTuple waitpidFallback(VirtualFrame frame, Object pid, Object options,
14961481
}
14971482
}
14981483

1499-
@Builtin(name = "system", minNumOfPositionalArgs = 1, declaresExplicitSelf = true)
1484+
@Builtin(name = "system", minNumOfPositionalArgs = 1)
15001485
@GenerateNodeFactory
15011486
@TypeSystemReference(PythonArithmeticTypes.class)
15021487
abstract static class SystemNode extends PythonBuiltinNode {
15031488
private static final TruffleLogger LOGGER = PythonLanguage.getLogger(SystemNode.class);
1504-
@Child private BytesNodes.ToBytesNode toBytes = BytesNodes.ToBytesNode.create();
15051489

15061490
static final String[] shell;
15071491
static {
@@ -1552,7 +1536,7 @@ public void finish() {
15521536

15531537
@TruffleBoundary
15541538
@Specialization
1555-
int system(PythonModule thisModule, String cmd) {
1539+
int system(String cmd) {
15561540
PythonContext context = getContext();
15571541
if (!context.isExecutableAccessAllowed()) {
15581542
return -1;
@@ -1562,13 +1546,6 @@ int system(PythonModule thisModule, String cmd) {
15621546
Env env = context.getEnv();
15631547
try {
15641548
ProcessBuilder pb = new ProcessBuilder(command);
1565-
PDict environ = (PDict) thisModule.getAttribute("environ");
1566-
ProcessBuilder builder = new ProcessBuilder(cmd);
1567-
Map<String, String> environment = pb.environment();
1568-
environment.clear();
1569-
environ.entries().forEach(entry -> {
1570-
environment.put(new String(toBytes.execute(null, entry.key)), new String(toBytes.execute(null, entry.value)));
1571-
});
15721549
pb.directory(new File(env.getCurrentWorkingDirectory().getPath()));
15731550
PipePump stdout = null, stderr = null;
15741551
boolean stdsArePipes = !terminalIsInteractive(context);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixSubprocessModuleBuiltins.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
import com.oracle.graal.python.builtins.objects.PNone;
6060
import com.oracle.graal.python.builtins.objects.bytes.BytesNodes;
6161
import com.oracle.graal.python.builtins.objects.bytes.PBytes;
62-
import com.oracle.graal.python.builtins.objects.dict.PDict;
6362
import com.oracle.graal.python.builtins.objects.function.PArguments;
6463
import com.oracle.graal.python.builtins.objects.list.PList;
6564
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
@@ -183,7 +182,6 @@ private synchronized int forkExec(PList args, @SuppressWarnings("unused") PList
183182
}
184183

185184
Map<String, String> environment = pb.environment();
186-
environment.clear();
187185
for (Object keyValue : env.getSequenceStorage().getInternalArray()) {
188186
if (keyValue instanceof PBytes) {
189187
// NOTE: passing 'null' frame means we took care of the global state in the
@@ -231,20 +229,6 @@ private synchronized int forkExec(PList args, @SuppressWarnings("unused") PList
231229
}
232230
}
233231

234-
@TruffleBoundary
235-
private PList createEnvList() {
236-
PDict environ = (PDict) getContext().getCore().lookupBuiltinModule("posix").getAttribute("environ");
237-
ArrayList<Object> envList = new ArrayList<>();
238-
environ.entries().forEach(entry -> {
239-
StringBuilder sb = new StringBuilder();
240-
sb.append(new String(toBytes.execute(null, entry.key)));
241-
sb.append("=");
242-
sb.append(new String(toBytes.execute(null, entry.value)));
243-
envList.add(factory().createBytes(sb.toString().getBytes()));
244-
});
245-
return factory().createList(envList.toArray());
246-
}
247-
248232
@Specialization(replaces = "forkExec")
249233
int forkExecDefault(VirtualFrame frame, Object args, Object executable_list, Object close_fds,
250234
Object fdsToKeep, Object cwd, Object env,
@@ -267,7 +251,7 @@ int forkExecDefault(VirtualFrame frame, Object args, Object executable_list, Obj
267251

268252
PList actualEnv;
269253
if (env instanceof PNone) {
270-
actualEnv = createEnvList();
254+
actualEnv = factory().createList();
271255
} else {
272256
actualEnv = castEnv.execute(frame, env);
273257
}

0 commit comments

Comments
 (0)