From: <pj...@us...> - 2008-11-27 20:56:19
|
Revision: 5647 http://jython.svn.sourceforge.net/jython/?rev=5647&view=rev Author: pjenvey Date: 2008-11-27 20:56:10 +0000 (Thu, 27 Nov 2008) Log Message: ----------- o explicitly convert Strings returned from ExposedGet to str (instead of unicode), just as ExposedMethod does. restores the behavior it had before the big Java integration String/unicode change o add a TypeError message for PyDataDescr.__set__ failed conversions Modified Paths: -------------- trunk/jython/src/org/python/core/PyDataDescr.java trunk/jython/src/org/python/expose/generate/DescriptorExposer.java Modified: trunk/jython/src/org/python/core/PyDataDescr.java =================================================================== --- trunk/jython/src/org/python/core/PyDataDescr.java 2008-11-27 04:52:37 UTC (rev 5646) +++ trunk/jython/src/org/python/core/PyDataDescr.java 2008-11-27 20:56:10 UTC (rev 5647) @@ -75,9 +75,12 @@ @ExposedMethod public void getset_descriptor___set__(PyObject obj, PyObject value) { checkGetterType(obj.getType()); + // XXX: We may want to special case value being PyUnicode and ofType being String + // (then explicitly value.encode() first) Object converted = value.__tojava__(ofType); if(converted == Py.NoConversion) { - throw Py.TypeError(""); // xxx + throw Py.TypeError(String.format("unsupported type for assignment to %s: '%.200s'", + name, value.getType().fastGetName())); } invokeSet(obj, converted); } Modified: trunk/jython/src/org/python/expose/generate/DescriptorExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/DescriptorExposer.java 2008-11-27 04:52:37 UTC (rev 5646) +++ trunk/jython/src/org/python/expose/generate/DescriptorExposer.java 2008-11-27 20:56:10 UTC (rev 5647) @@ -139,7 +139,7 @@ mv.visitVarInsn(ALOAD, 1); mv.visitTypeInsn(CHECKCAST, onType.getInternalName()); call(onType, getterMethodName, ofType); - if(PRIMITIVES.containsKey(ofType)) { + if(PRIMITIVES.containsKey(ofType) || ofType.equals(STRING)) { toPy(ofType); } endMethod(ARETURN); @@ -153,7 +153,7 @@ onType.getInternalName(), getterFieldName, ofType.getDescriptor()); - if(PRIMITIVES.containsKey(ofType)) { + if(PRIMITIVES.containsKey(ofType) || ofType.equals(STRING)) { toPy(ofType); } endMethod(ARETURN); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |