SF.net SVN: jython:[7287] trunk/jython

[email protected] Sat, 23 Apr 2011 00:17:56 +0000
Newsgroups gmane.comp.lang.jython.cvs
Message-ID <[email protected]>
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.

------------------------------------------------------------------------------
Fulfilling the Lean Software Promise
Lean software platforms are now widely adopted and the benefits have been 
demonstrated beyond question. Learn why your peers are replacing JEE 
containers with lightweight application servers - and what you can gain 
from the move. http://p.sf.net/sfu/vmware-sfemails