|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * The Universal Permissive License (UPL), Version 1.0
|
|
48 | 48 | import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ToByteArrayNode;
|
49 | 49 | import com.oracle.graal.python.builtins.objects.memoryview.PMemoryView;
|
50 | 50 | import com.oracle.graal.python.builtins.objects.str.PString;
|
| 51 | +import com.oracle.graal.python.nodes.PGuards; |
51 | 52 | import com.oracle.graal.python.nodes.PRaiseNode;
|
52 | 53 | import com.oracle.graal.python.nodes.SpecialMethodNames;
|
53 | 54 | import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
|
|
63 | 64 | /**
|
64 | 65 | * Converts a Python object to a Path string
|
65 | 66 | */
|
66 |
| -@ImportStatic(SpecialMethodNames.class) |
| 67 | +@ImportStatic({SpecialMethodNames.class, PGuards.class}) |
67 | 68 | public abstract class CastToPathNode extends Node {
|
68 | 69 | private static final String ERROR_MESSAGE = "path should be string, bytes or os.PathLike, not %p";
|
69 | 70 |
|
@@ -108,7 +109,7 @@ String doPString(PString x) {
|
108 | 109 | return x.getValue();
|
109 | 110 | }
|
110 | 111 |
|
111 |
| - @Specialization |
| 112 | + @Specialization(guards = {"!isString(object)", "!isBytes(object)", "!isMemoryView(object)"}) |
112 | 113 | String doObject(VirtualFrame frame, Object object,
|
113 | 114 | @Cached("createClassProfile()") ValueProfile resultTypeProfile,
|
114 | 115 | @Cached PRaiseNode raise,
|
|
0 commit comments