Skip to content

Commit cad245f

Browse files
committed
[GR-17960] Java-based Socket implementation
PullRequest: graalpython/634
2 parents 5f9029c + ad80918 commit cad245f

File tree

14 files changed

+1354
-51
lines changed

14 files changed

+1354
-51
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
*GeneralModuleTests.testCrucialConstants
2+
*GeneralModuleTests.testGetServBy
3+
*GeneralModuleTests.testHostnameRes
4+
*GeneralModuleTests.testInterpreterCrash
5+
*GeneralModuleTests.testNewAttributes
6+
*GeneralModuleTests.testSendAfterClose
7+
*GeneralModuleTests.testSetSockOpt
8+
*GeneralModuleTests.testSockName
9+
*GeneralModuleTests.test_SocketType_is_socketobject
10+
*GeneralModuleTests.test_getnameinfo
11+
*GeneralModuleTests.test_host_resolution
12+
*GeneralModuleTests.test_host_resolution_bad_address
13+
*GeneralModuleTests.test_listen_backlog
14+
*GeneralModuleTests.test_makefile_invalid_mode
15+
*GeneralModuleTests.test_makefile_mode
16+
*GeneralModuleTests.test_repr
17+
*GeneralModuleTests.test_socket_consistent_sock_type
18+
*GeneralModuleTests.test_unusable_closed_socketio

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_socketserver.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
import com.oracle.graal.python.builtins.objects.set.FrozenSetBuiltins;
151151
import com.oracle.graal.python.builtins.objects.set.SetBuiltins;
152152
import com.oracle.graal.python.builtins.objects.slice.SliceBuiltins;
153+
import com.oracle.graal.python.builtins.objects.socket.SocketBuiltins;
153154
import com.oracle.graal.python.builtins.objects.str.StringBuiltins;
154155
import com.oracle.graal.python.builtins.objects.superobject.SuperBuiltins;
155156
import com.oracle.graal.python.builtins.objects.thread.LockBuiltins;
@@ -327,6 +328,7 @@ private static final PythonBuiltins[] initializeBuiltins() {
327328
new AstModuleBuiltins(),
328329
new SelectModuleBuiltins(),
329330
new SocketModuleBuiltins(),
331+
new SocketBuiltins(),
330332
new SignalModuleBuiltins(),
331333
new TracebackBuiltins(),
332334
new GcModuleBuiltins(),

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
import com.oracle.graal.python.builtins.objects.ints.PInt;
114114
import com.oracle.graal.python.builtins.objects.list.PList;
115115
import com.oracle.graal.python.builtins.objects.module.PythonModule;
116+
import com.oracle.graal.python.builtins.objects.socket.PSocket;
116117
import com.oracle.graal.python.builtins.objects.str.PString;
117118
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
118119
import com.oracle.graal.python.builtins.objects.type.LazyPythonClass;
@@ -509,11 +510,10 @@ Object setInheritableStd(@SuppressWarnings("unused") int fd, @SuppressWarnings("
509510
}
510511

511512
@Specialization(guards = "fd > 2")
512-
Object setInheritable(int fd, @SuppressWarnings("unused") Object inheritable) {
513-
String path = getResources().getFilePath(fd);
514-
TruffleFile f = getContext().getEnv().getPublicTruffleFile(path);
515-
if (!f.exists()) {
516-
throw raise(OSError, "No such file or directory: '%s'", path);
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());
517517
}
518518
// TODO: investigate how to map this to the truffle file api (if supported)
519519
return PNone.NONE;

0 commit comments

Comments
 (0)