|
113 | 113 | import com.oracle.graal.python.builtins.objects.ints.PInt;
|
114 | 114 | import com.oracle.graal.python.builtins.objects.list.PList;
|
115 | 115 | import com.oracle.graal.python.builtins.objects.module.PythonModule;
|
| 116 | +import com.oracle.graal.python.builtins.objects.socket.PSocket; |
116 | 117 | import com.oracle.graal.python.builtins.objects.str.PString;
|
117 | 118 | import com.oracle.graal.python.builtins.objects.tuple.PTuple;
|
118 | 119 | import com.oracle.graal.python.builtins.objects.type.LazyPythonClass;
|
@@ -509,15 +510,10 @@ Object setInheritableStd(@SuppressWarnings("unused") int fd, @SuppressWarnings("
|
509 | 510 | }
|
510 | 511 |
|
511 | 512 | @Specialization(guards = "fd > 2")
|
512 |
| - Object setInheritable(int fd, @SuppressWarnings("unused") Object inheritable) { |
513 |
| - try { |
514 |
| - String path = getResources().getFilePath(fd); |
515 |
| - TruffleFile f = getContext().getEnv().getTruffleFile(path); |
516 |
| - if (!f.exists()) { |
517 |
| - throw raise(OSError, "No such file or directory: '%s'", path); |
518 |
| - } |
519 |
| - } catch (NullPointerException e) { |
520 |
| - throw raise(OSError, "Not a valid file descriptor, maybe a socket?'"); |
| 513 | + Object setInheritable(VirtualFrame frame, int fd, @SuppressWarnings("unused") Object inheritable) { |
| 514 | + Channel ch = getResources().getFileChannel(fd); |
| 515 | + if (ch == null || ch instanceof PSocket) { |
| 516 | + throw raiseOSError(frame, OSErrorEnum.EBADF.getNumber()); |
521 | 517 | }
|
522 | 518 | // TODO: investigate how to map this to the truffle file api (if supported)
|
523 | 519 | return PNone.NONE;
|
|
0 commit comments