`PySet` object recognized as `str` object

Frank Dai <[email protected]>
Newsgroups gmane.comp.lang.jython.user
Message-ID <CAPJGSt9egw=+LvE0ita3a-DBK6qJA-sSKZrrmQ+OxN4rt+XYiw@mail.gmail.com>
The following is my java code:

public void testPySet() {
    final PythonInterpreter interpreter = new PythonInterpreter();
    final String userCode = "def
test(x):\n\tprint(x)\n\tx.add(\"d\")\n\treturn x";
    interpreter.exec(userCode);
    final PyObject method = interpreter.get("test");
    final PySet set = new PySet(PyString.TYPE);
    set.add("a");
    set.add("b");
    set.add("c");
    final PyObject result = method.__call__(set);
    System.out.println(result);
}

When I run it, it will throw out an error message:

Traceback (most recent call last):
  File "<string>", line 3, in test
AttributeError: 'str' object has no attribute 'add'

If I remove the x.add(\"d\"), then it will run successfully.

It’s very weird that the PySet object is recognized as an str object.

Does anyone happen to know why?

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Jython-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.