Message735

Author leouserz
Recipients
Date 2006-12-21.16:51:18
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Id even say __doc__foo should accept any Java Object.  It appers that there is also a bug in the code where it does all these checks to determine if it should set the doc and then goes ahead and tries to set it anyway.  The result is if its not a PyString it causes a ClassCastException.  The patch removes that and makes any Object(even null) acceptable.

Test class:
public class TestDoc{


    public static String __doc__doIt ="HI";
    public void doIt(){}


    public void doIt2(){}

}

PATCH:
--- /org/python/core/PyJavaClass.java	Tue Dec  5 23:58:32 2006
+++ org/python/core/PyJavaClass.java	Thu Dec 21 10:47:28 2006
@@ -367,10 +367,10 @@
             try {

                 Field docField = proxyClass.getField("__doc__" + name);

                 int mods = docField.getModifiers();

-                if (docField.getType() == PyString.class &&

-                       Modifier.isPublic(mods) &&

-                       Modifier.isStatic(mods));

-                    func.__doc__ = (PyString) docField.get(null);

+                if (Modifier.isPublic(mods) && Modifier.isStatic(mods)) {
+		    String __doc__ = String.valueOf(docField.get(null));
+		    func.__doc__ = new PyString(__doc__);
+                }
             } catch (NoSuchFieldException ex) {

             } catch (SecurityException ex) {

             } catch (IllegalAccessException ex) {}

History
Date User Action Args
2008-02-20 17:17:09adminlinkissue608632 messages
2008-02-20 17:17:09admincreate