Skip to content

Commit 7785245

Browse files
committed
[GR-44442][GR-44443] Fixes for embedding scenarios.
PullRequest: graalpython/2650
2 parents 910c0b0 + be52aaa commit 7785245

File tree

3 files changed

+44
-11
lines changed

3 files changed

+44
-11
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SequenceFromStackNode.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -266,12 +266,20 @@ public void reportUpdatedCapacity(BasicSequenceStorage newStore) {
266266
if (PythonContext.get(this).getOption(PythonOptions.OverallocateLiteralLists)) {
267267
if (newStore.getCapacity() > initialCapacity.estimate()) {
268268
initialCapacity.updateFrom(newStore.getCapacity());
269-
LOGGER.finest(() -> String.format("Updating list size estimate at %s. Observed capacity: %d, new estimate: %d", getSourceSection(), newStore.getCapacity(),
270-
initialCapacity.estimate()));
269+
LOGGER.finest(() -> {
270+
SourceSection encapsulatingSourceSection = getEncapsulatingSourceSection();
271+
String sourceSection = encapsulatingSourceSection == null ? "<unavailable source>" : encapsulatingSourceSection.toString();
272+
return String.format("Updating list size estimate at %s. Observed capacity: %d, new estimate: %d", sourceSection, newStore.getCapacity(),
273+
initialCapacity.estimate());
274+
});
271275
}
272276
if (newStore.getElementType().generalizesFrom(type)) {
273277
type = newStore.getElementType();
274-
LOGGER.finest(() -> String.format("Updating list type estimate at %s. New type: %s", getSourceSection(), type.name()));
278+
LOGGER.finest(() -> {
279+
SourceSection encapsulatingSourceSection = getEncapsulatingSourceSection();
280+
String sourceSection = encapsulatingSourceSection == null ? "<unavailable source>" : encapsulatingSourceSection.toString();
281+
return String.format("Updating list type estimate at %s. New type: %s", sourceSection, type.name());
282+
});
275283
}
276284
}
277285
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/EmulatedPosixSupport.java

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,17 +1085,17 @@ private long[] basicStat(TruffleFile file, LinkOption... linkOptions) throws IOE
10851085
CREATION_TIME,
10861086
SIZE), linkOptions);
10871087
int mode = fileTypeBitsFromAttributes(attributes);
1088-
if (file.isReadable()) {
1088+
if (isReadable(file)) {
10891089
mode |= 0004;
10901090
mode |= 0040;
10911091
mode |= 0400;
10921092
}
1093-
if (file.isWritable()) {
1093+
if (isWritable(file)) {
10941094
mode |= 0002;
10951095
mode |= 0020;
10961096
mode |= 0200;
10971097
}
1098-
if (file.isExecutable()) {
1098+
if (isExecutable(file)) {
10991099
mode |= 0001;
11001100
mode |= 0010;
11011101
mode |= 0100;
@@ -1114,6 +1114,30 @@ private long[] basicStat(TruffleFile file, LinkOption... linkOptions) throws IOE
11141114
});
11151115
}
11161116

1117+
private static boolean isReadable(TruffleFile file) {
1118+
try {
1119+
return file.isReadable();
1120+
} catch (SecurityException e) {
1121+
return false;
1122+
}
1123+
}
1124+
1125+
private static boolean isWritable(TruffleFile file) {
1126+
try {
1127+
return file.isWritable();
1128+
} catch (SecurityException e) {
1129+
return false;
1130+
}
1131+
}
1132+
1133+
private static boolean isExecutable(TruffleFile file) {
1134+
try {
1135+
return file.isExecutable();
1136+
} catch (SecurityException e) {
1137+
return false;
1138+
}
1139+
}
1140+
11171141
private static long[] setTimestamps(Attributes attributes, TruffleFile.AttributeDescriptor<FileTime> ctimeDescriptor, long[] statResult) {
11181142
FileTime atime = attributes.get(LAST_ACCESS_TIME);
11191143
FileTime mtime = attributes.get(LAST_MODIFIED_TIME);
@@ -1700,13 +1724,13 @@ public boolean faccessat(int dirFd, Object path, int mode, boolean effectiveIds,
17001724
}
17011725
boolean result = true;
17021726
if ((mode & X_OK.value) != 0) {
1703-
result = result && file.isExecutable();
1727+
result = result && isExecutable(file);
17041728
}
17051729
if ((mode & R_OK.value) != 0) {
1706-
result = result && file.isReadable();
1730+
result = result && isReadable(file);
17071731
}
17081732
if ((mode & W_OK.value) != 0) {
1709-
result = result && file.isWritable();
1733+
result = result && isWritable(file);
17101734
}
17111735
return result;
17121736
}
@@ -2009,7 +2033,7 @@ public int forkExec(Object[] executables, Object[] args, Object cwd, Object[] en
20092033
for (Object o : executables) {
20102034
String path = pathToJavaString(o);
20112035
TruffleFile executableFile = cwdFile.resolve(path);
2012-
if (executableFile.isExecutable()) {
2036+
if (isExecutable(executableFile)) {
20132037
argStrings[0] = path;
20142038
try {
20152039
return exec(argStrings, cwdFile, envMap, stdinWriteFd, stdinReadFd, stdoutWriteFd, stdoutReadFd, stderrWriteFd, errPipeWriteFd, stderrReadFd);

graalpython/lib-graalpython/modules/ginstall.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ def matplotlib(**kwargs):
546546
python_dateutil(**kwargs)
547547
numpy(**kwargs)
548548
Pillow(**kwargs)
549+
kiwisolver(**kwargs)
549550

550551
def download_freetype(extracted_dir):
551552
target_dir = os.path.join(extracted_dir, "build")

0 commit comments

Comments
 (0)