Message10286

Author zyasoft
Recipients holmis83, zyasoft
Date 2015-09-24.00:13:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1443053599.02.0.239099591671.issue2402@psf.upfronthosting.co.za>
In-reply-to
Content
FWIW, Jython does not actually convert the string, instead it returns the unboxed string held by PyString (or PyUnicode). See PyString#getString.

Regardless, the requested change as-is would be a backwards breaking change in user APIs, something we don't want to do in 2.7.x, at least without very good justifications. (Examples of justifications to break APIs in this cycle would be preventing resource leaks, etc. These do not apply here.)

Unfortunately, from what I can tell, there is no way to get the underlying PyObject using the JSR 223 APIs that we support. Instead all outbound objects are converted via __tojava__(Object.class); in the case of PyString, we see the following test immediately at the top of its __tojava__ method:

        if (c.isAssignableFrom(String.class)) {
            return getString();
        }

which for Object is always true.

Otherwise, we could provide you the desired object by simply calling pyobj.__tojava__(byte[].class), which is handled by the PyString#__tojava__ method implementation.

Perhaps we can offer an extended version of the JSR 223 API to do so? It will have to be considered carefully. Presumably we would start with http://docs.oracle.com/javase/7/docs/api/javax/script/Bindings.html and maybe overload get to take the conversion type.
History
Date User Action Args
2015-09-24 00:13:19zyasoftsetmessageid: <1443053599.02.0.239099591671.issue2402@psf.upfronthosting.co.za>
2015-09-24 00:13:19zyasoftsetrecipients: + zyasoft, holmis83
2015-09-24 00:13:18zyasoftlinkissue2402 messages
2015-09-24 00:13:17zyasoftcreate