From: <pj...@us...> - 2011-04-23 00:18:02
|
Revision: 7287 http://jython.svn.sourceforge.net/jython/?rev=7287&view=rev Author: pjenvey Date: 2011-04-23 00:17:56 +0000 (Sat, 23 Apr 2011) Log Message: ----------- fix os.read returning unicode instead of str fixes #1735 Modified Paths: -------------- trunk/jython/Lib/test/test_fileno.py trunk/jython/NEWS trunk/jython/src/org/python/modules/posix/PosixModule.java Modified: trunk/jython/Lib/test/test_fileno.py =================================================================== --- trunk/jython/Lib/test/test_fileno.py 2011-04-03 00:59:11 UTC (rev 7286) +++ trunk/jython/Lib/test/test_fileno.py 2011-04-23 00:17:56 UTC (rev 7287) @@ -46,7 +46,9 @@ self.fp.write('jython filenos') self.fp.flush() self.fp.seek(0) - self.assertEqual(os.read(self.fd, 7), 'jython ') + result = os.read(self.fd, 7) + self.assertTrue(isinstance(result, str)) + self.assertEqual(result, 'jython ') self.assertEqual(os.read(self.fd, 99), 'filenos') self.fp.close() raises(OSError, 9, os.read, self.fd, 1) Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2011-04-03 00:59:11 UTC (rev 7286) +++ trunk/jython/NEWS 2011-04-23 00:17:56 UTC (rev 7287) @@ -3,6 +3,7 @@ Jython 2.6a1 Bugs Fixed - [ 1727 ] Error in Jython 2.5.2 with os.stat and varargs + - [ 1735 ] return type of os.read is unicode, not str Jython 2.5.2 same as 2.5.2rc4 Modified: trunk/jython/src/org/python/modules/posix/PosixModule.java =================================================================== --- trunk/jython/src/org/python/modules/posix/PosixModule.java 2011-04-03 00:59:11 UTC (rev 7286) +++ trunk/jython/src/org/python/modules/posix/PosixModule.java 2011-04-23 00:17:56 UTC (rev 7287) @@ -609,9 +609,9 @@ public static PyString __doc__read = new PyString( "read(fd, buffersize) -> string\n\n" + "Read a file descriptor."); - public static String read(PyObject fd, int buffersize) { + public static PyObject read(PyObject fd, int buffersize) { try { - return StringUtil.fromBytes(FileDescriptors.get(fd).read(buffersize)); + return new PyString(StringUtil.fromBytes(FileDescriptors.get(fd).read(buffersize))); } catch (PyException pye) { throw badFD(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |