Title: __doc__foo should accept java String
Type: behaviour Severity: normal
Components: Core Versions:
Milestone: Jython 2.7.1
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: stefan.richthofer Nosy List: cgroves, fwierzbicki, leouserz, pedronis, stefan.richthofer, zyasoft
Priority: low Keywords: patch

Created on 2002-09-12.21:54:44 by pedronis, last changed 2017-02-27.04:47:08 by zyasoft.

msg734 (view) Author: Samuele Pedroni (pedronis) Date: 2002-09-12.21:54:44
msg735 (view) Author: Deleted User leouserz (leouserz) Date: 2006-12-21.16:51:18
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(){}


--- /org/python/core/	Tue Dec  5 23:58:32 2006
+++ org/python/core/	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) {}

msg736 (view) Author: Charlie Groves (cgroves) Date: 2006-12-24.02:47:55
Please attach patches as files instead of pasting them into comments.
msg9385 (view) Author: Jim Baker (zyasoft) Date: 2015-01-14.03:17:52
Looks useful, we should support this functionality.

I cannot find the original email - the link to activestate cited has long ago disappeared.
msg10867 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2016-06-18.21:43:45
There is a recent PR regarding this issue:

(just linking it back here to help keeping track)
msg11017 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-01-12.15:31:17
As of anything that implements java.lang.CharSequence is accepted as __doc__foo (As of PyBaseString and thus also PyString and PyUnicode implement CharSequence as well.).

The commit is based on
Date User Action Args
2017-02-27 04:47:08zyasoftsetstatus: pending -> closed
2017-01-12 15:31:17stefan.richthofersetstatus: open -> pending
resolution: fixed
messages: + msg11017
assignee: stefan.richthofer
milestone: Jython 2.7.1
type: behaviour
2016-06-18 21:43:46stefan.richthofersetnosy: + stefan.richthofer
messages: + msg10867
2015-01-14 03:17:52zyasoftsetassignee: fwierzbicki -> (no value)
messages: + msg9385
nosy: + zyasoft
2013-02-26 18:43:52fwierzbickisetkeywords: + patch
2013-02-26 18:43:39fwierzbickisetassignee: fwierzbicki
2013-02-26 18:43:29fwierzbickisetnosy: + fwierzbicki
2008-12-14 18:31:29fwierzbickisetcomponents: + Core, - None
title: __doc__foo should accept java String -> __doc__foo should accept java String
2002-09-12 21:54:44pedroniscreate