Skip to content

Commit 162dd1d

Browse files
committed
Return original objects instead of integer file descriptors in select()
1 parent ef47936 commit 162dd1d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
6868
import com.oracle.graal.python.runtime.exception.PythonErrorType;
6969
import com.oracle.graal.python.runtime.sequence.PSequence;
70-
import com.oracle.graal.python.runtime.sequence.storage.IntSequenceStorage;
7170
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
7271
import com.oracle.truffle.api.CompilerDirectives.ValueType;
7372
import com.oracle.truffle.api.dsl.Cached;
@@ -226,12 +225,13 @@ private ChannelFD[] seq2set(VirtualFrame frame, Object sequence, PythonObjectLib
226225
PSequence pSequence = constructListNode.execute(sequence);
227226

228227
for (int i = 0; i < len; i++) {
229-
int fd = itemLib.asFileDescriptorWithState(callGetItemNode.executeObject(frame, pSequence, i), threadState);
228+
Object pythonObject = callGetItemNode.executeObject(frame, pSequence, i);
229+
int fd = itemLib.asFileDescriptorWithState(pythonObject, threadState);
230230
Channel fileChannel = getContext().getResources().getFileChannel(fd);
231231
if (!(fileChannel instanceof SelectableChannel)) {
232232
throw NonSelectableChannel.INSTANCE;
233233
}
234-
result[i] = new ChannelFD(fd, (SelectableChannel) fileChannel);
234+
result[i] = new ChannelFD(pythonObject, (SelectableChannel) fileChannel);
235235
}
236236
return result;
237237
}
@@ -243,13 +243,13 @@ private PList toList(ChannelFD[] arr) {
243243
cnt++;
244244
}
245245
}
246-
int[] fds = new int[cnt];
246+
Object[] fds = new Object[cnt];
247247
for (ChannelFD channelFD : arr) {
248248
if (channelFD != null) {
249-
fds[fds.length - (cnt--)] = channelFD.fd;
249+
fds[fds.length - (cnt--)] = channelFD.pythonObject;
250250
}
251251
}
252-
return factory().createList(new IntSequenceStorage(fds));
252+
return factory().createList(fds);
253253
}
254254

255255
static LookupAndCallBinaryNode createGetItem() {
@@ -258,11 +258,11 @@ static LookupAndCallBinaryNode createGetItem() {
258258

259259
@ValueType
260260
private static final class ChannelFD {
261-
private final int fd;
261+
private final Object pythonObject;
262262
private final SelectableChannel channel;
263263

264-
private ChannelFD(int fd, SelectableChannel channel) {
265-
this.fd = fd;
264+
private ChannelFD(Object pythonObject, SelectableChannel channel) {
265+
this.pythonObject = pythonObject;
266266
this.channel = channel;
267267
}
268268
}

0 commit comments

Comments
 (0)