[Jython-checkins] jython (merge 2.5 -> default): merge with 2.5

philip.jenvey jython-checkins at python.org
Thu Nov 24 02:46:56 CET 2011


http://hg.python.org/jython/rev/8bc674cdfd2d
changeset:   6282:8bc674cdfd2d
parent:      6279:c280db0483aa
parent:      6281:4d0f8af76d2d
user:        Philip Jenvey <pjenvey at underboss.org>
date:        Wed Nov 23 17:44:41 2011 -0800
summary:
  merge with 2.5

files:
  Lib/test/test_java_integration.py    |  9 ++++++++-
  Lib/test/test_socket.py              |  2 +-
  Lib/test/test_urllib2_localnet.py    |  2 +-
  NEWS                                 |  1 +
  src/org/python/core/PyJavaType.java  |  3 ++-
  tests/java/javatests/ProxyTests.java |  4 ++++
  6 files changed, 17 insertions(+), 4 deletions(-)


diff --git a/Lib/test/test_java_integration.py b/Lib/test/test_java_integration.py
--- a/Lib/test/test_java_integration.py
+++ b/Lib/test/test_java_integration.py
@@ -25,7 +25,7 @@
 from org.python.tests import (BeanImplementation, Child, Child2,
                               CustomizableMapHolder, Listenable, ToUnicode)
 from org.python.tests.mro import (ConfusedOnGetitemAdd, FirstPredefinedGetitem, GetitemAdder)
-from javatests.ProxyTests import Person
+from javatests.ProxyTests import NullToString, Person
 
 
 class InstantiationTest(unittest.TestCase):
@@ -473,6 +473,13 @@
         self.assertRaises(TypeError, __import__, "org.python.tests.mro.ConfusedOnImport")
         self.assertRaises(TypeError, GetitemAdder.addPostdefined)
 
+    def test_null_tostring(self):
+        # http://bugs.jython.org/issue1819
+        nts = NullToString()
+        self.assertEqual(repr(nts), '')
+        self.assertEqual(str(nts), '')
+        self.assertEqual(unicode(nts), '')
+
 
 def roundtrip_serialization(obj):
     """Returns a deep copy of an object, via serializing it
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -20,7 +20,7 @@
 from weakref import proxy
 from StringIO import StringIO
 
-PORT = 50007
+PORT = 50100
 HOST = 'localhost'
 MSG = 'Michael Gilfix was here\n'
 EIGHT_BIT_MSG = 'Bh\xed Al\xe1in \xd3 Cinn\xe9ide anseo\n'
diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py
--- a/Lib/test/test_urllib2_localnet.py
+++ b/Lib/test/test_urllib2_localnet.py
@@ -226,7 +226,7 @@
 class ProxyAuthTests(unittest.TestCase):
     URL = "http://www.foo.com"
 
-    PORT = 8080
+    PORT = 58080
     USER = "tester"
     PASSWD = "test123"
     REALM = "TestRealm"
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@
     - [ 1804 ] _tcpsocket doesn't have 'type' and 'proto' attributes
     - [ 1809 ] socket.getaddrinfo sometimes returns an object that crashes in __str__
     - [ 1811 ] Recursive import bug w/ SQLAlchemy 0.7.3
+    - [ 1819 ] Incorrect handling of Java object toString methods returning null
 
 Jython 2.5.2
   same as 2.5.2rc4
diff --git a/src/org/python/core/PyJavaType.java b/src/org/python/core/PyJavaType.java
--- a/src/org/python/core/PyJavaType.java
+++ b/src/org/python/core/PyJavaType.java
@@ -593,7 +593,8 @@
             addMethod(new PyBuiltinMethodNarrow("__repr__") {
                 @Override
                 public PyObject __call__() {
-                    return Py.newString(self.getJavaProxy().toString());
+                    String toString = self.getJavaProxy().toString();
+                    return toString == null ? Py.EmptyString : Py.newString(toString);
                 }
             });
             addMethod(new PyBuiltinMethodNarrow("__unicode__") {
diff --git a/tests/java/javatests/ProxyTests.java b/tests/java/javatests/ProxyTests.java
--- a/tests/java/javatests/ProxyTests.java
+++ b/tests/java/javatests/ProxyTests.java
@@ -35,4 +35,8 @@
         }
     }
 
+    public static class NullToString {
+        public String toString() { return null; }
+    }
+
 }

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list