Issue1276

classification
Title: Incomplete translation of Java inputstreams to Jython Io objects
Type: rfe Severity: urgent
Components: Versions: 2.5.1
Milestone:
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: JacobKessler, fwierzbicki, pjenvey, zyasoft
Priority: normal Keywords:

Created on 2009-03-18.17:07:42 by JacobKessler, last changed 2009-05-31.05:47:47 by pjenvey.

Messages
msg4310 (view) Author: Jacob Kessler (JacobKessler) Date: 2009-03-18.17:07:41
Attempting to call read([n]) on a Java InputStream that has been turned
into a PyObject will crash with "read(): 1st arg can't be coerced to
byte[]". The PyObject conversion should create a read(int) method on the
InputStream to create and return a length-n byte[].
msg4422 (view) Author: Jim Baker (zyasoft) Date: 2009-04-04.02:01:53
RFE for enhanced Java integration, so deferring until 2.5.1
msg4459 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-04-07.00:36:02
crap, wrong bug, re-opening.
msg4771 (view) Author: Philip Jenvey (pjenvey) Date: 2009-05-31.05:47:19
It sounds like you're just not using an InputStream correctly. There's 
only read(), read(byte[]) and read(byte[], int, int). You can create a 
byte[] with the array module to use the latter 2, e.g.:

Jython 2.5rc3+ (trunk:6432:6433M, May 30 2009, 22:11:31) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_07
Type "help", "copyright", "credits" or "license" for more information.
>>> fp = open('/tmp/foo', 'w+')
>>> fp.write('Hello World')
>>> fp.seek(0)
>>> from java.io import FileInputStream    
>>> import array
>>> fis = FileInputStream('/tmp/foo')
>>> chr(fis.read())
'H'
>>> buf = array.array('b', [0] * 10)
>>> fis.read(buf)
10
>>> buf
array('b', [101, 108, 108, 111, 32, 87, 111, 114, 108, 100])
>>> buf.tostring()
'ello World'
History
Date User Action Args
2009-05-31 05:47:48pjenveysetstatus: open -> closed
resolution: invalid
messages: + msg4771
nosy: + pjenvey
2009-04-07 00:36:18fwierzbickisetmessages: - msg4458
2009-04-07 00:36:03fwierzbickisetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg4459
2009-04-07 00:35:28fwierzbickisetstatus: open -> closed
resolution: fixed
messages: + msg4458
nosy: + fwierzbicki
2009-04-04 02:01:53zyasoftsetpriority: normal
nosy: + zyasoft
messages: + msg4422
versions: + 2.5.1
2009-03-18 17:07:42JacobKesslercreate