Skip to content

Commit b57d855

Browse files
author
Franziska Geiger
committed
[GR-17272][GR-17273]Added constant to _socket.py and implemented missing Specialization in UnicodeEscapeDecode node
PullRequest: graalpython/591
2 parents 6675034 + 200081c commit b57d855

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import com.oracle.truffle.api.CompilerDirectives;
7474
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
7575
import com.oracle.truffle.api.dsl.Cached;
76+
import com.oracle.truffle.api.dsl.Cached.Shared;
7677
import com.oracle.truffle.api.dsl.Fallback;
7778
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
7879
import com.oracle.truffle.api.dsl.ImportStatic;
@@ -341,7 +342,13 @@ Object encode(Object str, @SuppressWarnings("unused") Object errors) {
341342
abstract static class UnicodeEscapeDecode extends PythonBinaryBuiltinNode {
342343
@Specialization(guards = "isBytes(bytes)")
343344
Object encode(VirtualFrame frame, Object bytes, @SuppressWarnings("unused") PNone errors,
344-
@Cached("create()") BytesNodes.ToBytesNode toBytes) {
345+
@Shared("toBytes") @Cached("create()") BytesNodes.ToBytesNode toBytes) {
346+
return encode(frame, bytes, "", toBytes);
347+
}
348+
349+
@Specialization(guards = "isBytes(bytes)")
350+
Object encode(VirtualFrame frame, Object bytes, @SuppressWarnings("unused") String errors,
351+
@Shared("toBytes") @Cached("create()") BytesNodes.ToBytesNode toBytes) {
345352
// for now we'll just parse this as a String, ignoring any error strategies
346353
PythonCore core = getCore();
347354
byte[] byteArray = toBytes.execute(frame, bytes);

graalpython/lib-graalpython/_socket.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
AF_INET = 2
4242
AF_INET6 = 23
4343

44+
AI_PASSIVE = 1
45+
4446
SOCK_DGRAM = 1
4547
SOCK_STREAM = 2
4648
SOCK_RAW = 3

0 commit comments

Comments
 (0)