Issue1745

classification
Title: interp.get(arr, Object) returns padded array if called arr.append(x)
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.5
Milestone:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, judahgreenblatt, zyasoft
Priority: normal Keywords:

Created on 2011-05-02.18:12:27 by judahgreenblatt, last changed 2016-01-13.22:56:58 by zyasoft.

Messages
msg6519 (view) Author: Judah Greenblatt (judahgreenblatt) Date: 2011-05-02.18:12:27
Error happens when calling PythonInterpreter from Java.
Example Java code:

    interp = new PythonInterpreter();
    interp.put("arr", new double[3]);
    interp.exec("arr.append(3.0)\n\n");
    o = interp.get(arr, Object.class);

o ends up as double[7] with 3.0 in position 3.
Should be double[4].

Error is in PyArray.__toJava__(Class)
where it returns 'data' instead of calling this.getArray() which calls delegate.copyArray().
msg10597 (view) Author: Jim Baker (zyasoft) Date: 2016-01-06.22:24:11
I added a test (https://hg.python.org/jython/rev/837c14575b65) based on what Judah submitted here:

    public void testCompactArray() {
	// tests http://bugs.jython.org/issue1745
	PythonInterpreter interp = new PythonInterpreter();
	interp.put("arr", new double[3]);
	interp.exec("arr.append(3.0)\n\n");
	o = interp.get(arr, Object.class);
    }

and determined this problem must have been fixed a while ago - it was not changed by the recent work in https://hg.python.org/jython/rev/49d498968f34
History
Date User Action Args
2016-01-13 22:56:58zyasoftsetstatus: pending -> closed
2016-01-06 22:24:12zyasoftsetstatus: open -> pending
resolution: out of date
messages: + msg10597
nosy: + zyasoft
2013-02-25 18:32:37fwierzbickisetpriority: normal
nosy: + fwierzbicki
versions: + Jython 2.5, - 2.5.1
2011-05-02 18:12:27judahgreenblattcreate