Issue1735

classification
Title: return type of os.read is unicode, not str
Type: behaviour Severity: normal
Components: Library Versions: 2.5.2rc
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pjenvey Nosy List: dstromberg, pjenvey
Priority: Keywords:

Created on 2011-04-19.02:08:27 by dstromberg, last changed 2011-04-23.03:32:30 by dstromberg.

Files
File name Uploaded Description Edit Remove
unnamed dstromberg, 2011-04-23.00:43:16
unnamed dstromberg, 2011-04-23.03:23:58
unnamed dstromberg, 2011-04-23.03:32:30
Messages
msg6499 (view) Author: Dan Stromberg (dstromberg) Date: 2011-04-19.02:08:27
In Jython 2.5.2 (I didn't see 2.5.2 in the version list) os.read() returns an object of type unicode, but should return an object of type str in Python 2.x's.

This is inconsistent with CPython 2.x and PyPy 1.4.1, both of which return str.

Because CPython 3.x's os.read() returns bytes (which are similar to 2.x str's), use of os.read() is perhaps becoming important for systems programming, where os.read() gives nice binary blobs in both 2.x and 3.x, without imposing any encoding assumptions on the data being read.
msg6506 (view) Author: Philip Jenvey (pjenvey) Date: 2011-04-23.00:27:40
fixed in r7287, r7288
msg6507 (view) Author: Dan Stromberg (dstromberg) Date: 2011-04-23.00:43:17
This is great.  How soon might I hope for a 2.5.3 that would include it?

Or should I just figure out how to build a trunk?

On Fri, Apr 22, 2011 at 5:27 PM, Philip Jenvey <report@bugs.jython.org>wrote:

>
> Philip Jenvey <pjenvey@underboss.org> added the comment:
>
> fixed in r7287, r7288
>
> ----------
> resolution:  -> fixed
> status: open -> closed
>
> _______________________________________
> Jython tracker <report@bugs.jython.org>
> <http://bugs.jython.org/issue1735>
> _______________________________________
>
msg6508 (view) Author: Philip Jenvey (pjenvey) Date: 2011-04-23.00:45:27
2.5.2 was released fairly recently, and now we're focused on 2.6 work, so I don't expect a 2.5.3 any time soon.

I did apply this change to the 2.5 branch however, if you want to build your own release from there.
msg6509 (view) Author: Dan Stromberg (dstromberg) Date: 2011-04-23.03:23:58
Something seems not-quite-right:

$ /usr/local/jython-2.5.2-r7288/bin/jython
cmd started 2011 Fri Apr 22 08:20:53 PM
*sys-package-mgr*: can't create package cache dir,
'/usr/local/jython-2.5.2-r7288/cachedir/packages'
Jython 2.5.2 (Release_2_5maint:7288, Apr 22 2011, 19:40:21)
[OpenJDK Server VM (Sun Microsystems Inc.)] on java1.6.0_20
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> filedes = os.open('/etc/protocols', os.O_RDONLY)
>>> data = filedes.read(100)
>>> data
java.nio.HeapByteBuffer[pos=0 lim=100 cap=100]
>>> type(data)
<type 'java.nio.HeapByteBuffer'>
>>> data[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'java.nio.HeapByteBuffer' object is unsubscriptable
>>> os.close(filedes)
>>>

data should be a str with around 100 characters in it, or at least something
that quacks like a str.

Thoughts?

On Fri, Apr 22, 2011 at 5:45 PM, Philip Jenvey <report@bugs.jython.org>wrote:

>
> Philip Jenvey <pjenvey@underboss.org> added the comment:
>
> 2.5.2 was released fairly recently, and now we're focused on 2.6 work, so I
> don't expect a 2.5.3 any time soon.
>
> I did apply this change to the 2.5 branch however, if you want to build
> your own release from there.
>
> _______________________________________
> Jython tracker <report@bugs.jython.org>
> <http://bugs.jython.org/issue1735>
> _______________________________________
>
msg6510 (view) Author: Philip Jenvey (pjenvey) Date: 2011-04-23.03:31:01
You've mistakenly called <fileno>.read(100) instead of os.read(fileno, 100)

Our file descriptors are weird =]
msg6511 (view) Author: Dan Stromberg (dstromberg) Date: 2011-04-23.03:32:30
Doh.  Thanks.

$ /usr/local/jython-2.5.2-r7288/bin/jython
cmd started 2011 Fri Apr 22 08:31:34 PM
*sys-package-mgr*: can't create package cache dir,
'/usr/local/jython-2.5.2-r7288/cachedir/packages'
Jython 2.5.2 (Release_2_5maint:7288, Apr 22 2011, 19:40:21)
[OpenJDK Server VM (Sun Microsystems Inc.)] on java1.6.0_20
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> filedes = os.open('/etc/protocols', os.O_RDONLY)
>>> data = os.read(filedes, 100)
>>> data
'# Internet (IP) protocols\n#\n# Updated from
http://www.iana.org/assignments/protocol-numbers and othe'
>>> filedes.close()
>>>

On Fri, Apr 22, 2011 at 8:31 PM, Philip Jenvey <report@bugs.jython.org>wrote:

>
> Philip Jenvey <pjenvey@underboss.org> added the comment:
>
> You've mistakenly called <fileno>.read(100) instead of os.read(fileno, 100)
>
> Our file descriptors are weird =]
>
> _______________________________________
> Jython tracker <report@bugs.jython.org>
> <http://bugs.jython.org/issue1735>
> _______________________________________
>
History
Date User Action Args
2011-04-23 03:32:30dstrombergsetfiles: + unnamed
messages: + msg6511
2011-04-23 03:31:01pjenveysetmessages: + msg6510
2011-04-23 03:23:58dstrombergsetfiles: + unnamed
messages: + msg6509
2011-04-23 00:45:27pjenveysetmessages: + msg6508
2011-04-23 00:43:17dstrombergsetfiles: + unnamed
messages: + msg6507
2011-04-23 00:27:40pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg6506
2011-04-22 18:49:51pjenveysetassignee: pjenvey
nosy: + pjenvey
2011-04-19 02:08:27dstrombergcreate