File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 43
43
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
44
44
import com .oracle .graal .python .nodes .object .GetClassNode ;
45
45
import com .oracle .graal .python .nodes .truffle .PythonArithmeticTypes ;
46
+ import com .oracle .graal .python .runtime .exception .PException ;
46
47
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
47
48
import com .oracle .truffle .api .dsl .Cached ;
48
49
import com .oracle .truffle .api .dsl .Fallback ;
@@ -102,14 +103,27 @@ String doBuiltinFunction(PBuiltinFunction self) {
102
103
103
104
@ Specialization
104
105
String doBuiltinMethod (PBuiltinMethod self ) {
105
- if (self .getSelf () == null || self .getSelf () == PNone .NONE || self .getSelf () instanceof PythonModule ) {
106
- return self .getName ();
106
+ return doMethod (self .getName (), self .getSelf ());
107
+ }
108
+
109
+ @ Specialization
110
+ String doBuiltinMethod (PMethod self ) {
111
+ return doMethod (self .getName (), self .getSelf ());
112
+ }
113
+
114
+ private String doMethod (String name , Object owner ) {
115
+ if (owner == null || owner == PNone .NONE || owner instanceof PythonModule ) {
116
+ return name ;
107
117
}
108
- return ( String ) doGeneric ( self );
118
+ throw raiseCannotPickle ( );
109
119
}
110
120
111
121
@ Fallback
112
122
Object doGeneric (@ SuppressWarnings ("unused" ) Object obj ) {
123
+ throw raiseCannotPickle ();
124
+ }
125
+
126
+ private PException raiseCannotPickle () {
113
127
throw raise (TypeError , "can't pickle function objects" );
114
128
}
115
129
}
You can’t perform that action at this time.
0 commit comments