@@ -231,15 +231,15 @@ protected boolean isMimeType(String lang) {
231
231
}
232
232
}
233
233
234
- @ Builtin (name = "export_value" , minNumOfPositionalArgs = 1 , parameterNames = {"value " , "name " })
234
+ @ Builtin (name = "export_value" , minNumOfPositionalArgs = 1 , parameterNames = {"name " , "value " })
235
235
@ GenerateNodeFactory
236
236
public abstract static class ExportSymbolNode extends PythonBuiltinNode {
237
237
@ Child private GetAttributeNode getNameAttributeNode ;
238
238
@ Child private CastToStringNode castToStringNode ;
239
239
240
- @ Specialization
240
+ @ Specialization ( guards = "!isString(value)" )
241
241
@ TruffleBoundary
242
- public Object exportSymbol ( Object value , String name ) {
242
+ public Object exportSymbolKeyValue ( String name , Object value ) {
243
243
Env env = getContext ().getEnv ();
244
244
if (!env .isPolyglotAccessAllowed ()) {
245
245
throw raise (PythonErrorType .NotImplementedError , "polyglot access is not allowed" );
@@ -248,6 +248,23 @@ public Object exportSymbol(Object value, String name) {
248
248
return value ;
249
249
}
250
250
251
+ @ Specialization (guards = "!isString(value)" )
252
+ @ TruffleBoundary
253
+ public Object exportSymbolValueKey (Object value , String name ) {
254
+ PythonLanguage .getLogger ().warning ("[deprecation] polyglot.export_value(value, name) is deprecated " +
255
+ "and will be removed. Please swap the arguments." );
256
+ return exportSymbolKeyValue (name , value );
257
+ }
258
+
259
+ @ Specialization (guards = "isString(arg1)" )
260
+ @ TruffleBoundary
261
+ public Object exportSymbolAmbiguous (Object arg1 , String arg2 ) {
262
+ PythonLanguage .getLogger ().warning ("[deprecation] polyglot.export_value(str, str) is ambiguous. In the future, this will " +
263
+ "default to using the first argument as the name and the second as value, but now it " +
264
+ "uses the first argument as value and the second as the name." );
265
+ return exportSymbolValueKey (arg1 , arg2 );
266
+ }
267
+
251
268
@ Specialization
252
269
@ TruffleBoundary
253
270
public Object exportSymbol (PFunction fun , @ SuppressWarnings ("unused" ) PNone name ) {
0 commit comments