@@ -1021,10 +1021,10 @@ public abstract static class LseekNode extends PythonFileNode {
1021
1021
private final ConditionProfile noFile = ConditionProfile .createBinaryProfile ();
1022
1022
1023
1023
@ Specialization
1024
- Object lseek (VirtualFrame frame , int fd , long pos , int how ,
1024
+ Object lseek (VirtualFrame frame , long fd , long pos , int how ,
1025
1025
@ Cached PRaiseOSErrorNode raise ,
1026
1026
@ Cached ("createClassProfile()" ) ValueProfile channelClassProfile ) {
1027
- Channel channel = getResources ().getFileChannel (fd , channelClassProfile );
1027
+ Channel channel = getResources ().getFileChannel (( int ) fd , channelClassProfile );
1028
1028
if (noFile .profile (channel == null || !(channel instanceof SeekableByteChannel ))) {
1029
1029
throw raise .raiseOSError (frame , OSErrorEnum .ESPIPE );
1030
1030
}
@@ -1062,8 +1062,10 @@ public abstract static class CloseNode extends PythonFileNode {
1062
1062
private final ConditionProfile noFile = ConditionProfile .createBinaryProfile ();
1063
1063
1064
1064
@ Specialization
1065
- Object close (int fd ,
1065
+ Object close (Object fdObject ,
1066
+ @ Cached CastToIndexNode castToIndex ,
1066
1067
@ Cached ("createClassProfile()" ) ValueProfile channelClassProfile ) {
1068
+ int fd = castToIndex .execute (fdObject );
1067
1069
PosixResources resources = getResources ();
1068
1070
Channel channel = resources .getFileChannel (fd , channelClassProfile );
1069
1071
if (noFile .profile (channel == null )) {
@@ -1244,16 +1246,18 @@ Object read(@SuppressWarnings("unused") VirtualFrame frame, int fd, long request
1244
1246
@ TypeSystemReference (PythonArithmeticTypes .class )
1245
1247
public abstract static class IsATTYNode extends PythonBuiltinNode {
1246
1248
@ 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 ;
1255
1254
}
1256
1255
}
1256
+
1257
+ @ Fallback
1258
+ boolean isATTY (@ SuppressWarnings ("unused" ) Object fd ) {
1259
+ return false ;
1260
+ }
1257
1261
}
1258
1262
1259
1263
@ Builtin (name = "_exit" , minNumOfPositionalArgs = 1 )
0 commit comments