@@ -231,15 +231,15 @@ protected boolean isMimeType(String lang) {
231231 }
232232 }
233233
234- @ Builtin (name = "export_value" , minNumOfPositionalArgs = 1 , parameterNames = {"value " , "name " })
234+ @ Builtin (name = "export_value" , minNumOfPositionalArgs = 1 , parameterNames = {"name " , "value " })
235235 @ GenerateNodeFactory
236236 public abstract static class ExportSymbolNode extends PythonBuiltinNode {
237237 @ Child private GetAttributeNode getNameAttributeNode ;
238238 @ Child private CastToStringNode castToStringNode ;
239239
240- @ Specialization
240+ @ Specialization ( guards = "!isString(value)" )
241241 @ TruffleBoundary
242- public Object exportSymbol ( Object value , String name ) {
242+ public Object exportSymbolKeyValue ( String name , Object value ) {
243243 Env env = getContext ().getEnv ();
244244 if (!env .isPolyglotAccessAllowed ()) {
245245 throw raise (PythonErrorType .NotImplementedError , "polyglot access is not allowed" );
@@ -248,6 +248,23 @@ public Object exportSymbol(Object value, String name) {
248248 return value ;
249249 }
250250
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+
251268 @ Specialization
252269 @ TruffleBoundary
253270 public Object exportSymbol (PFunction fun , @ SuppressWarnings ("unused" ) PNone name ) {
0 commit comments