|
80 | 80 | import com.oracle.graal.python.lib.PyLongAsLongAndOverflowNode; |
81 | 81 | import com.oracle.graal.python.lib.PyLongAsLongNode; |
82 | 82 | import com.oracle.graal.python.lib.PyNumberIndexNode; |
| 83 | +import com.oracle.graal.python.lib.PyOSFSPathNode; |
83 | 84 | import com.oracle.graal.python.lib.PyObjectAsFileDescriptor; |
84 | 85 | import com.oracle.graal.python.lib.PyObjectSizeNode; |
85 | 86 | import com.oracle.graal.python.nodes.ErrorMessages; |
@@ -2130,27 +2131,10 @@ PNone kill(VirtualFrame frame, long pid, int signal, |
2130 | 2131 | @GenerateNodeFactory |
2131 | 2132 | // Can be used as an equivalent of PyOS_FSPath() |
2132 | 2133 | public abstract static class FspathNode extends PythonUnaryBuiltinNode { |
2133 | | - |
2134 | | - @Specialization(guards = "isPath(value)") |
2135 | | - static Object doTrivial(Object value) { |
2136 | | - return value; |
2137 | | - } |
2138 | | - |
2139 | | - @Specialization(guards = "!isPath(value)") |
2140 | | - Object callFspath(VirtualFrame frame, Object value, |
2141 | | - @Cached("create(T___FSPATH__)") LookupAndCallUnaryNode callFSPath) { |
2142 | | - Object pathObject = callFSPath.executeObject(frame, value); |
2143 | | - if (isPath(pathObject)) { |
2144 | | - return pathObject; |
2145 | | - } else if (pathObject == PNone.NO_VALUE) { |
2146 | | - throw raise(TypeError, ErrorMessages.EXPECTED_STR_BYTE_OSPATHLIKE_OBJ, value); |
2147 | | - } else { |
2148 | | - throw raise(TypeError, ErrorMessages.EXPECTED_FSPATH_TO_RETURN_STR_OR_BYTES, value, pathObject); |
2149 | | - } |
2150 | | - } |
2151 | | - |
2152 | | - protected static boolean isPath(Object obj) { |
2153 | | - return PGuards.isString(obj) || obj instanceof PBytes; |
| 2134 | + @Specialization |
| 2135 | + static Object doTrivial(VirtualFrame frame, Object value, |
| 2136 | + @Cached PyOSFSPathNode fsPathNode) { |
| 2137 | + return fsPathNode.execute(frame, value); |
2154 | 2138 | } |
2155 | 2139 | } |
2156 | 2140 |
|
@@ -2243,14 +2227,14 @@ abstract static class ObjectToOpaquePathNode extends PNodeWithRaise { |
2243 | 2227 |
|
2244 | 2228 | @Specialization(guards = "!checkEmpty") |
2245 | 2229 | static Object noCheck(VirtualFrame frame, Object obj, @SuppressWarnings("unused") boolean checkEmpty, |
2246 | | - @Cached FspathNode fspathNode, |
| 2230 | + @Cached PyOSFSPathNode fspathNode, |
2247 | 2231 | @Cached StringOrBytesToOpaquePathNode stringOrBytesToOpaquePathNode) { |
2248 | 2232 | return stringOrBytesToOpaquePathNode.execute(fspathNode.execute(frame, obj)); |
2249 | 2233 | } |
2250 | 2234 |
|
2251 | 2235 | @Specialization(guards = "checkEmpty") |
2252 | 2236 | Object withCheck(VirtualFrame frame, Object obj, @SuppressWarnings("unused") boolean checkEmpty, |
2253 | | - @Cached FspathNode fspathNode, |
| 2237 | + @Cached PyOSFSPathNode fspathNode, |
2254 | 2238 | @Cached PyObjectSizeNode sizeNode, |
2255 | 2239 | @Cached StringOrBytesToOpaquePathNode stringOrBytesToOpaquePathNode) { |
2256 | 2240 | Object stringOrBytes = fspathNode.execute(frame, obj); |
@@ -2415,7 +2399,7 @@ public static PBytes opaquePathToBytes(Object opaquePath, PosixSupportLibrary po |
2415 | 2399 | public abstract static class FsConverterNode extends ArgumentCastNodeWithRaise { |
2416 | 2400 | @Specialization |
2417 | 2401 | static PBytes convert(VirtualFrame frame, Object value, |
2418 | | - @Cached FspathNode fspathNode, |
| 2402 | + @Cached PyOSFSPathNode fspathNode, |
2419 | 2403 | @Cached StringOrBytesToBytesNode stringOrBytesToBytesNode) { |
2420 | 2404 | return stringOrBytesToBytesNode.execute(fspathNode.execute(frame, value)); |
2421 | 2405 | } |
|
0 commit comments