|
70 | 70 | import com.oracle.graal.python.builtins.objects.PythonAbstractObject;
|
71 | 71 | import com.oracle.graal.python.builtins.objects.bytes.BytesBuiltins;
|
72 | 72 | import com.oracle.graal.python.builtins.objects.bytes.BytesNodes;
|
| 73 | +import com.oracle.graal.python.builtins.objects.bytes.PByteArray; |
73 | 74 | import com.oracle.graal.python.builtins.objects.bytes.PBytes;
|
74 | 75 | import com.oracle.graal.python.builtins.objects.cext.CArrayWrappers.CByteArrayWrapper;
|
75 | 76 | import com.oracle.graal.python.builtins.objects.cext.CArrayWrappers.CStringWrapper;
|
@@ -2138,6 +2139,23 @@ protected static boolean isPSequence(Object object) {
|
2138 | 2139 | @Builtin(name = "PyBytes_FromStringAndSize", minNumOfPositionalArgs = 2, declaresExplicitSelf = true)
|
2139 | 2140 | @GenerateNodeFactory
|
2140 | 2141 | abstract static class PyBytes_FromStringAndSize extends NativeBuiltin {
|
| 2142 | + // n.b.: the specializations for PBytes/PByteArray are quite common on |
| 2143 | + // managed, when the PySequenceArrayWrapper that we used never went |
| 2144 | + // native, and during the upcall to here it was simply unwrapped again |
| 2145 | + // with the ToJava (rather than mapped from a native pointer back into a |
| 2146 | + // PythonNativeObject) |
| 2147 | + |
| 2148 | + @Specialization |
| 2149 | + Object doGeneric(Object module, PByteArray object, |
| 2150 | + @Exclusive @Cached BytesNodes.ToBytesNode getByteArrayNode) { |
| 2151 | + return factory().createBytes(getByteArrayNode.execute(object)); |
| 2152 | + } |
| 2153 | + |
| 2154 | + @Specialization |
| 2155 | + Object doGeneric(Object module, PBytes object, |
| 2156 | + @Exclusive @Cached BytesNodes.ToBytesNode getByteArrayNode) { |
| 2157 | + return factory().createBytes(getByteArrayNode.execute(object)); |
| 2158 | + } |
2141 | 2159 |
|
2142 | 2160 | @Specialization
|
2143 | 2161 | Object doGeneric(Object module, PythonNativeObject object,
|
|
0 commit comments