[Jython-checkins] jython (merge default -> default): Merge.
frank.wierzbicki
jython-checkins at python.org
Mon Feb 6 18:41:42 CET 2012
http://hg.python.org/jython/rev/2f2b7b889246
changeset: 6302:2f2b7b889246
parent: 6301:332b2490f53e
parent: 6300:86ebf89770e5
user: Frank Wierzbicki <fwierzbicki at gmail.com>
date: Mon Feb 06 09:39:57 2012 -0800
summary:
Merge.
files:
Lib/test/test_java_integration.py | 22 ++++++++++++-
NEWS | 1 +
src/org/python/core/PyBeanProperty.java | 2 +-
tests/java/javatests/Issue1833.java | 10 +++++
4 files changed, 33 insertions(+), 2 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,6 +25,7 @@
from org.python.tests import (BeanImplementation, Child, Child2,
CustomizableMapHolder, Listenable, ToUnicode)
from org.python.tests.mro import (ConfusedOnGetitemAdd, FirstPredefinedGetitem, GetitemAdder)
+from javatests import Issue1833
from javatests.ProxyTests import NullToString, Person
@@ -592,6 +593,24 @@
self.assertEqual(type(test), unicode)
self.assertEqual(test, u"Circle is 360\u00B0")
+
+class BeanPropertyTest(unittest.TestCase):
+
+ def test_issue1833(self):
+ class TargetClass(object):
+ def _getattribute(self):
+ return self.__attribute
+ def _setattribute(self, value):
+ self.__attribute = value
+ attribute = property(_getattribute, _setattribute)
+
+ target = TargetClass()
+ test = Issue1833(target=target)
+ value = ('bleh', 'blah')
+ test.value = value
+ self.assertEqual(target.attribute, value)
+
+
def test_main():
test_support.run_unittest(InstantiationTest,
BeanTest,
@@ -609,7 +628,8 @@
JavaWrapperCustomizationTest,
SerializationTest,
CopyTest,
- UnicodeTest)
+ UnicodeTest,
+ BeanPropertyTest)
if __name__ == "__main__":
test_main()
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@
- [ 1824 ] os.link() can silently fail
- [ 1825 ] EnvironmentError.filename is `str` even if original name is `unicode`
- [ 1828 ] Problems inheriting from long
+ - [ 1833 ] Trouble passing Python objects through a Java class back to Python
Jython 2.5.2
same as 2.5.2rc4
diff --git a/src/org/python/core/PyBeanProperty.java b/src/org/python/core/PyBeanProperty.java
--- a/src/org/python/core/PyBeanProperty.java
+++ b/src/org/python/core/PyBeanProperty.java
@@ -53,7 +53,7 @@
Object iself = Py.tojava(self, setMethod.getDeclaringClass());
// Special handling of tuples - try to call a class constructor
- if (value instanceof PyTuple) {
+ if (value instanceof PyTuple && myType != PyObject.class) {
try {
value = Py.java2py(myType).__call__(((PyTuple)value).getArray());
} catch (Throwable t) {
diff --git a/tests/java/javatests/Issue1833.java b/tests/java/javatests/Issue1833.java
new file mode 100644
--- /dev/null
+++ b/tests/java/javatests/Issue1833.java
@@ -0,0 +1,10 @@
+package javatests;
+import org.python.core.PyObject;
+
+public class Issue1833 {
+ public PyObject target;
+
+ public void setValue(PyObject value) {
+ target.__setattr__("attribute", value);
+ }
+}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list