Skip to content

Commit 38611b8

Browse files
committed
fix a few cases of UnsupportedSpecializations
1 parent 53cfbd2 commit 38611b8

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,10 +1021,10 @@ public abstract static class LseekNode extends PythonFileNode {
10211021
private final ConditionProfile noFile = ConditionProfile.createBinaryProfile();
10221022

10231023
@Specialization
1024-
Object lseek(VirtualFrame frame, int fd, long pos, int how,
1024+
Object lseek(VirtualFrame frame, long fd, long pos, int how,
10251025
@Cached PRaiseOSErrorNode raise,
10261026
@Cached("createClassProfile()") ValueProfile channelClassProfile) {
1027-
Channel channel = getResources().getFileChannel(fd, channelClassProfile);
1027+
Channel channel = getResources().getFileChannel((int) fd, channelClassProfile);
10281028
if (noFile.profile(channel == null || !(channel instanceof SeekableByteChannel))) {
10291029
throw raise.raiseOSError(frame, OSErrorEnum.ESPIPE);
10301030
}
@@ -1062,8 +1062,10 @@ public abstract static class CloseNode extends PythonFileNode {
10621062
private final ConditionProfile noFile = ConditionProfile.createBinaryProfile();
10631063

10641064
@Specialization
1065-
Object close(int fd,
1065+
Object close(Object fdObject,
1066+
@Cached CastToIndexNode castToIndex,
10661067
@Cached("createClassProfile()") ValueProfile channelClassProfile) {
1068+
int fd = castToIndex.execute(fdObject);
10671069
PosixResources resources = getResources();
10681070
Channel channel = resources.getFileChannel(fd, channelClassProfile);
10691071
if (noFile.profile(channel == null)) {
@@ -1244,16 +1246,18 @@ Object read(@SuppressWarnings("unused") VirtualFrame frame, int fd, long request
12441246
@TypeSystemReference(PythonArithmeticTypes.class)
12451247
public abstract static class IsATTYNode extends PythonBuiltinNode {
12461248
@Specialization
1247-
boolean isATTY(int fd) {
1248-
switch (fd) {
1249-
case 0:
1250-
case 1:
1251-
case 2:
1252-
return terminalIsInteractive(getContext());
1253-
default:
1254-
return false;
1249+
boolean isATTY(long fd) {
1250+
if (fd >= 0 && fd <= 2) {
1251+
return terminalIsInteractive(getContext());
1252+
} else {
1253+
return false;
12551254
}
12561255
}
1256+
1257+
@Fallback
1258+
boolean isATTY(@SuppressWarnings("unused") Object fd) {
1259+
return false;
1260+
}
12571261
}
12581262

12591263
@Builtin(name = "_exit", minNumOfPositionalArgs = 1)

0 commit comments

Comments
 (0)