You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <pj...@us...> - 2008-12-24 02:22:17
|
Revision: 5796 http://jython.svn.sourceforge.net/jython/?rev=5796&view=rev Author: pjenvey Date: 2008-12-24 01:47:07 +0000 (Wed, 24 Dec 2008) Log Message: ----------- correct issue # reference, small cleanup Modified Paths: -------------- trunk/jython/Lib/os.py trunk/jython/Lib/test/test_builtin_jy.py Modified: trunk/jython/Lib/os.py =================================================================== --- trunk/jython/Lib/os.py 2008-12-23 19:56:53 UTC (rev 5795) +++ trunk/jython/Lib/os.py 2008-12-24 01:47:07 UTC (rev 5796) @@ -564,7 +564,7 @@ floor = long(seconds) except TypeError: raise TypeError('an integer is required') - if floor < _time_t.MIN_VALUE or floor > _time_t.MAX_VALUE: + if not _time_t.MIN_VALUE <= floor <= _time_t.MAX_VALUE: raise OverflowError('long int too large to convert to int') # usec can't exceed 1000000 Modified: trunk/jython/Lib/test/test_builtin_jy.py =================================================================== --- trunk/jython/Lib/test/test_builtin_jy.py 2008-12-23 19:56:53 UTC (rev 5795) +++ trunk/jython/Lib/test/test_builtin_jy.py 2008-12-24 01:47:07 UTC (rev 5796) @@ -17,7 +17,7 @@ self.assert_(not hasattr(Foo(), 'bar')) def test_dir(self): - # for http://bugs.jython.org/issue1063 + # for http://bugs.jython.org/issue1196 class Foo(object): def __getattribute__(self, name): return name This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-23 19:56:56
|
Revision: 5795 http://jython.svn.sourceforge.net/jython/?rev=5795&view=rev Author: fwierzbicki Date: 2008-12-23 19:56:53 +0000 (Tue, 23 Dec 2008) Log Message: ----------- Fixed a direct cast to stmt in GrammarActions. Modified Paths: -------------- trunk/jython/src/org/python/antlr/GrammarActions.java Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2008-12-23 19:35:40 UTC (rev 5794) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-12-23 19:56:53 UTC (rev 5795) @@ -159,7 +159,7 @@ return new ArrayList<stmt>(); } List <stmt> s = new ArrayList<stmt>(); - s.add((stmt)elif); + s.add(castStmt(elif)); return s; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-23 19:35:45
|
Revision: 5794 http://jython.svn.sourceforge.net/jython/?rev=5794&view=rev Author: fwierzbicki Date: 2008-12-23 19:35:40 +0000 (Tue, 23 Dec 2008) Log Message: ----------- __doc__ for dict. Modified Paths: -------------- trunk/jython/src/org/python/core/PyDictionary.java Modified: trunk/jython/src/org/python/core/PyDictionary.java =================================================================== --- trunk/jython/src/org/python/core/PyDictionary.java 2008-12-23 18:53:36 UTC (rev 5793) +++ trunk/jython/src/org/python/core/PyDictionary.java 2008-12-23 19:35:40 UTC (rev 5794) @@ -80,7 +80,7 @@ } } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict___init___doc) @ExposedNew protected final void dict___init__(PyObject[] args, String[] keywords) { updateCommon(args, keywords, "dict"); @@ -107,7 +107,7 @@ return dict___len__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict___len___doc) final int dict___len__() { return table.size(); } @@ -116,6 +116,7 @@ return dict___nonzero__(); } + //XXX: CPython's dict does not define __nonzero__ @ExposedMethod final boolean dict___nonzero__() { return table.size() != 0; @@ -129,7 +130,7 @@ return table.get(key); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict___getitem___doc) protected final PyObject dict___getitem__(PyObject key) { PyObject result = table.get(key); if (result != null) { @@ -151,7 +152,7 @@ dict___setitem__(key,value); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict___setitem___doc) final void dict___setitem__(PyObject key, PyObject value) { table.put(key, value); } @@ -160,7 +161,7 @@ dict___delitem__(key); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict___delitem___doc) final void dict___delitem__(PyObject key) { Object ret = table.remove(key); if (ret == null) @@ -171,7 +172,7 @@ return dict___iter__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict___iter___doc) final PyObject dict___iter__() { return iterkeys(); } @@ -180,7 +181,7 @@ return dict_toString(); } - @ExposedMethod(names = {"__repr__", "__str__"}) + @ExposedMethod(names = {"__repr__", "__str__"}, doc = BuiltinDocs.dict___str___doc) final String dict_toString() { ThreadState ts = Py.getThreadState(); if (!ts.enterRepr(this)) { @@ -208,7 +209,7 @@ return dict___eq__(ob_other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.dict___eq___doc) final PyObject dict___eq__(PyObject ob_other) { PyType thisType = getType(); PyType otherType = ob_other.getType(); @@ -239,14 +240,14 @@ return dict___ne__(ob_other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.dict___ne___doc) final PyObject dict___ne__(PyObject ob_other) { PyObject eq_result = __eq__(ob_other); if (eq_result == null) return null; return eq_result.__not__(); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.dict___lt___doc) final PyObject dict___lt__(PyObject ob_other){ int result = __cmp__(ob_other); if(result == -2){ @@ -255,7 +256,7 @@ return result < 0 ? Py.True : Py.False; } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.dict___gt___doc) final PyObject dict___gt__(PyObject ob_other){ int result = __cmp__(ob_other); if(result == -2){ @@ -264,7 +265,7 @@ return result > 0 ? Py.True : Py.False; } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.dict___le___doc) final PyObject dict___le__(PyObject ob_other){ int result = __cmp__(ob_other); if(result == -2){ @@ -273,7 +274,7 @@ return result <= 0 ? Py.True : Py.False; } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.dict___ge___doc) final PyObject dict___ge__(PyObject ob_other){ int result = __cmp__(ob_other); if(result == -2){ @@ -286,7 +287,7 @@ return dict___cmp__(ob_other); } - @ExposedMethod(type = MethodType.CMP) + @ExposedMethod(type = MethodType.CMP, doc = BuiltinDocs.dict___cmp___doc) final int dict___cmp__(PyObject ob_other) { PyType thisType = getType(); PyType otherType = ob_other.getType(); @@ -337,7 +338,7 @@ return dict_has_key(key); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict_has_key_doc) final boolean dict_has_key(PyObject key) { return table.containsKey(key); } @@ -346,7 +347,7 @@ return dict___contains__(o); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict___contains___doc) final boolean dict___contains__(PyObject o) { return dict_has_key(o); } @@ -363,7 +364,7 @@ return dict_get(key,default_object); } - @ExposedMethod(defaults = "Py.None") + @ExposedMethod(defaults = "Py.None", doc = BuiltinDocs.dict_get_doc) final PyObject dict_get(PyObject key, PyObject default_object) { PyObject o = table.get(key); if (o == null) @@ -389,7 +390,7 @@ return dict_copy(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict_copy_doc) final PyDictionary dict_copy() { return new PyDictionary(table); // no need to clone() } @@ -401,7 +402,7 @@ dict_clear(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict_clear_doc) final void dict_clear() { table.clear(); } @@ -414,7 +415,7 @@ dict_update(new PyObject[] {other}, Py.NoKeywords); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict_update_doc) final void dict_update(PyObject[] args, String[] keywords) { updateCommon(args, keywords, "update"); } @@ -516,6 +517,7 @@ return dict_setdefault(key,failobj); } + //XXX: needs __doc__ but CPython does not define setdefault @ExposedMethod(defaults = "Py.None") final PyObject dict_setdefault(PyObject key, PyObject failobj) { PyObject oldValue = table.putIfAbsent(key, failobj); @@ -526,6 +528,7 @@ } } + //XXX: needs __doc__ but CPython does not define setifabsent @ExposedMethod(defaults = "Py.None") final PyObject dict_setifabsent(PyObject key, PyObject failobj) { PyObject oldValue = table.putIfAbsent(key, failobj); @@ -553,7 +556,7 @@ return dict_pop(key, defaultValue); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.dict_pop_doc) final PyObject dict_pop(PyObject key, PyObject defaultValue) { if (!table.containsKey(key)) { if (defaultValue == null) { @@ -573,7 +576,7 @@ return dict_popitem(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict_popitem_doc) final PyObject dict_popitem() { Iterator it = table.entrySet().iterator(); if (!it.hasNext()) @@ -593,7 +596,7 @@ return dict_items(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict_items_doc) final PyList dict_items() { List<PyObject> list = new ArrayList<PyObject>(table.size()); for (Entry<PyObject, PyObject> entry : table.entrySet()) { @@ -609,12 +612,12 @@ return dict_keys(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict_keys_doc) final PyList dict_keys() { return new PyList(new ArrayList<PyObject>(table.keySet())); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict_values_doc) final PyList dict_values() { return new PyList(new ArrayList<PyObject>(table.values())); } @@ -626,7 +629,7 @@ return dict_iteritems(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict_iteritems_doc) final PyObject dict_iteritems() { return new ItemsIter(table.entrySet()); } @@ -638,7 +641,7 @@ return dict_iterkeys(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict_iterkeys_doc) final PyObject dict_iterkeys() { return new ValuesIter(table.keySet()); } @@ -650,7 +653,7 @@ return dict_itervalues(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict_itervalues_doc) final PyObject dict_itervalues() { return new ValuesIter(table.values()); } @@ -659,7 +662,7 @@ return dict___hash__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.dict___hash___doc) final int dict___hash__() { throw Py.TypeError(String.format("unhashable type: '%.200s'", getType().fastGetName())); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-23 18:53:41
|
Revision: 5793 http://jython.svn.sourceforge.net/jython/?rev=5793&view=rev Author: fwierzbicki Date: 2008-12-23 18:53:36 +0000 (Tue, 23 Dec 2008) Log Message: ----------- Added some __doc__ info for type. Modified Paths: -------------- trunk/jython/src/org/python/core/PyType.java Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2008-12-23 18:06:19 UTC (rev 5792) +++ trunk/jython/src/org/python/core/PyType.java 2008-12-23 18:53:36 UTC (rev 5793) @@ -421,6 +421,7 @@ return base.getLayout(); } + //XXX: needs __doc__ @ExposedGet(name = "__base__") public PyObject getBase() { if (base == null) @@ -428,6 +429,7 @@ return base; } + //XXX: needs __doc__ @ExposedGet(name = "__bases__") public PyObject getBases() { return new PyTuple(bases); @@ -570,7 +572,7 @@ return new PyLong(tp_flags); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.type___subclasses___doc) public synchronized final PyObject type___subclasses__() { PyList result = new PyList(); cleanup_subclasses(); @@ -681,7 +683,7 @@ return Py.TypeError(msg.toString()); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.type_mro_doc) final PyList type_mro(PyObject o) { if (o == null) { return new PyList(compute_mro()); @@ -1029,7 +1031,7 @@ return addFromClass(c); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.type___getattribute___doc) final PyObject type___getattribute__(PyObject name) { String n = asName(name); PyObject ret = type___findattr_ex__(n); @@ -1081,7 +1083,7 @@ return true; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.type___setattr___doc) final void type___setattr__(PyObject name, PyObject value) { type___setattr__(asName(name), value); } @@ -1127,7 +1129,7 @@ type___delattr__(name); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.type___delattr___doc) final void type___delattr__(PyObject name) { type___delattr__(asName(name)); } @@ -1175,7 +1177,7 @@ return type___call__(args, keywords); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.type___call___doc) final PyObject type___call__(PyObject[] args, String[] keywords) { PyObject new_ = lookup("__new__"); if (!instantiable || new_ == null) { @@ -1292,7 +1294,7 @@ return numSlots; } - @ExposedMethod(names = {"__repr__", "__str__"}) + @ExposedMethod(names = {"__repr__", "__str__"}, doc = BuiltinDocs.type___str___doc) public String type_toString() { String kind; if (!builtin) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-23 18:06:26
|
Revision: 5792 http://jython.svn.sourceforge.net/jython/?rev=5792&view=rev Author: fwierzbicki Date: 2008-12-23 18:06:19 +0000 (Tue, 23 Dec 2008) Log Message: ----------- object __doc__ strings exposed. Put in a comment about exposing __repr__ and __str__, because the Java method called __repr__ is exposed to Python as __str__ which feels wrong. Modified Paths: -------------- trunk/jython/src/org/python/core/PyObject.java Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2008-12-23 03:42:37 UTC (rev 5791) +++ trunk/jython/src/org/python/core/PyObject.java 2008-12-23 18:06:19 UTC (rev 5792) @@ -26,8 +26,9 @@ public static final PyType TYPE = PyType.fromClass(PyObject.class); + //XXX: in CPython object.__new__ has a doc string... @ExposedNew - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.object___init___doc) final void object___init__(PyObject[] args, String[] keywords) { // XXX: attempted fix for object(foo=1), etc // XXX: this doesn't work for metaclasses, for some reason @@ -70,6 +71,7 @@ return objtype; } + //XXX: needs doc @ExposedGet(name = "__doc__") public PyObject getDoc() { PyObject d = fastGetDict(); @@ -156,7 +158,10 @@ * configure the string representation of a <code>PyObject</code> is to * override the standard Java <code>toString</code> method. **/ - @ExposedMethod(names = "__str__") + // counter-intuitively exposing this as __str__, otherwise stack overflow + // occurs during regression testing. XXX: more detail for this comment + // is needed. + @ExposedMethod(names = "__str__", doc = BuiltinDocs.object___str___doc) public PyString __repr__() { return new PyString(toString()); } @@ -165,7 +170,7 @@ return object_toString(); } - @ExposedMethod(names = "__repr__") + @ExposedMethod(names = "__repr__", doc = BuiltinDocs.object___repr___doc) final String object_toString() { if (getType() == null) { return "unknown object"; @@ -211,7 +216,7 @@ return object___hash__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.object___hash___doc) final int object___hash__() { return System.identityHashCode(this); } @@ -3660,7 +3665,7 @@ throw Py.AttributeError("object internal __delete__ impl is abstract"); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.object___getattribute___doc) final PyObject object___getattribute__(PyObject arg0) { String name = asName(arg0); PyObject ret = object___findattr__(name); @@ -3697,7 +3702,7 @@ return null; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.object___setattr___doc) final void object___setattr__(PyObject name, PyObject value) { hackCheck("__setattr__"); object___setattr__(asName(name), value); @@ -3733,7 +3738,7 @@ noAttributeError(name); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.object___delattr___doc) final void object___delattr__(PyObject name) { hackCheck("__delattr__"); object___delattr__(asName(name)); @@ -3806,7 +3811,7 @@ return object___reduce__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.object___reduce___doc) final PyObject object___reduce__() { return object___reduce_ex__(0); } @@ -3826,7 +3831,7 @@ return object___reduce_ex__(0); } - @ExposedMethod(defaults = "0") + @ExposedMethod(defaults = "0", doc = BuiltinDocs.object___reduce___doc) final PyObject object___reduce_ex__(int arg) { PyObject res; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-23 03:42:40
|
Revision: 5791 http://jython.svn.sourceforge.net/jython/?rev=5791&view=rev Author: fwierzbicki Date: 2008-12-23 03:42:37 +0000 (Tue, 23 Dec 2008) Log Message: ----------- __doc__ for unicode type Modified Paths: -------------- trunk/jython/src/org/python/core/PyUnicode.java Modified: trunk/jython/src/org/python/core/PyUnicode.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicode.java 2008-12-23 02:34:17 UTC (rev 5790) +++ trunk/jython/src/org/python/core/PyUnicode.java 2008-12-23 03:42:37 UTC (rev 5791) @@ -207,13 +207,14 @@ return unicode___mod__(other); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode___mod___doc) final PyObject unicode___mod__(PyObject other) { StringFormatter fmt = new StringFormatter(string, true); return fmt.format(other); } - @ExposedMethod + //XXX: needs doc + @ExposedMethod/*(doc = BuiltinDocs.unicode___unicode___doc)*/ final PyUnicode unicode___unicode__() { return str___unicode__(); } @@ -223,7 +224,7 @@ return unicode___str__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode___str___doc) final PyString unicode___str__() { return new PyString(encode()); } @@ -233,7 +234,7 @@ return unicode___len__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode___len___doc) final int unicode___len__() { return getCodePointCount(); } @@ -243,17 +244,17 @@ return unicode___repr__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode___repr___doc) final PyString unicode___repr__() { return new PyString("u" + encode_UnicodeEscape(string, true)); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode___getitem___doc) final PyObject unicode___getitem__(PyObject index) { return str___getitem__(index); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode___getslice__(PyObject start, PyObject stop, PyObject step) { return seq___getslice__(start, stop, step); } @@ -274,22 +275,22 @@ return createInstance(new String(buffer)); } - @ExposedMethod(type = MethodType.CMP) + @ExposedMethod(type = MethodType.CMP, doc = BuiltinDocs.unicode___getslice___doc) final int unicode___cmp__(PyObject other) { return str___cmp__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode___eq__(PyObject other) { return str___eq__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode___ne__(PyObject other) { return str___ne__(other); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode___hash___doc) final int unicode___hash__() { return str___hash__(); } @@ -440,17 +441,17 @@ } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode___contains___doc) final boolean unicode___contains__(PyObject o) { return str___contains__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode___mul__(PyObject o) { return str___mul__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode___rmul__(PyObject o) { return str___rmul__(o); } @@ -459,7 +460,7 @@ return unicode___add__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode___add__(PyObject other) { PyUnicode otherUnicode; if (other instanceof PyUnicode) { @@ -472,17 +473,17 @@ return new PyUnicode(string.concat(otherUnicode.string)); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_lower_doc) final PyObject unicode_lower() { return new PyUnicode(str_lower()); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_upper_doc) final PyObject unicode_upper() { return new PyUnicode(str_upper()); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_title_doc) final PyObject unicode_title() { if (isBasicPlane()) { return new PyUnicode(str_title()); @@ -508,7 +509,7 @@ return new PyUnicode(buffer); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_swapcase_doc) final PyObject unicode_swapcase() { if (isBasicPlane()) { return new PyUnicode(str_swapcase()); @@ -592,7 +593,7 @@ } } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode_strip(PyObject sepObj) { PyUnicode sep = coerceStripSepToUnicode(sepObj); if (isBasicPlane() && (sep == null || sep.isBasicPlane())) { @@ -606,7 +607,7 @@ new ReversedIterator(new StripIterator(sep, newSubsequenceIterator()))))); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode_lstrip(PyObject sepObj) { PyUnicode sep = coerceStripSepToUnicode(sepObj); if (isBasicPlane() && (sep == null || sep.isBasicPlane())) { @@ -619,7 +620,7 @@ return new PyUnicode(new StripIterator(sep, newSubsequenceIterator())); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode_rstrip(PyObject sepObj) { PyUnicode sep = coerceStripSepToUnicode(sepObj); if (isBasicPlane() && (sep == null || sep.isBasicPlane())) { @@ -637,7 +638,7 @@ return unicode_partition(sep); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_partition_doc) final PyTuple unicode_partition(PyObject sep) { return unicodePartition(sep); } @@ -877,12 +878,12 @@ return unicode_rpartition(sep); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_rpartition_doc) final PyTuple unicode_rpartition(PyObject sep) { return unicodeRpartition(sep); } - @ExposedMethod(defaults = {"null", "-1"}) + @ExposedMethod(defaults = {"null", "-1"}, doc = BuiltinDocs.unicode___getslice___doc) final PyList unicode_split(PyObject sepObj, int maxsplit) { PyUnicode sep = coerceToUnicode(sepObj); if (sep != null) { @@ -892,7 +893,7 @@ } } - @ExposedMethod(defaults = {"null", "-1"}) + @ExposedMethod(defaults = {"null", "-1"}, doc = BuiltinDocs.unicode___getslice___doc) final PyList unicode_rsplit(PyObject sepObj, int maxsplit) { PyUnicode sep = coerceToUnicode(sepObj); if (sep != null) { @@ -902,7 +903,7 @@ } } - @ExposedMethod(defaults = "false") + @ExposedMethod(defaults = "false", doc = BuiltinDocs.unicode___getslice___doc) final PyList unicode_splitlines(boolean keepends) { if (isBasicPlane()) { return str_splitlines(keepends); @@ -917,17 +918,17 @@ return new PyUnicode(string.substring(begin, end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.unicode___getslice___doc) final int unicode_index(String sub, int start, PyObject end) { return str_index(sub, start, end); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.unicode___getslice___doc) final int unicode_rindex(String sub, int start, PyObject end) { return str_rindex(sub, start, end); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.unicode___getslice___doc) final int unicode_count(PyObject subObj, int start, PyObject end) { final PyUnicode sub = coerceToUnicode(subObj); if (isBasicPlane()) { @@ -953,12 +954,12 @@ return count; } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.unicode___getslice___doc) final int unicode_find(String sub, int start, PyObject end) { return str_find(sub, start, end); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.unicode___getslice___doc) final int unicode_rfind(String sub, int start, PyObject end) { return str_rfind(sub, start, end); } @@ -978,7 +979,7 @@ return fillchar.codePointAt(0); } - @ExposedMethod(defaults="null") + @ExposedMethod(defaults="null", doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode_ljust(int width, String padding) { int n = width - getCodePointCount(); if (n <= 0) { @@ -988,7 +989,7 @@ } } - @ExposedMethod(defaults="null") + @ExposedMethod(defaults="null", doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode_rjust(int width, String padding) { int n = width - getCodePointCount(); if (n <= 0) { @@ -998,7 +999,7 @@ } } - @ExposedMethod(defaults="null") + @ExposedMethod(defaults="null", doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode_center(int width, String padding) { int n = width - getCodePointCount(); if (n <= 0) { @@ -1012,7 +1013,7 @@ return new PyUnicode(padding(half, pad) + string + padding(n - half, pad)); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_zfill_doc) final PyObject unicode_zfill(int width) { int n = getCodePointCount(); if (n >= width) { @@ -1051,12 +1052,12 @@ return new PyUnicode(buffer); } - @ExposedMethod(defaults = "8") + @ExposedMethod(defaults = "8", doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode_expandtabs(int tabsize) { return new PyUnicode(str_expandtabs(tabsize)); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_capitalize_doc) final PyObject unicode_capitalize() { if (string.length() == 0) { return this; @@ -1077,7 +1078,7 @@ return new PyUnicode(buffer); } - @ExposedMethod(defaults = "-1") + @ExposedMethod(defaults = "-1", doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode_replace(PyObject oldPieceObj, PyObject newPieceObj, int maxsplit) { PyUnicode newPiece = coerceToUnicode(newPieceObj); PyUnicode oldPiece = coerceToUnicode(oldPieceObj); @@ -1122,22 +1123,22 @@ return unicode_join(seq); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_join_doc) final PyUnicode unicode_join(PyObject seq) { return unicodeJoin(seq); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.unicode___getslice___doc) final boolean unicode_startswith(PyObject prefix, int start, PyObject end) { return str_startswith(prefix, start, end); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.unicode___getslice___doc) final boolean unicode_endswith(PyObject suffix, int start, PyObject end) { return str_endswith(suffix, start, end); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_translate_doc) final PyObject unicode_translate(PyObject table) { String trans = _codecs.translate_charmap(string, "ignore", table, true).__getitem__(0).toString(); return new PyUnicode(trans); @@ -1145,7 +1146,7 @@ // these tests need to be UTF-16 aware because they are character-by-character tests, // so we can only use equivalent str_XXX tests if we are in basic plane - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_islower_doc) final boolean unicode_islower() { if (isBasicPlane()) { return str_islower(); @@ -1162,7 +1163,7 @@ return cased; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_isupper_doc) final boolean unicode_isupper() { if (isBasicPlane()) { return str_isupper(); @@ -1179,7 +1180,7 @@ return cased; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_isalpha_doc) final boolean unicode_isalpha() { if (isBasicPlane()) { return str_isalpha(); @@ -1195,7 +1196,7 @@ return true; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_isalnum_doc) final boolean unicode_isalnum() { if (isBasicPlane()) { return str_isalnum(); @@ -1213,7 +1214,7 @@ return true; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_isdecimal_doc) final boolean unicode_isdecimal() { if (isBasicPlane()) { return str_isdecimal(); @@ -1229,7 +1230,7 @@ return true; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_isdigit_doc) final boolean unicode_isdigit() { if (isBasicPlane()) { return str_isdigit(); @@ -1245,7 +1246,7 @@ return true; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_isnumeric_doc) final boolean unicode_isnumeric() { if (isBasicPlane()) { return str_isnumeric(); @@ -1264,7 +1265,7 @@ return true; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_istitle_doc) final boolean unicode_istitle() { if (isBasicPlane()) { return str_istitle(); @@ -1295,7 +1296,7 @@ return cased; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_isspace_doc) final boolean unicode_isspace() { if (isBasicPlane()) { return str_isspace(); @@ -1310,23 +1311,24 @@ } return true; } + // XXX: needs doc // end utf-16 aware @ExposedMethod final boolean unicode_isunicode() { return true; } - @ExposedMethod(defaults = {"null", "null"}) + @ExposedMethod(defaults = {"null", "null"}, doc = BuiltinDocs.unicode___getslice___doc) final String unicode_encode(String encoding, String errors) { return str_encode(encoding, errors); } - @ExposedMethod(defaults = {"null", "null"}) + @ExposedMethod(defaults = {"null", "null"}, doc = BuiltinDocs.unicode___getslice___doc) final PyObject unicode_decode(String encoding, String errors) { return str_decode(encoding, errors); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode___getnewargs___doc) final PyTuple unicode___getnewargs__() { return new PyTuple(new PyUnicode(this.string)); } @@ -1422,7 +1424,8 @@ return sb.toString(); } - @ExposedMethod + //needs doc + @ExposedMethod/*(doc = BuiltinDocs.unicode_toString_doc)*/ final String unicode_toString() { return toString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-23 02:55:28
|
Revision: 5789 http://jython.svn.sourceforge.net/jython/?rev=5789&view=rev Author: fwierzbicki Date: 2008-12-23 01:41:45 +0000 (Tue, 23 Dec 2008) Log Message: ----------- more builtins processed for pydoc generation. Modified Paths: -------------- trunk/jython/Misc/make_pydocs.py Modified: trunk/jython/Misc/make_pydocs.py =================================================================== --- trunk/jython/Misc/make_pydocs.py 2008-12-23 00:35:32 UTC (rev 5788) +++ trunk/jython/Misc/make_pydocs.py 2008-12-23 01:41:45 UTC (rev 5789) @@ -1,26 +1,65 @@ -class PyDocGenerator(object): - def __init__(self): - self.out = open("BuiltinDocs.java", "w") - print >> self.out, '//generated by make_pydocs.py\n' - print >> self.out, 'package org.python.core;\n' - print >> self.out, 'public class BuiltinDocs {\n' - objects = [str, unicode] - for obj in objects: - print >> self.out, ' //Docs for %s' % obj - for meth in dir(obj): - self.print_doc(obj, meth) - print >> self.out, '}' +import sys +import __builtin__ +def print_doc(out, obj, meth): + doc = (getattr(obj, meth)).__doc__ + if doc == None: + doc = "" + lines = doc.split("\n") + outstring = '\\n" + \n "'.join(lines) + print >> out, (' public final static String %s_%s_doc = ' + % (obj.__name__, meth)) + print >> outfile, ' "%s";\n' % outstring - def print_doc(self, obj, meth): - doc = (getattr(obj, meth)).__doc__ - if doc == None: - doc = "" - lines = doc.split("\n") - out = '\\n" + \n "'.join(lines) - print >> self.out, (' public final static String %s_%s_doc = ' - % (obj.__name__, meth)) - print >> self.out, ' "%s";\n' % out +opt = lambda n: getattr(__builtin__, n, None) -if __name__ == '__main__': - PyDocGenerator() +def f(): pass +try: + raise Exception +except: + _, _, tb = sys.exc_info() + +class C: + f = f + +m = C.f + +types_list = [ +object, +type, +unicode, +dict, +list, +slice, +super, +staticmethod, +float, +opt('enumerate'), +#open, +opt('basestring'), +long, +tuple, +str, +property, +int, +xrange, +file, +complex, +opt('bool'), +classmethod, +] + +outfile = open("BuiltinDocs.java", "w") +print >> outfile, '//generated by make_pydocs.py\n' +print >> outfile, 'package org.python.core;\n' +print >> outfile, 'public class BuiltinDocs {\n' + + +for obj in types_list: + print >> outfile, ' //Docs for %s' % obj + for meth in dir(obj): + print_doc(outfile, obj, meth) + +print >> outfile, '}' + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-23 02:34:23
|
Revision: 5790 http://jython.svn.sourceforge.net/jython/?rev=5790&view=rev Author: fwierzbicki Date: 2008-12-23 02:34:17 +0000 (Tue, 23 Dec 2008) Log Message: ----------- Added in most of the types from make_checker and created a more complete BuiltinDocs.java. Still need to actually expose the docs in each of the builtins. Modified Paths: -------------- trunk/jython/Misc/make_pydocs.py trunk/jython/src/org/python/core/BuiltinDocs.java Modified: trunk/jython/Misc/make_pydocs.py =================================================================== --- trunk/jython/Misc/make_pydocs.py 2008-12-23 01:41:45 UTC (rev 5789) +++ trunk/jython/Misc/make_pydocs.py 2008-12-23 02:34:17 UTC (rev 5790) @@ -47,6 +47,14 @@ complex, opt('bool'), classmethod, +#buffer, +# + +type(f), +type(m), +type(f.func_code), +type(sys._getframe()), +type(tb), +#type(slice), ] outfile = open("BuiltinDocs.java", "w") Modified: trunk/jython/src/org/python/core/BuiltinDocs.java =================================================================== --- trunk/jython/src/org/python/core/BuiltinDocs.java 2008-12-23 01:41:45 UTC (rev 5789) +++ trunk/jython/src/org/python/core/BuiltinDocs.java 2008-12-23 02:34:17 UTC (rev 5790) @@ -4,6 +4,1470 @@ public class BuiltinDocs { + //Docs for <type 'object'> + public final static String object___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String object___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String object___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String object___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String object___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String object___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String object___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String object___reduce___doc = + "helper for pickle"; + + public final static String object___reduce_ex___doc = + "helper for pickle"; + + public final static String object___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String object___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String object___str___doc = + "x.__str__() <==> str(x)"; + + //Docs for <type 'type'> + public final static String type___base___doc = + "The most base type"; + + public final static String type___bases___doc = + "tuple() -> an empty tuple\n" + + "tuple(sequence) -> tuple initialized from sequence's items\n" + + "\n" + + "If the argument is a tuple, the return value is the same object."; + + public final static String type___basicsize___doc = + "int(x[, base]) -> integer\n" + + "\n" + + "Convert a string or number to an integer, if possible. A floating point\n" + + "argument will be truncated towards zero (this does not include a string\n" + + "representation of a floating point number!) When converting a string, use\n" + + "the optional base. It is an error to supply a base when converting a\n" + + "non-string. If the argument is outside the integer range a long object\n" + + "will be returned instead."; + + public final static String type___call___doc = + "x.__call__(...) <==> x(...)"; + + public final static String type___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String type___cmp___doc = + "x.__cmp__(y) <==> cmp(x,y)"; + + public final static String type___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String type___dict___doc = + ""; + + public final static String type___dictoffset___doc = + "int(x[, base]) -> integer\n" + + "\n" + + "Convert a string or number to an integer, if possible. A floating point\n" + + "argument will be truncated towards zero (this does not include a string\n" + + "representation of a floating point number!) When converting a string, use\n" + + "the optional base. It is an error to supply a base when converting a\n" + + "non-string. If the argument is outside the integer range a long object\n" + + "will be returned instead."; + + public final static String type___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String type___flags___doc = + "int(x[, base]) -> integer\n" + + "\n" + + "Convert a string or number to an integer, if possible. A floating point\n" + + "argument will be truncated towards zero (this does not include a string\n" + + "representation of a floating point number!) When converting a string, use\n" + + "the optional base. It is an error to supply a base when converting a\n" + + "non-string. If the argument is outside the integer range a long object\n" + + "will be returned instead."; + + public final static String type___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String type___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String type___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String type___itemsize___doc = + "int(x[, base]) -> integer\n" + + "\n" + + "Convert a string or number to an integer, if possible. A floating point\n" + + "argument will be truncated towards zero (this does not include a string\n" + + "representation of a floating point number!) When converting a string, use\n" + + "the optional base. It is an error to supply a base when converting a\n" + + "non-string. If the argument is outside the integer range a long object\n" + + "will be returned instead."; + + public final static String type___module___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String type___mro___doc = + "tuple() -> an empty tuple\n" + + "tuple(sequence) -> tuple initialized from sequence's items\n" + + "\n" + + "If the argument is a tuple, the return value is the same object."; + + public final static String type___name___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String type___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String type___reduce___doc = + "helper for pickle"; + + public final static String type___reduce_ex___doc = + "helper for pickle"; + + public final static String type___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String type___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String type___str___doc = + "x.__str__() <==> str(x)"; + + public final static String type___subclasses___doc = + "__subclasses__() -> list of immediate subclasses"; + + public final static String type___weakrefoffset___doc = + "int(x[, base]) -> integer\n" + + "\n" + + "Convert a string or number to an integer, if possible. A floating point\n" + + "argument will be truncated towards zero (this does not include a string\n" + + "representation of a floating point number!) When converting a string, use\n" + + "the optional base. It is an error to supply a base when converting a\n" + + "non-string. If the argument is outside the integer range a long object\n" + + "will be returned instead."; + + public final static String type_mro_doc = + "mro() -> list\n" + + "return a type's method resolution order"; + + //Docs for <type 'unicode'> + public final static String unicode___add___doc = + "x.__add__(y) <==> x+y"; + + public final static String unicode___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String unicode___contains___doc = + "x.__contains__(y) <==> y in x"; + + public final static String unicode___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String unicode___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String unicode___eq___doc = + "x.__eq__(y) <==> x==y"; + + public final static String unicode___ge___doc = + "x.__ge__(y) <==> x>=y"; + + public final static String unicode___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String unicode___getitem___doc = + "x.__getitem__(y) <==> x[y]"; + + public final static String unicode___getnewargs___doc = + ""; + + public final static String unicode___getslice___doc = + "x.__getslice__(i, j) <==> x[i:j]\n" + + " \n" + + " Use of negative indices is not supported."; + + public final static String unicode___gt___doc = + "x.__gt__(y) <==> x>y"; + + public final static String unicode___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String unicode___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String unicode___le___doc = + "x.__le__(y) <==> x<=y"; + + public final static String unicode___len___doc = + "x.__len__() <==> len(x)"; + + public final static String unicode___lt___doc = + "x.__lt__(y) <==> x<y"; + + public final static String unicode___mod___doc = + "x.__mod__(y) <==> x%y"; + + public final static String unicode___mul___doc = + "x.__mul__(n) <==> x*n"; + + public final static String unicode___ne___doc = + "x.__ne__(y) <==> x!=y"; + + public final static String unicode___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String unicode___reduce___doc = + "helper for pickle"; + + public final static String unicode___reduce_ex___doc = + "helper for pickle"; + + public final static String unicode___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String unicode___rmod___doc = + "x.__rmod__(y) <==> y%x"; + + public final static String unicode___rmul___doc = + "x.__rmul__(n) <==> n*x"; + + public final static String unicode___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String unicode___str___doc = + "x.__str__() <==> str(x)"; + + public final static String unicode_capitalize_doc = + "S.capitalize() -> unicode\n" + + "\n" + + "Return a capitalized version of S, i.e. make the first character\n" + + "have upper case."; + + public final static String unicode_center_doc = + "S.center(width[, fillchar]) -> unicode\n" + + "\n" + + "Return S centered in a Unicode string of length width. Padding is\n" + + "done using the specified fill character (default is a space)"; + + public final static String unicode_count_doc = + "S.count(sub[, start[, end]]) -> int\n" + + "\n" + + "Return the number of non-overlapping occurrences of substring sub in\n" + + "Unicode string S[start:end]. Optional arguments start and end are\n" + + "interpreted as in slice notation."; + + public final static String unicode_decode_doc = + "S.decode([encoding[,errors]]) -> string or unicode\n" + + "\n" + + "Decodes S using the codec registered for encoding. encoding defaults\n" + + "to the default encoding. errors may be given to set a different error\n" + + "handling scheme. Default is 'strict' meaning that encoding errors raise\n" + + "a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'\n" + + "as well as any other name registerd with codecs.register_error that is\n" + + "able to handle UnicodeDecodeErrors."; + + public final static String unicode_encode_doc = + "S.encode([encoding[,errors]]) -> string or unicode\n" + + "\n" + + "Encodes S using the codec registered for encoding. encoding defaults\n" + + "to the default encoding. errors may be given to set a different error\n" + + "handling scheme. Default is 'strict' meaning that encoding errors raise\n" + + "a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and\n" + + "'xmlcharrefreplace' as well as any other name registered with\n" + + "codecs.register_error that can handle UnicodeEncodeErrors."; + + public final static String unicode_endswith_doc = + "S.endswith(suffix[, start[, end]]) -> bool\n" + + "\n" + + "Return True if S ends with the specified suffix, False otherwise.\n" + + "With optional start, test S beginning at that position.\n" + + "With optional end, stop comparing S at that position.\n" + + "suffix can also be a tuple of strings to try."; + + public final static String unicode_expandtabs_doc = + "S.expandtabs([tabsize]) -> unicode\n" + + "\n" + + "Return a copy of S where all tab characters are expanded using spaces.\n" + + "If tabsize is not given, a tab size of 8 characters is assumed."; + + public final static String unicode_find_doc = + "S.find(sub [,start [,end]]) -> int\n" + + "\n" + + "Return the lowest index in S where substring sub is found,\n" + + "such that sub is contained within s[start:end]. Optional\n" + + "arguments start and end are interpreted as in slice notation.\n" + + "\n" + + "Return -1 on failure."; + + public final static String unicode_index_doc = + "S.index(sub [,start [,end]]) -> int\n" + + "\n" + + "Like S.find() but raise ValueError when the substring is not found."; + + public final static String unicode_isalnum_doc = + "S.isalnum() -> bool\n" + + "\n" + + "Return True if all characters in S are alphanumeric\n" + + "and there is at least one character in S, False otherwise."; + + public final static String unicode_isalpha_doc = + "S.isalpha() -> bool\n" + + "\n" + + "Return True if all characters in S are alphabetic\n" + + "and there is at least one character in S, False otherwise."; + + public final static String unicode_isdecimal_doc = + "S.isdecimal() -> bool\n" + + "\n" + + "Return True if there are only decimal characters in S,\n" + + "False otherwise."; + + public final static String unicode_isdigit_doc = + "S.isdigit() -> bool\n" + + "\n" + + "Return True if all characters in S are digits\n" + + "and there is at least one character in S, False otherwise."; + + public final static String unicode_islower_doc = + "S.islower() -> bool\n" + + "\n" + + "Return True if all cased characters in S are lowercase and there is\n" + + "at least one cased character in S, False otherwise."; + + public final static String unicode_isnumeric_doc = + "S.isnumeric() -> bool\n" + + "\n" + + "Return True if there are only numeric characters in S,\n" + + "False otherwise."; + + public final static String unicode_isspace_doc = + "S.isspace() -> bool\n" + + "\n" + + "Return True if all characters in S are whitespace\n" + + "and there is at least one character in S, False otherwise."; + + public final static String unicode_istitle_doc = + "S.istitle() -> bool\n" + + "\n" + + "Return True if S is a titlecased string and there is at least one\n" + + "character in S, i.e. upper- and titlecase characters may only\n" + + "follow uncased characters and lowercase characters only cased ones.\n" + + "Return False otherwise."; + + public final static String unicode_isupper_doc = + "S.isupper() -> bool\n" + + "\n" + + "Return True if all cased characters in S are uppercase and there is\n" + + "at least one cased character in S, False otherwise."; + + public final static String unicode_join_doc = + "S.join(sequence) -> unicode\n" + + "\n" + + "Return a string which is the concatenation of the strings in the\n" + + "sequence. The separator between elements is S."; + + public final static String unicode_ljust_doc = + "S.ljust(width[, fillchar]) -> int\n" + + "\n" + + "Return S left justified in a Unicode string of length width. Padding is\n" + + "done using the specified fill character (default is a space)."; + + public final static String unicode_lower_doc = + "S.lower() -> unicode\n" + + "\n" + + "Return a copy of the string S converted to lowercase."; + + public final static String unicode_lstrip_doc = + "S.lstrip([chars]) -> unicode\n" + + "\n" + + "Return a copy of the string S with leading whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is a str, it will be converted to unicode before stripping"; + + public final static String unicode_partition_doc = + "S.partition(sep) -> (head, sep, tail)\n" + + "\n" + + "Searches for the separator sep in S, and returns the part before it,\n" + + "the separator itself, and the part after it. If the separator is not\n" + + "found, returns S and two empty strings."; + + public final static String unicode_replace_doc = + "S.replace (old, new[, maxsplit]) -> unicode\n" + + "\n" + + "Return a copy of S with all occurrences of substring\n" + + "old replaced by new. If the optional argument maxsplit is\n" + + "given, only the first maxsplit occurrences are replaced."; + + public final static String unicode_rfind_doc = + "S.rfind(sub [,start [,end]]) -> int\n" + + "\n" + + "Return the highest index in S where substring sub is found,\n" + + "such that sub is contained within s[start:end]. Optional\n" + + "arguments start and end are interpreted as in slice notation.\n" + + "\n" + + "Return -1 on failure."; + + public final static String unicode_rindex_doc = + "S.rindex(sub [,start [,end]]) -> int\n" + + "\n" + + "Like S.rfind() but raise ValueError when the substring is not found."; + + public final static String unicode_rjust_doc = + "S.rjust(width[, fillchar]) -> unicode\n" + + "\n" + + "Return S right justified in a Unicode string of length width. Padding is\n" + + "done using the specified fill character (default is a space)."; + + public final static String unicode_rpartition_doc = + "S.rpartition(sep) -> (tail, sep, head)\n" + + "\n" + + "Searches for the separator sep in S, starting at the end of S, and returns\n" + + "the part before it, the separator itself, and the part after it. If the\n" + + "separator is not found, returns two empty strings and S."; + + public final static String unicode_rsplit_doc = + "S.rsplit([sep [,maxsplit]]) -> list of strings\n" + + "\n" + + "Return a list of the words in S, using sep as the\n" + + "delimiter string, starting at the end of the string and\n" + + "working to the front. If maxsplit is given, at most maxsplit\n" + + "splits are done. If sep is not specified, any whitespace string\n" + + "is a separator."; + + public final static String unicode_rstrip_doc = + "S.rstrip([chars]) -> unicode\n" + + "\n" + + "Return a copy of the string S with trailing whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is a str, it will be converted to unicode before stripping"; + + public final static String unicode_split_doc = + "S.split([sep [,maxsplit]]) -> list of strings\n" + + "\n" + + "Return a list of the words in S, using sep as the\n" + + "delimiter string. If maxsplit is given, at most maxsplit\n" + + "splits are done. If sep is not specified or is None,\n" + + "any whitespace string is a separator."; + + public final static String unicode_splitlines_doc = + "S.splitlines([keepends]]) -> list of strings\n" + + "\n" + + "Return a list of the lines in S, breaking at line boundaries.\n" + + "Line breaks are not included in the resulting list unless keepends\n" + + "is given and true."; + + public final static String unicode_startswith_doc = + "S.startswith(prefix[, start[, end]]) -> bool\n" + + "\n" + + "Return True if S starts with the specified prefix, False otherwise.\n" + + "With optional start, test S beginning at that position.\n" + + "With optional end, stop comparing S at that position.\n" + + "prefix can also be a tuple of strings to try."; + + public final static String unicode_strip_doc = + "S.strip([chars]) -> unicode\n" + + "\n" + + "Return a copy of the string S with leading and trailing\n" + + "whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is a str, it will be converted to unicode before stripping"; + + public final static String unicode_swapcase_doc = + "S.swapcase() -> unicode\n" + + "\n" + + "Return a copy of S with uppercase characters converted to lowercase\n" + + "and vice versa."; + + public final static String unicode_title_doc = + "S.title() -> unicode\n" + + "\n" + + "Return a titlecased version of S, i.e. words start with title case\n" + + "characters, all remaining cased characters have lower case."; + + public final static String unicode_translate_doc = + "S.translate(table) -> unicode\n" + + "\n" + + "Return a copy of the string S, where all characters have been mapped\n" + + "through the given translation table, which must be a mapping of\n" + + "Unicode ordinals to Unicode ordinals, Unicode strings or None.\n" + + "Unmapped characters are left untouched. Characters mapped to None\n" + + "are deleted."; + + public final static String unicode_upper_doc = + "S.upper() -> unicode\n" + + "\n" + + "Return a copy of S converted to uppercase."; + + public final static String unicode_zfill_doc = + "S.zfill(width) -> unicode\n" + + "\n" + + "Pad a numeric string x with zeros on the left, to fill a field\n" + + "of the specified width. The string x is never truncated."; + + //Docs for <type 'dict'> + public final static String dict___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String dict___cmp___doc = + "x.__cmp__(y) <==> cmp(x,y)"; + + public final static String dict___contains___doc = + "D.__contains__(k) -> True if D has a key k, else False"; + + public final static String dict___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String dict___delitem___doc = + "x.__delitem__(y) <==> del x[y]"; + + public final static String dict___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String dict___eq___doc = + "x.__eq__(y) <==> x==y"; + + public final static String dict___ge___doc = + "x.__ge__(y) <==> x>=y"; + + public final static String dict___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String dict___getitem___doc = + "x.__getitem__(y) <==> x[y]"; + + public final static String dict___gt___doc = + "x.__gt__(y) <==> x>y"; + + public final static String dict___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String dict___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String dict___iter___doc = + "x.__iter__() <==> iter(x)"; + + public final static String dict___le___doc = + "x.__le__(y) <==> x<=y"; + + public final static String dict___len___doc = + "x.__len__() <==> len(x)"; + + public final static String dict___lt___doc = + "x.__lt__(y) <==> x<y"; + + public final static String dict___ne___doc = + "x.__ne__(y) <==> x!=y"; + + public final static String dict___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String dict___reduce___doc = + "helper for pickle"; + + public final static String dict___reduce_ex___doc = + "helper for pickle"; + + public final static String dict___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String dict___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String dict___setitem___doc = + "x.__setitem__(i, y) <==> x[i]=y"; + + public final static String dict___str___doc = + "x.__str__() <==> str(x)"; + + public final static String dict_clear_doc = + "D.clear() -> None. Remove all items from D."; + + public final static String dict_copy_doc = + "D.copy() -> a shallow copy of D"; + + public final static String dict_fromkeys_doc = + "dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.\n" + + "v defaults to None."; + + public final static String dict_get_doc = + "D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None."; + + public final static String dict_has_key_doc = + "D.has_key(k) -> True if D has a key k, else False"; + + public final static String dict_items_doc = + "D.items() -> list of D's (key, value) pairs, as 2-tuples"; + + public final static String dict_iteritems_doc = + "D.iteritems() -> an iterator over the (key, value) items of D"; + + public final static String dict_iterkeys_doc = + "D.iterkeys() -> an iterator over the keys of D"; + + public final static String dict_itervalues_doc = + "D.itervalues() -> an iterator over the values of D"; + + public final static String dict_keys_doc = + "D.keys() -> list of D's keys"; + + public final static String dict_pop_doc = + "D.pop(k[,d]) -> v, remove specified key and return the corresponding value\n" + + "If key is not found, d is returned if given, otherwise KeyError is raised"; + + public final static String dict_popitem_doc = + "D.popitem() -> (k, v), remove and return some (key, value) pair as a\n" + + "2-tuple; but raise KeyError if D is empty"; + + public final static String dict_setdefault_doc = + "D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D"; + + public final static String dict_update_doc = + "D.update(E, **F) -> None. Update D from E and F: for k in E: D[k] = E[k]\n" + + "(if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k]"; + + public final static String dict_values_doc = + "D.values() -> list of D's values"; + + //Docs for <type 'list'> + public final static String list___add___doc = + "x.__add__(y) <==> x+y"; + + public final static String list___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String list___contains___doc = + "x.__contains__(y) <==> y in x"; + + public final static String list___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String list___delitem___doc = + "x.__delitem__(y) <==> del x[y]"; + + public final static String list___delslice___doc = + "x.__delslice__(i, j) <==> del x[i:j]\n" + + " \n" + + " Use of negative indices is not supported."; + + public final static String list___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String list___eq___doc = + "x.__eq__(y) <==> x==y"; + + public final static String list___ge___doc = + "x.__ge__(y) <==> x>=y"; + + public final static String list___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String list___getitem___doc = + "x.__getitem__(y) <==> x[y]"; + + public final static String list___getslice___doc = + "x.__getslice__(i, j) <==> x[i:j]\n" + + " \n" + + " Use of negative indices is not supported."; + + public final static String list___gt___doc = + "x.__gt__(y) <==> x>y"; + + public final static String list___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String list___iadd___doc = + "x.__iadd__(y) <==> x+=y"; + + public final static String list___imul___doc = + "x.__imul__(y) <==> x*=y"; + + public final static String list___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String list___iter___doc = + "x.__iter__() <==> iter(x)"; + + public final static String list___le___doc = + "x.__le__(y) <==> x<=y"; + + public final static String list___len___doc = + "x.__len__() <==> len(x)"; + + public final static String list___lt___doc = + "x.__lt__(y) <==> x<y"; + + public final static String list___mul___doc = + "x.__mul__(n) <==> x*n"; + + public final static String list___ne___doc = + "x.__ne__(y) <==> x!=y"; + + public final static String list___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String list___reduce___doc = + "helper for pickle"; + + public final static String list___reduce_ex___doc = + "helper for pickle"; + + public final static String list___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String list___reversed___doc = + "L.__reversed__() -- return a reverse iterator over the list"; + + public final static String list___rmul___doc = + "x.__rmul__(n) <==> n*x"; + + public final static String list___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String list___setitem___doc = + "x.__setitem__(i, y) <==> x[i]=y"; + + public final static String list___setslice___doc = + "x.__setslice__(i, j, y) <==> x[i:j]=y\n" + + " \n" + + " Use of negative indices is not supported."; + + public final static String list___str___doc = + "x.__str__() <==> str(x)"; + + public final static String list_append_doc = + "L.append(object) -- append object to end"; + + public final static String list_count_doc = + "L.count(value) -> integer -- return number of occurrences of value"; + + public final static String list_extend_doc = + "L.extend(iterable) -- extend list by appending elements from the iterable"; + + public final static String list_index_doc = + "L.index(value, [start, [stop]]) -> integer -- return first index of value"; + + public final static String list_insert_doc = + "L.insert(index, object) -- insert object before index"; + + public final static String list_pop_doc = + "L.pop([index]) -> item -- remove and return item at index (default last)"; + + public final static String list_remove_doc = + "L.remove(value) -- remove first occurrence of value"; + + public final static String list_reverse_doc = + "L.reverse() -- reverse *IN PLACE*"; + + public final static String list_sort_doc = + "L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;\n" + + "cmp(x, y) -> -1, 0, 1"; + + //Docs for <type 'slice'> + public final static String slice___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String slice___cmp___doc = + "x.__cmp__(y) <==> cmp(x,y)"; + + public final static String slice___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String slice___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String slice___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String slice___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String slice___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String slice___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String slice___reduce___doc = + "helper for pickle"; + + public final static String slice___reduce_ex___doc = + "helper for pickle"; + + public final static String slice___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String slice___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String slice___str___doc = + "x.__str__() <==> str(x)"; + + public final static String slice_indices_doc = + "S.indices(len) -> (start, stop, stride)\n" + + "\n" + + "Assuming a sequence of length len, calculate the start and stop\n" + + "indices, and the stride length of the extended slice described by\n" + + "S. Out of bounds indices are clipped in a manner consistent with the\n" + + "handling of normal slices."; + + public final static String slice_start_doc = + ""; + + public final static String slice_step_doc = + ""; + + public final static String slice_stop_doc = + ""; + + //Docs for <type 'super'> + public final static String super___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String super___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String super___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String super___get___doc = + "descr.__get__(obj[, type]) -> value"; + + public final static String super___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String super___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String super___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String super___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String super___reduce___doc = + "helper for pickle"; + + public final static String super___reduce_ex___doc = + "helper for pickle"; + + public final static String super___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String super___self___doc = + "the instance invoking super(); may be None"; + + public final static String super___self_class___doc = + "the type of the instance invoking super(); may be None"; + + public final static String super___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String super___str___doc = + "x.__str__() <==> str(x)"; + + public final static String super___thisclass___doc = + "the class invoking super()"; + + //Docs for <type 'staticmethod'> + public final static String staticmethod___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String staticmethod___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String staticmethod___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String staticmethod___get___doc = + "descr.__get__(obj[, type]) -> value"; + + public final static String staticmethod___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String staticmethod___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String staticmethod___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String staticmethod___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String staticmethod___reduce___doc = + "helper for pickle"; + + public final static String staticmethod___reduce_ex___doc = + "helper for pickle"; + + public final static String staticmethod___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String staticmethod___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String staticmethod___str___doc = + "x.__str__() <==> str(x)"; + + //Docs for <type 'float'> + public final static String float___abs___doc = + "x.__abs__() <==> abs(x)"; + + public final static String float___add___doc = + "x.__add__(y) <==> x+y"; + + public final static String float___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String float___coerce___doc = + "x.__coerce__(y) <==> coerce(x, y)"; + + public final static String float___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String float___div___doc = + "x.__div__(y) <==> x/y"; + + public final static String float___divmod___doc = + "x.__divmod__(y) <==> divmod(x, y)"; + + public final static String float___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String float___eq___doc = + "x.__eq__(y) <==> x==y"; + + public final static String float___float___doc = + "x.__float__() <==> float(x)"; + + public final static String float___floordiv___doc = + "x.__floordiv__(y) <==> x//y"; + + public final static String float___ge___doc = + "x.__ge__(y) <==> x>=y"; + + public final static String float___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String float___getformat___doc = + "float.__getformat__(typestr) -> string\n" + + "\n" + + "You probably don't want to use this function. It exists mainly to be\n" + + "used in Python's test suite.\n" + + "\n" + + "typestr must be 'double' or 'float'. This function returns whichever of\n" + + "'unknown', 'IEEE, big-endian' or 'IEEE, little-endian' best describes the\n" + + "format of floating point numbers used by the C type named by typestr."; + + public final static String float___getnewargs___doc = + ""; + + public final static String float___gt___doc = + "x.__gt__(y) <==> x>y"; + + public final static String float___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String float___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String float___int___doc = + "x.__int__() <==> int(x)"; + + public final static String float___le___doc = + "x.__le__(y) <==> x<=y"; + + public final static String float___long___doc = + "x.__long__() <==> long(x)"; + + public final static String float___lt___doc = + "x.__lt__(y) <==> x<y"; + + public final static String float___mod___doc = + "x.__mod__(y) <==> x%y"; + + public final static String float___mul___doc = + "x.__mul__(y) <==> x*y"; + + public final static String float___ne___doc = + "x.__ne__(y) <==> x!=y"; + + public final static String float___neg___doc = + "x.__neg__() <==> -x"; + + public final static String float___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String float___nonzero___doc = + "x.__nonzero__() <==> x != 0"; + + public final static String float___pos___doc = + "x.__pos__() <==> +x"; + + public final static String float___pow___doc = + "x.__pow__(y[, z]) <==> pow(x, y[, z])"; + + public final static String float___radd___doc = + "x.__radd__(y) <==> y+x"; + + public final static String float___rdiv___doc = + "x.__rdiv__(y) <==> y/x"; + + public final static String float___rdivmod___doc = + "x.__rdivmod__(y) <==> divmod(y, x)"; + + public final static String float___reduce___doc = + "helper for pickle"; + + public final static String float___reduce_ex___doc = + "helper for pickle"; + + public final static String float___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String float___rfloordiv___doc = + "x.__rfloordiv__(y) <==> y//x"; + + public final static String float___rmod___doc = + "x.__rmod__(y) <==> y%x"; + + public final static String float___rmul___doc = + "x.__rmul__(y) <==> y*x"; + + public final static String float___rpow___doc = + "y.__rpow__(x[, z]) <==> pow(x, y[, z])"; + + public final static String float___rsub___doc = + "x.__rsub__(y) <==> y-x"; + + public final static String float___rtruediv___doc = + "x.__rtruediv__(y) <==> y/x"; + + public final static String float___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String float___setformat___doc = + "float.__setformat__(typestr, fmt) -> None\n" + + "\n" + + "You probably don't want to use this function. It exists mainly to be\n" + + "used in Python's test suite.\n" + + "\n" + + "typestr must be 'double' or 'float'. fmt must be one of 'unknown',\n" + + "'IEEE, big-endian' or 'IEEE, little-endian', and in addition can only be\n" + + "one of the latter two if it appears to match the underlying C reality.\n" + + "\n" + + "Overrides the automatic determination of C-level floating point type.\n" + + "This affects how floats are converted to and from binary strings."; + + public final static String float___str___doc = + "x.__str__() <==> str(x)"; + + public final static String float___sub___doc = + "x.__sub__(y) <==> x-y"; + + public final static String float___truediv___doc = + "x.__truediv__(y) <==> x/y"; + + //Docs for <type 'enumerate'> + public final static String enumerate___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String enumerate___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String enumerate___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String enumerate___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String enumerate___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String enumerate___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String enumerate___iter___doc = + "x.__iter__() <==> iter(x)"; + + public final static String enumerate___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String enumerate___reduce___doc = + "helper for pickle"; + + public final static String enumerate___reduce_ex___doc = + "helper for pickle"; + + public final static String enumerate___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String enumerate___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String enumerate___str___doc = + "x.__str__() <==> str(x)"; + + public final static String enumerate_next_doc = + "x.next() -> the next value, or raise StopIteration"; + + //Docs for <type 'basestring'> + public final static String basestring___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String basestring___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String basestring___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String basestring___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String basestring___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String basestring___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String basestring___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String basestring___reduce___doc = + "helper for pickle"; + + public final static String basestring___reduce_ex___doc = + "helper for pickle"; + + public final static String basestring___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String basestring___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String basestring___str___doc = + "x.__str__() <==> str(x)"; + + //Docs for <type 'long'> + public final static String long___abs___doc = + "x.__abs__() <==> abs(x)"; + + public final static String long___add___doc = + "x.__add__(y) <==> x+y"; + + public final static String long___and___doc = + "x.__and__(y) <==> x&y"; + + public final static String long___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String long___cmp___doc = + "x.__cmp__(y) <==> cmp(x,y)"; + + public final static String long___coerce___doc = + "x.__coerce__(y) <==> coerce(x, y)"; + + public final static String long___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String long___div___doc = + "x.__div__(y) <==> x/y"; + + public final static String long___divmod___doc = + "x.__divmod__(y) <==> divmod(x, y)"; + + public final static String long___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String long___float___doc = + "x.__float__() <==> float(x)"; + + public final static String long___floordiv___doc = + "x.__floordiv__(y) <==> x//y"; + + public final static String long___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String long___getnewargs___doc = + ""; + + public final static String long___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String long___hex___doc = + "x.__hex__() <==> hex(x)"; + + public final static String long___index___doc = + "x[y:z] <==> x[y.__index__():z.__index__()]"; + + public final static String long___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String long___int___doc = + "x.__int__() <==> int(x)"; + + public final static String long___invert___doc = + "x.__invert__() <==> ~x"; + + public final static String long___long___doc = + "x.__long__() <==> long(x)"; + + public final static String long___lshift___doc = + "x.__lshift__(y) <==> x<<y"; + + public final static String long___mod___doc = + "x.__mod__(y) <==> x%y"; + + public final static String long___mul___doc = + "x.__mul__(y) <==> x*y"; + + public final static String long___neg___doc = + "x.__neg__() <==> -x"; + + public final static String long___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String long___nonzero___doc = + "x.__nonzero__() <==> x != 0"; + + public final static String long___oct___doc = + "x.__oct__() <==> oct(x)"; + + public final static String long___or___doc = + "x.__or__(y) <==> x|y"; + + public final static String long___pos___doc = + "x.__pos__() <==> +x"; + + public final static String long___pow___doc = + "x.__pow__(y[, z]) <==> pow(x, y[, z])"; + + public final static String long___radd___doc = + "x.__radd__(y) <==> y+x"; + + public final static String long___rand___doc = + "x.__rand__(y) <==> y&x"; + + public final static String long___rdiv___doc = + "x.__rdiv__(y) <==> y/x"; + + public final static String long___rdivmod___doc = + "x.__rdivmod__(y) <==> divmod(y, x)"; + + public final static String long___reduce___doc = + "helper for pickle"; + + public final static String long___reduce_ex___doc = + "helper for pickle"; + + public final static String long___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String long___rfloordiv___doc = + "x.__rfloordiv__(y) <==> y//x"; + + public final static String long___rlshift___doc = + "x.__rlshift__(y) <==> y<<x"; + + public final static String long___rmod___doc = + "x.__rmod__(y) <==> y%x"; + + public final static String long___rmul___doc = + "x.__rmul__(y) <==> y*x"; + + public final static String long___ror___doc = + "x.__ror__(y) <==> y|x"; + + public final static String long___rpow___doc = + "y.__rpow__(x[, z]) <==> pow(x, y[, z])"; + + public final static String long___rrshift___doc = + "x.__rrshift__(y) <==> y>>x"; + + public final static String long___rshift___doc = + "x.__rshift__(y) <==> x>>y"; + + public final static String long___rsub___doc = + "x.__rsub__(y) <==> y-x"; + + public final static String long___rtruediv___doc = + "x.__rtruediv__(y) <==> y/x"; + + public final static String long___rxor___doc = + "x.__rxor__(y) <==> y^x"; + + public final static String long___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String long___str___doc = + "x.__str__() <==> str(x)"; + + public final static String long___sub___doc = + "x.__sub__(y) <==> x-y"; + + public final static String long___truediv___doc = + "x.__truediv__(y) <==> x/y"; + + public final static String long___xor___doc = + "x.__xor__(y) <==> x^y"; + + //Docs for <type 'tuple'> + public final static String tuple___add___doc = + "x.__add__(y) <==> x+y"; + + public final static String tuple___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String tuple___contains___doc = + "x.__contains__(y) <==> y in x"; + + public final static String tuple___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String tuple___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String tuple___eq___doc = + "x.__eq__(y) <==> x==y"; + + public final static String tuple___ge___doc = + "x.__ge__(y) <==> x>=y"; + + public final static String tuple___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String tuple___getitem___doc = + "x.__getitem__(y) <==> x[y]"; + + public final static String tuple___getnewargs___doc = + ""; + + public final static String tuple___getslice___doc = + "x.__getslice__(i, j) <==> x[i:j]\n" + + " \n" + + " Use of negative indices is not supported."; + + public final static String tuple___gt___doc = + "x.__gt__(y) <==> x>y"; + + public final static String tuple___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String tuple___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String tuple___iter___doc = + "x.__iter__() <==> iter(x)"; + + public final static String tuple___le___doc = + "x.__le__(y) <==> x<=y"; + + public final static String tuple___len___doc = + "x.__len__() <==> len(x)"; + + public final static String tuple___lt___doc = + "x.__lt__(y) <==> x<y"; + + public final static String tuple___mul___doc = + "x.__mul__(n) <==> x*n"; + + public final static String tuple___ne___doc = + "x.__ne__(y) <==> x!=y"; + + public final static String tuple___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String tuple___reduce___doc = + "helper for pickle"; + + public final static String tuple___reduce_ex___doc = + "helper for pickle"; + + public final static String tuple___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String tuple___rmul___doc = + "x.__rmul__(n) <==> n*x"; + + public final static String tuple___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String tuple___str___doc = + "x.__str__() <==> str(x)"; + //Docs for <type 'str'> public final static String str___add___doc = "x.__add__(y) <==> x+y"; @@ -349,362 +1813,1135 @@ "Pad a numeric string S with zeros on the left, to fill a field\n" + "of the specified width. The string S is never truncated."; - //Docs for <type 'unicode'> - public final static String unicode___add___doc = + //Docs for <type 'property'> + public final static String property___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String property___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String property___delete___doc = + "descr.__delete__(obj)"; + + public final static String property___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String property___get___doc = + "descr.__get__(obj[, type]) -> value"; + + public final static String property___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String property___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String property___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String property___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String property___reduce___doc = + "helper for pickle"; + + public final static String property___reduce_ex___doc = + "helper for pickle"; + + public final static String property___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String property___set___doc = + "descr.__set__(obj, value)"; + + public final static String property___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String property___str___doc = + "x.__str__() <==> str(x)"; + + public final static String property_fdel_doc = + ""; + + public final static String property_fget_doc = + ""; + + public final static String property_fset_doc = + ""; + + //Docs for <type 'int'> + public final static String int___abs___doc = + "x.__abs__() <==> abs(x)"; + + public final static String int___add___doc = "x.__add__(y) <==> x+y"; - public final static String unicode___class___doc = + public final static String int___and___doc = + "x.__and__(y) <==> x&y"; + + public final static String int___class___doc = "type(object) -> the object's type\n"... [truncated message content] |
From: <fwi...@us...> - 2008-12-23 00:35:36
|
Revision: 5788 http://jython.svn.sourceforge.net/jython/?rev=5788&view=rev Author: fwierzbicki Date: 2008-12-23 00:35:32 +0000 (Tue, 23 Dec 2008) Log Message: ----------- First cut at generating the __doc__ test for builtin types. So far I am only generating the docs for str and unicode, and I have only exposed the docs for str. Modified Paths: -------------- trunk/jython/src/org/python/core/PyString.java Added Paths: ----------- trunk/jython/Misc/make_pydocs.py trunk/jython/src/org/python/core/BuiltinDocs.java Added: trunk/jython/Misc/make_pydocs.py =================================================================== --- trunk/jython/Misc/make_pydocs.py (rev 0) +++ trunk/jython/Misc/make_pydocs.py 2008-12-23 00:35:32 UTC (rev 5788) @@ -0,0 +1,26 @@ +class PyDocGenerator(object): + def __init__(self): + self.out = open("BuiltinDocs.java", "w") + print >> self.out, '//generated by make_pydocs.py\n' + print >> self.out, 'package org.python.core;\n' + print >> self.out, 'public class BuiltinDocs {\n' + objects = [str, unicode] + for obj in objects: + print >> self.out, ' //Docs for %s' % obj + for meth in dir(obj): + self.print_doc(obj, meth) + print >> self.out, '}' + + + def print_doc(self, obj, meth): + doc = (getattr(obj, meth)).__doc__ + if doc == None: + doc = "" + lines = doc.split("\n") + out = '\\n" + \n "'.join(lines) + print >> self.out, (' public final static String %s_%s_doc = ' + % (obj.__name__, meth)) + print >> self.out, ' "%s";\n' % out + +if __name__ == '__main__': + PyDocGenerator() Added: trunk/jython/src/org/python/core/BuiltinDocs.java =================================================================== --- trunk/jython/src/org/python/core/BuiltinDocs.java (rev 0) +++ trunk/jython/src/org/python/core/BuiltinDocs.java 2008-12-23 00:35:32 UTC (rev 5788) @@ -0,0 +1,710 @@ +//generated by make_pydocs.py + +package org.python.core; + +public class BuiltinDocs { + + //Docs for <type 'str'> + public final static String str___add___doc = + "x.__add__(y) <==> x+y"; + + public final static String str___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String str___contains___doc = + "x.__contains__(y) <==> y in x"; + + public final static String str___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String str___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String str___eq___doc = + "x.__eq__(y) <==> x==y"; + + public final static String str___ge___doc = + "x.__ge__(y) <==> x>=y"; + + public final static String str___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String str___getitem___doc = + "x.__getitem__(y) <==> x[y]"; + + public final static String str___getnewargs___doc = + ""; + + public final static String str___getslice___doc = + "x.__getslice__(i, j) <==> x[i:j]\n" + + " \n" + + " Use of negative indices is not supported."; + + public final static String str___gt___doc = + "x.__gt__(y) <==> x>y"; + + public final static String str___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String str___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String str___le___doc = + "x.__le__(y) <==> x<=y"; + + public final static String str___len___doc = + "x.__len__() <==> len(x)"; + + public final static String str___lt___doc = + "x.__lt__(y) <==> x<y"; + + public final static String str___mod___doc = + "x.__mod__(y) <==> x%y"; + + public final static String str___mul___doc = + "x.__mul__(n) <==> x*n"; + + public final static String str___ne___doc = + "x.__ne__(y) <==> x!=y"; + + public final static String str___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String str___reduce___doc = + "helper for pickle"; + + public final static String str___reduce_ex___doc = + "helper for pickle"; + + public final static String str___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String str___rmod___doc = + "x.__rmod__(y) <==> y%x"; + + public final static String str___rmul___doc = + "x.__rmul__(n) <==> n*x"; + + public final static String str___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String str___str___doc = + "x.__str__() <==> str(x)"; + + public final static String str_capitalize_doc = + "S.capitalize() -> string\n" + + "\n" + + "Return a copy of the string S with only its first character\n" + + "capitalized."; + + public final static String str_center_doc = + "S.center(width[, fillchar]) -> string\n" + + "\n" + + "Return S centered in a string of length width. Padding is\n" + + "done using the specified fill character (default is a space)"; + + public final static String str_count_doc = + "S.count(sub[, start[, end]]) -> int\n" + + "\n" + + "Return the number of non-overlapping occurrences of substring sub in\n" + + "string S[start:end]. Optional arguments start and end are interpreted\n" + + "as in slice notation."; + + public final static String str_decode_doc = + "S.decode([encoding[,errors]]) -> object\n" + + "\n" + + "Decodes S using the codec registered for encoding. encoding defaults\n" + + "to the default encoding. errors may be given to set a different error\n" + + "handling scheme. Default is 'strict' meaning that encoding errors raise\n" + + "a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'\n" + + "as well as any other name registerd with codecs.register_error that is\n" + + "able to handle UnicodeDecodeErrors."; + + public final static String str_encode_doc = + "S.encode([encoding[,errors]]) -> object\n" + + "\n" + + "Encodes S using the codec registered for encoding. encoding defaults\n" + + "to the default encoding. errors may be given to set a different error\n" + + "handling scheme. Default is 'strict' meaning that encoding errors raise\n" + + "a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and\n" + + "'xmlcharrefreplace' as well as any other name registered with\n" + + "codecs.register_error that is able to handle UnicodeEncodeErrors."; + + public final static String str_endswith_doc = + "S.endswith(suffix[, start[, end]]) -> bool\n" + + "\n" + + "Return True if S ends with the specified suffix, False otherwise.\n" + + "With optional start, test S beginning at that position.\n" + + "With optional end, stop comparing S at that position.\n" + + "suffix can also be a tuple of strings to try."; + + public final static String str_expandtabs_doc = + "S.expandtabs([tabsize]) -> string\n" + + "\n" + + "Return a copy of S where all tab characters are expanded using spaces.\n" + + "If tabsize is not given, a tab size of 8 characters is assumed."; + + public final static String str_find_doc = + "S.find(sub [,start [,end]]) -> int\n" + + "\n" + + "Return the lowest index in S where substring sub is found,\n" + + "such that sub is contained within s[start:end]. Optional\n" + + "arguments start and end are interpreted as in slice notation.\n" + + "\n" + + "Return -1 on failure."; + + public final static String str_index_doc = + "S.index(sub [,start [,end]]) -> int\n" + + "\n" + + "Like S.find() but raise ValueError when the substring is not found."; + + public final static String str_isalnum_doc = + "S.isalnum() -> bool\n" + + "\n" + + "Return True if all characters in S are alphanumeric\n" + + "and there is at least one character in S, False otherwise."; + + public final static String str_isalpha_doc = + "S.isalpha() -> bool\n" + + "\n" + + "Return True if all characters in S are alphabetic\n" + + "and there is at least one character in S, False otherwise."; + + public final static String str_isdigit_doc = + "S.isdigit() -> bool\n" + + "\n" + + "Return True if all characters in S are digits\n" + + "and there is at least one character in S, False otherwise."; + + public final static String str_islower_doc = + "S.islower() -> bool\n" + + "\n" + + "Return True if all cased characters in S are lowercase and there is\n" + + "at least one cased character in S, False otherwise."; + + public final static String str_isspace_doc = + "S.isspace() -> bool\n" + + "\n" + + "Return True if all characters in S are whitespace\n" + + "and there is at least one character in S, False otherwise."; + + public final static String str_istitle_doc = + "S.istitle() -> bool\n" + + "\n" + + "Return True if S is a titlecased string and there is at least one\n" + + "character in S, i.e. uppercase characters may only follow uncased\n" + + "characters and lowercase characters only cased ones. Return False\n" + + "otherwise."; + + public final static String str_isupper_doc = + "S.isupper() -> bool\n" + + "\n" + + "Return True if all cased characters in S are uppercase and there is\n" + + "at least one cased character in S, False otherwise."; + + public final static String str_join_doc = + "S.join(sequence) -> string\n" + + "\n" + + "Return a string which is the concatenation of the strings in the\n" + + "sequence. The separator between elements is S."; + + public final static String str_ljust_doc = + "S.ljust(width[, fillchar]) -> string\n" + + "\n" + + "Return S left justified in a string of length width. Padding is\n" + + "done using the specified fill character (default is a space)."; + + public final static String str_lower_doc = + "S.lower() -> string\n" + + "\n" + + "Return a copy of the string S converted to lowercase."; + + public final static String str_lstrip_doc = + "S.lstrip([chars]) -> string or unicode\n" + + "\n" + + "Return a copy of the string S with leading whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is unicode, S will be converted to unicode before stripping"; + + public final static String str_partition_doc = + "S.partition(sep) -> (head, sep, tail)\n" + + "\n" + + "Searches for the separator sep in S, and returns the part before it,\n" + + "the separator itself, and the part after it. If the separator is not\n" + + "found, returns S and two empty strings."; + + public final static String str_replace_doc = + "S.replace (old, new[, count]) -> string\n" + + "\n" + + "Return a copy of string S with all occurrences of substring\n" + + "old replaced by new. If the optional argument count is\n" + + "given, only the first count occurrences are replaced."; + + public final static String str_rfind_doc = + "S.rfind(sub [,start [,end]]) -> int\n" + + "\n" + + "Return the highest index in S where substring sub is found,\n" + + "such that sub is contained within s[start:end]. Optional\n" + + "arguments start and end are interpreted as in slice notation.\n" + + "\n" + + "Return -1 on failure."; + + public final static String str_rindex_doc = + "S.rindex(sub [,start [,end]]) -> int\n" + + "\n" + + "Like S.rfind() but raise ValueError when the substring is not found."; + + public final static String str_rjust_doc = + "S.rjust(width[, fillchar]) -> string\n" + + "\n" + + "Return S right justified in a string of length width. Padding is\n" + + "done using the specified fill character (default is a space)"; + + public final static String str_rpartition_doc = + "S.rpartition(sep) -> (tail, sep, head)\n" + + "\n" + + "Searches for the separator sep in S, starting at the end of S, and returns\n" + + "the part before it, the separator itself, and the part after it. If the\n" + + "separator is not found, returns two empty strings and S."; + + public final static String str_rsplit_doc = + "S.rsplit([sep [,maxsplit]]) -> list of strings\n" + + "\n" + + "Return a list of the words in the string S, using sep as the\n" + + "delimiter string, starting at the end of the string and working\n" + + "to the front. If maxsplit is given, at most maxsplit splits are\n" + + "done. If sep is not specified or is None, any whitespace string\n" + + "is a separator."; + + public final static String str_rstrip_doc = + "S.rstrip([chars]) -> string or unicode\n" + + "\n" + + "Return a copy of the string S with trailing whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is unicode, S will be converted to unicode before stripping"; + + public final static String str_split_doc = + "S.split([sep [,maxsplit]]) -> list of strings\n" + + "\n" + + "Return a list of the words in the string S, using sep as the\n" + + "delimiter string. If maxsplit is given, at most maxsplit\n" + + "splits are done. If sep is not specified or is None, any\n" + + "whitespace string is a separator."; + + public final static String str_splitlines_doc = + "S.splitlines([keepends]) -> list of strings\n" + + "\n" + + "Return a list of the lines in S, breaking at line boundaries.\n" + + "Line breaks are not included in the resulting list unless keepends\n" + + "is given and true."; + + public final static String str_startswith_doc = + "S.startswith(prefix[, start[, end]]) -> bool\n" + + "\n" + + "Return True if S starts with the specified prefix, False otherwise.\n" + + "With optional start, test S beginning at that position.\n" + + "With optional end, stop comparing S at that position.\n" + + "prefix can also be a tuple of strings to try."; + + public final static String str_strip_doc = + "S.strip([chars]) -> string or unicode\n" + + "\n" + + "Return a copy of the string S with leading and trailing\n" + + "whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is unicode, S will be converted to unicode before stripping"; + + public final static String str_swapcase_doc = + "S.swapcase() -> string\n" + + "\n" + + "Return a copy of the string S with uppercase characters\n" + + "converted to lowercase and vice versa."; + + public final static String str_title_doc = + "S.title() -> string\n" + + "\n" + + "Return a titlecased version of S, i.e. words start with uppercase\n" + + "characters, all remaining cased characters have lowercase."; + + public final static String str_translate_doc = + "S.translate(table [,deletechars]) -> string\n" + + "\n" + + "Return a copy of the string S, where all characters occurring\n" + + "in the optional argument deletechars are removed, and the\n" + + "remaining characters have been mapped through the given\n" + + "translation table, which must be a string of length 256."; + + public final static String str_upper_doc = + "S.upper() -> string\n" + + "\n" + + "Return a copy of the string S converted to uppercase."; + + public final static String str_zfill_doc = + "S.zfill(width) -> string\n" + + "\n" + + "Pad a numeric string S with zeros on the left, to fill a field\n" + + "of the specified width. The string S is never truncated."; + + //Docs for <type 'unicode'> + public final static String unicode___add___doc = + "x.__add__(y) <==> x+y"; + + public final static String unicode___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String unicode___contains___doc = + "x.__contains__(y) <==> y in x"; + + public final static String unicode___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String unicode___doc___doc = + "str(object) -> string\n" + + "\n" + + "Return a nice string representation of the object.\n" + + "If the argument is a string, the return value is the same object."; + + public final static String unicode___eq___doc = + "x.__eq__(y) <==> x==y"; + + public final static String unicode___ge___doc = + "x.__ge__(y) <==> x>=y"; + + public final static String unicode___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String unicode___getitem___doc = + "x.__getitem__(y) <==> x[y]"; + + public final static String unicode___getnewargs___doc = + ""; + + public final static String unicode___getslice___doc = + "x.__getslice__(i, j) <==> x[i:j]\n" + + " \n" + + " Use of negative indices is not supported."; + + public final static String unicode___gt___doc = + "x.__gt__(y) <==> x>y"; + + public final static String unicode___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String unicode___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String unicode___le___doc = + "x.__le__(y) <==> x<=y"; + + public final static String unicode___len___doc = + "x.__len__() <==> len(x)"; + + public final static String unicode___lt___doc = + "x.__lt__(y) <==> x<y"; + + public final static String unicode___mod___doc = + "x.__mod__(y) <==> x%y"; + + public final static String unicode___mul___doc = + "x.__mul__(n) <==> x*n"; + + public final static String unicode___ne___doc = + "x.__ne__(y) <==> x!=y"; + + public final static String unicode___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String unicode___reduce___doc = + "helper for pickle"; + + public final static String unicode___reduce_ex___doc = + "helper for pickle"; + + public final static String unicode___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String unicode___rmod___doc = + "x.__rmod__(y) <==> y%x"; + + public final static String unicode___rmul___doc = + "x.__rmul__(n) <==> n*x"; + + public final static String unicode___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String unicode___str___doc = + "x.__str__() <==> str(x)"; + + public final static String unicode_capitalize_doc = + "S.capitalize() -> unicode\n" + + "\n" + + "Return a capitalized version of S, i.e. make the first character\n" + + "have upper case."; + + public final static String unicode_center_doc = + "S.center(width[, fillchar]) -> unicode\n" + + "\n" + + "Return S centered in a Unicode string of length width. Padding is\n" + + "done using the specified fill character (default is a space)"; + + public final static String unicode_count_doc = + "S.count(sub[, start[, end]]) -> int\n" + + "\n" + + "Return the number of non-overlapping occurrences of substring sub in\n" + + "Unicode string S[start:end]. Optional arguments start and end are\n" + + "interpreted as in slice notation."; + + public final static String unicode_decode_doc = + "S.decode([encoding[,errors]]) -> string or unicode\n" + + "\n" + + "Decodes S using the codec registered for encoding. encoding defaults\n" + + "to the default encoding. errors may be given to set a different error\n" + + "handling scheme. Default is 'strict' meaning that encoding errors raise\n" + + "a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'\n" + + "as well as any other name registerd with codecs.register_error that is\n" + + "able to handle UnicodeDecodeErrors."; + + public final static String unicode_encode_doc = + "S.encode([encoding[,errors]]) -> string or unicode\n" + + "\n" + + "Encodes S using the codec registered for encoding. encoding defaults\n" + + "to the default encoding. errors may be given to set a different error\n" + + "handling scheme. Default is 'strict' meaning that encoding errors raise\n" + + "a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and\n" + + "'xmlcharrefreplace' as well as any other name registered with\n" + + "codecs.register_error that can handle UnicodeEncodeErrors."; + + public final static String unicode_endswith_doc = + "S.endswith(suffix[, start[, end]]) -> bool\n" + + "\n" + + "Return True if S ends with the specified suffix, False otherwise.\n" + + "With optional start, test S beginning at that position.\n" + + "With optional end, stop comparing S at that position.\n" + + "suffix can also be a tuple of strings to try."; + + public final static String unicode_expandtabs_doc = + "S.expandtabs([tabsize]) -> unicode\n" + + "\n" + + "Return a copy of S where all tab characters are expanded using spaces.\n" + + "If tabsize is not given, a tab size of 8 characters is assumed."; + + public final static String unicode_find_doc = + "S.find(sub [,start [,end]]) -> int\n" + + "\n" + + "Return the lowest index in S where substring sub is found,\n" + + "such that sub is contained within s[start:end]. Optional\n" + + "arguments start and end are interpreted as in slice notation.\n" + + "\n" + + "Return -1 on failure."; + + public final static String unicode_index_doc = + "S.index(sub [,start [,end]]) -> int\n" + + "\n" + + "Like S.find() but raise ValueError when the substring is not found."; + + public final static String unicode_isalnum_doc = + "S.isalnum() -> bool\n" + + "\n" + + "Return True if all characters in S are alphanumeric\n" + + "and there is at least one character in S, False otherwise."; + + public final static String unicode_isalpha_doc = + "S.isalpha() -> bool\n" + + "\n" + + "Return True if all characters in S are alphabetic\n" + + "and there is at least one character in S, False otherwise."; + + public final static String unicode_isdecimal_doc = + "S.isdecimal() -> bool\n" + + "\n" + + "Return True if there are only decimal characters in S,\n" + + "False otherwise."; + + public final static String unicode_isdigit_doc = + "S.isdigit() -> bool\n" + + "\n" + + "Return True if all characters in S are digits\n" + + "and there is at least one character in S, False otherwise."; + + public final static String unicode_islower_doc = + "S.islower() -> bool\n" + + "\n" + + "Return True if all cased characters in S are lowercase and there is\n" + + "at least one cased character in S, False otherwise."; + + public final static String unicode_isnumeric_doc = + "S.isnumeric() -> bool\n" + + "\n" + + "Return True if there are only numeric characters in S,\n" + + "False otherwise."; + + public final static String unicode_isspace_doc = + "S.isspace() -> bool\n" + + "\n" + + "Return True if all characters in S are whitespace\n" + + "and there is at least one character in S, False otherwise."; + + public final static String unicode_istitle_doc = + "S.istitle() -> bool\n" + + "\n" + + "Return True if S is a titlecased string and there is at least one\n" + + "character in S, i.e. upper- and titlecase characters may only\n" + + "follow uncased characters and lowercase characters only cased ones.\n" + + "Return False otherwise."; + + public final static String unicode_isupper_doc = + "S.isupper() -> bool\n" + + "\n" + + "Return True if all cased characters in S are uppercase and there is\n" + + "at least one cased character in S, False otherwise."; + + public final static String unicode_join_doc = + "S.join(sequence) -> unicode\n" + + "\n" + + "Return a string which is the concatenation of the strings in the\n" + + "sequence. The separator between elements is S."; + + public final static String unicode_ljust_doc = + "S.ljust(width[, fillchar]) -> int\n" + + "\n" + + "Return S left justified in a Unicode string of length width. Padding is\n" + + "done using the specified fill character (default is a space)."; + + public final static String unicode_lower_doc = + "S.lower() -> unicode\n" + + "\n" + + "Return a copy of the string S converted to lowercase."; + + public final static String unicode_lstrip_doc = + "S.lstrip([chars]) -> unicode\n" + + "\n" + + "Return a copy of the string S with leading whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is a str, it will be converted to unicode before stripping"; + + public final static String unicode_partition_doc = + "S.partition(sep) -> (head, sep, tail)\n" + + "\n" + + "Searches for the separator sep in S, and returns the part before it,\n" + + "the separator itself, and the part after it. If the separator is not\n" + + "found, returns S and two empty strings."; + + public final static String unicode_replace_doc = + "S.replace (old, new[, maxsplit]) -> unicode\n" + + "\n" + + "Return a copy of S with all occurrences of substring\n" + + "old replaced by new. If the optional argument maxsplit is\n" + + "given, only the first maxsplit occurrences are replaced."; + + public final static String unicode_rfind_doc = + "S.rfind(sub [,start [,end]]) -> int\n" + + "\n" + + "Return the highest index in S where substring sub is found,\n" + + "such that sub is contained within s[start:end]. Optional\n" + + "arguments start and end are interpreted as in slice notation.\n" + + "\n" + + "Return -1 on failure."; + + public final static String unicode_rindex_doc = + "S.rindex(sub [,start [,end]]) -> int\n" + + "\n" + + "Like S.rfind() but raise ValueError when the substring is not found."; + + public final static String unicode_rjust_doc = + "S.rjust(width[, fillchar]) -> unicode\n" + + "\n" + + "Return S right justified in a Unicode string of length width. Padding is\n" + + "done using the specified fill character (default is a space)."; + + public final static String unicode_rpartition_doc = + "S.rpartition(sep) -> (tail, sep, head)\n" + + "\n" + + "Searches for the separator sep in S, starting at the end of S, and returns\n" + + "the part before it, the separator itself, and the part after it. If the\n" + + "separator is not found, returns two empty strings and S."; + + public final static String unicode_rsplit_doc = + "S.rsplit([sep [,maxsplit]]) -> list of strings\n" + + "\n" + + "Return a list of the words in S, using sep as the\n" + + "delimiter string, starting at the end of the string and\n" + + "working to the front. If maxsplit is given, at most maxsplit\n" + + "splits are done. If sep is not specified, any whitespace string\n" + + "is a separator."; + + public final static String unicode_rstrip_doc = + "S.rstrip([chars]) -> unicode\n" + + "\n" + + "Return a copy of the string S with trailing whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is a str, it will be converted to unicode before stripping"; + + public final static String unicode_split_doc = + "S.split([sep [,maxsplit]]) -> list of strings\n" + + "\n" + + "Return a list of the words in S, using sep as the\n" + + "delimiter string. If maxsplit is given, at most maxsplit\n" + + "splits are done. If sep is not specified or is None,\n" + + "any whitespace string is a separator."; + + public final static String unicode_splitlines_doc = + "S.splitlines([keepends]]) -> list of strings\n" + + "\n" + + "Return a list of the lines in S, breaking at line boundaries.\n" + + "Line breaks are not included in the resulting list unless keepends\n" + + "is given and true."; + + public final static String unicode_startswith_doc = + "S.startswith(prefix[, start[, end]]) -> bool\n" + + "\n" + + "Return True if S starts with the specified prefix, False otherwise.\n" + + "With optional start, test S beginning at that position.\n" + + "With optional end, stop comparing S at that position.\n" + + "prefix can also be a tuple of strings to try."; + + public final static String unicode_strip_doc = + "S.strip([chars]) -> unicode\n" + + "\n" + + "Return a copy of the string S with leading and trailing\n" + + "whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is a str, it will be converted to unicode before stripping"; + + public final static String unicode_swapcase_doc = + "S.swapcase() -> unicode\n" + + "\n" + + "Return a copy of S with uppercase characters converted to lowercase\n" + + "and vice versa."; + + public final static String unicode_title_doc = + "S.title() -> unicode\n" + + "\n" + + "Return a titlecased version of S, i.e. words start with title case\n" + + "characters, all remaining cased characters have lower case."; + + public final static String unicode_translate_doc = + "S.translate(table) -> unicode\n" + + "\n" + + "Return a copy of the string S, where all characters have been mapped\n" + + "through the given translation table, which must be a mapping of\n" + + "Unicode ordinals to Unicode ordinals, Unicode strings or None.\n" + + "Unmapped characters are left untouched. Characters mapped to None\n" + + "are deleted."; + + public final static String unicode_upper_doc = + "S.upper() -> unicode\n" + + "\n" + + "Return a copy of S converted to uppercase."; + + public final static String unicode_zfill_doc = + "S.zfill(width) -> unicode\n" + + "\n" + + "Pad a numeric string x with zeros on the left, to fill a field\n" + + "of the specified width. The string x is never truncated."; + +} Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2008-12-22 03:29:57 UTC (rev 5787) +++ trunk/jython/src/org/python/core/PyString.java 2008-12-23 00:35:32 UTC (rev 5788) @@ -92,7 +92,7 @@ return str___str__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___str___doc) final PyString str___str__() { if (getClass() == PyString.class) { return this; @@ -104,6 +104,7 @@ return str___unicode__(); } + //XXX: need doc @ExposedMethod final PyUnicode str___unicode__() { return new PyUnicode(this); @@ -113,7 +114,7 @@ return str___len__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___len___doc) final int str___len__() { return string.length(); } @@ -122,6 +123,7 @@ return string; } + //XXX: need doc @ExposedMethod final String str_toString() { return toString(); @@ -141,7 +143,7 @@ return str___repr__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___repr___doc) final PyString str___repr__() { return new PyString(encode_UnicodeEscape(string, true)); } @@ -471,7 +473,7 @@ return false; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___getitem___doc) final PyObject str___getitem__(PyObject index) { PyObject ret = seq___finditem__(index); if (ret == null) { @@ -480,6 +482,7 @@ return ret; } + //XXX: need doc @ExposedMethod(defaults = "null") final PyObject str___getslice__(PyObject start, PyObject stop, PyObject step) { return seq___getslice__(start, stop, step); @@ -502,7 +505,7 @@ return str___eq__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___eq___doc) final PyObject str___eq__(PyObject other) { String s = coerce(other); if (s == null) @@ -514,7 +517,7 @@ return str___ne__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___ne___doc) final PyObject str___ne__(PyObject other) { String s = coerce(other); if (s == null) @@ -526,7 +529,7 @@ return str___lt__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___lt___doc) final PyObject str___lt__(PyObject other){ String s = coerce(other); if (s == null) @@ -538,7 +541,7 @@ return str___le__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___le___doc) final PyObject str___le__(PyObject other){ String s = coerce(other); if (s == null) @@ -550,7 +553,7 @@ return str___gt__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___gt___doc) final PyObject str___gt__(PyObject other){ String s = coerce(other); if (s == null) @@ -562,7 +565,7 @@ return str___ge__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___ge___doc) final PyObject str___ge__(PyObject other){ String s = coerce(other); if (s == null) @@ -580,7 +583,7 @@ return str___hash__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___hash___doc) final int str___hash__() { if (cached_hashcode == 0) cached_hashcode = string.hashCode(); @@ -651,7 +654,7 @@ return str___contains__(o); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___contains___doc) final boolean str___contains__(PyObject o) { if (!(o instanceof PyString)) throw Py.TypeError("'in <string>' requires string as left operand"); @@ -683,7 +686,7 @@ return str___mul__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___mul___doc) final PyObject str___mul__(PyObject o) { if (!o.isIndex()) { return null; @@ -696,7 +699,7 @@ return str___rmul__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___rmul___doc) final PyObject str___rmul__(PyObject o) { if (!o.isIndex()) { return null; @@ -708,7 +711,7 @@ return str___add__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___add___doc) final PyObject str___add__(PyObject other) { if (other instanceof PyUnicode) { return decode().__add__(other); @@ -720,7 +723,7 @@ return null; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___getnewargs___doc) final PyTuple str___getnewargs__() { return new PyTuple(new PyString(this.string)); } @@ -733,7 +736,7 @@ return str___mod__(other); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___mod___doc) public PyObject str___mod__(PyObject other){ StringFormatter fmt = new StringFormatter(string, false); return fmt.format(other); @@ -904,7 +907,7 @@ return str_lower(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_lower_doc) final String str_lower() { return string.toLowerCase(); } @@ -913,7 +916,7 @@ return str_upper(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_upper_doc) final String str_upper() { return string.toUpperCase(); } @@ -922,7 +925,7 @@ return str_title(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_title_doc) final String str_title() { char[] chars = string.toCharArray(); int n = chars.length; @@ -949,7 +952,7 @@ return str_swapcase(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_swapcase_doc) final String str_swapcase() { char[] chars = string.toCharArray(); int n=chars.length; @@ -973,7 +976,7 @@ return str_strip(sep); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_strip_doc) final String str_strip(String sep) { char[] chars = string.toCharArray(); int n=chars.length; @@ -1009,7 +1012,7 @@ return str_lstrip(sep); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_lstrip_doc) final String str_lstrip(String sep) { char[] chars = string.toCharArray(); int n=chars.length; @@ -1028,7 +1031,7 @@ return str_rstrip(sep); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_rstrip_doc) final String str_rstrip(String sep) { char[] chars = string.toCharArray(); int n=chars.length; @@ -1056,7 +1059,7 @@ return str_split(sep, maxsplit); } - @ExposedMethod(defaults = {"null", "-1"}) + @ExposedMethod(defaults = {"null", "-1"}, doc = BuiltinDocs.str_split_doc) final PyList str_split(String sep, int maxsplit) { if (sep != null) { if (sep.length() == 0) { @@ -1107,7 +1110,7 @@ return str_rsplit(sep, maxsplit); } - @ExposedMethod(defaults = {"null", "-1"}) + @ExposedMethod(defaults = {"null", "-1"}, doc = BuiltinDocs.str_rsplit_doc) final PyList str_rsplit(String sep, int maxsplit) { if (sep != null) { if (sep.length() == 0) { @@ -1169,7 +1172,7 @@ return str_partition(sepObj); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_partition_doc) final PyTuple str_partition(PyObject sepObj) { String sep; @@ -1220,7 +1223,7 @@ return str_rpartition(sepObj); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_rpartition_doc) final PyTuple str_rpartition(PyObject sepObj) { String sep; @@ -1338,7 +1341,7 @@ return str_splitlines(keepends); } - @ExposedMethod(defaults = "false") + @ExposedMethod(defaults = "false", doc = BuiltinDocs.str_splitlines_doc) final PyList str_splitlines(boolean keepends) { PyList list = new PyList(); @@ -1387,7 +1390,7 @@ return str_index(sub, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_index_doc) final int str_index(String sub, int start, PyObject end) { int index = str_find(sub, start, end); if (index == -1) @@ -1407,7 +1410,7 @@ return str_rindex(sub, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_rindex_doc) final int str_rindex(String sub, int start, PyObject end) { int index = str_rfind(sub, start, end); if(index == -1) @@ -1427,7 +1430,7 @@ return str_count(sub, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_count_doc) final int str_count(String sub, int start, PyObject end) { int[] indices = translateIndices(start, end); int n = sub.length(); @@ -1461,7 +1464,7 @@ return str_find(sub, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_find_doc) final int str_find(String sub, int start, PyObject end) { int[] indices = translateIndices(start, end); int index = string.indexOf(sub, indices[0]); @@ -1483,7 +1486,7 @@ return str_rfind(sub, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_rfind_doc) final int str_rfind(String sub, int start, PyObject end) { int[] indices = translateIndices(start, end); int index = string.lastIndexOf(sub, indices[1] - sub.length()); @@ -1690,7 +1693,7 @@ return str_ljust(width, padding); } - @ExposedMethod(defaults="null") + @ExposedMethod(defaults="null", doc = BuiltinDocs.str_ljust_doc) final String str_ljust(int width, String fillchar) { char pad = parse_fillchar("ljust", fillchar); int n = width-string.length(); @@ -1703,7 +1706,7 @@ return str_rjust(width, null); } - @ExposedMethod(defaults="null") + @ExposedMethod(defaults="null", doc = BuiltinDocs.str_rjust_doc) final String str_rjust(int width, String fillchar) { char pad = parse_fillchar("rjust", fillchar); int n = width-string.length(); @@ -1716,7 +1719,7 @@ return str_center(width, null); } - @ExposedMethod(defaults="null") + @ExposedMethod(defaults="null", doc = BuiltinDocs.str_center_doc) final String str_center(int width, String fillchar) { char pad = parse_fillchar("center", fillchar); int n = width-string.length(); @@ -1733,7 +1736,7 @@ return str_zfill(width); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_zfill_doc) final String str_zfill(int width) { String s = string; int n = s.length(); @@ -1767,7 +1770,7 @@ return str_expandtabs(tabsize); } - @ExposedMethod(defaults = "8") + @ExposedMethod(defaults = "8", doc = BuiltinDocs.str_expandtabs_doc) final String str_expandtabs(int tabsize) { String s = string; StringBuilder buf = new StringBuilder((int)(s.length()*1.5)); @@ -1798,7 +1801,7 @@ return str_capitalize(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_capitalize_doc) final String str_capitalize() { if (string.length() == 0) return string; @@ -1806,7 +1809,7 @@ return first.concat(string.substring(1).toLowerCase()); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_replace_doc) final PyString str_replace(PyObject oldPiece, PyObject newPiece, PyObject maxsplit) { if(!(oldPiece instanceof PyString) || !(newPiece instanceof PyString)) { throw Py.TypeError("str or unicode required for replace"); @@ -1853,7 +1856,7 @@ return str_join(seq); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_join_doc) final PyString str_join(PyObject obj) { PySequence seq = fastSequence(obj, ""); int seqLen = seq.__len__(); @@ -1987,7 +1990,7 @@ return str_startswith(prefix, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_startswith_doc) final boolean str_startswith(PyObject prefix, int start, PyObject end) { int[] indices = translateIndices(start, end); @@ -2029,7 +2032,7 @@ return str_endswith(suffix, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_endswith_doc) final boolean str_endswith(PyObject suffix, int start, PyObject end) { int[] indices = translateIndices(start, end); @@ -2097,7 +2100,7 @@ return str_translate(table, deletechars); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_translate_doc) final String str_translate(String table, String deletechars) { if (table.length() != 256) throw Py.ValueError( @@ -2161,7 +2164,7 @@ return str_islower(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_islower_doc) final boolean str_islower() { int n = string.length(); @@ -2185,7 +2188,7 @@ return str_isupper(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_isupper_doc) final boolean str_isupper() { int n = string.length(); @@ -2209,7 +2212,7 @@ return str_isalpha(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_isalpha_doc) final boolean str_isalpha() { int n = string.length(); @@ -2233,7 +2236,7 @@ return str_isalnum(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_isalnum_doc) final boolean str_isalnum() { int n = string.length(); @@ -2266,7 +2269,7 @@ return str_isdecimal(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_isdecimal_doc) final boolean str_isdecimal() { int n = string.length(); @@ -2297,7 +2300,7 @@ return str_isdigit(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_isdigit_doc) final boolean str_isdigit() { int n = string.length(); @@ -2321,7 +2324,7 @@ return str_isnumeric(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_isnumeric_doc) final boolean str_isnumeric() { int n = string.length(); @@ -2351,7 +2354,7 @@ return str_istitle(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_istitle_doc) final boolean str_istitle() { int n = string.length(); @@ -2387,7 +2390,7 @@ return str_isspace(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_isspace_doc) final boolean str_isspace() { int n = string.length(); @@ -2411,7 +2414,8 @@ return str_isunicode(); } - @ExposedMethod + //XXX: need doc + @ExposedMethod/*(doc = BuiltinDocs.unicode_isunicode_doc)*/ final boolean str_isunicode() { int n = string.length(); for (int i = 0; i < n; i++) { @@ -2434,7 +2438,7 @@ return str_encode(encoding, errors); } - @ExposedMethod(defaults = {"null", "null"}) + @ExposedMethod(defaults = {"null", "null"}, doc = BuiltinDocs.str_encode_doc) final String str_encode(String encoding, String errors) { return codecs.encode(this, encoding, errors); } @@ -2451,7 +2455,7 @@ return str_decode(encoding, errors); } - @ExposedMethod(defaults = {"null", "null"}) + @ExposedMethod(defaults = {"null", "null"}, doc = BuiltinDocs.str_decode_doc) final PyObject str_decode(String encoding, String errors) { return codecs.decode(this, encoding, errors); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-22 03:30:01
|
Revision: 5787 http://jython.svn.sourceforge.net/jython/?rev=5787&view=rev Author: cgroves Date: 2008-12-22 03:29:57 +0000 (Mon, 22 Dec 2008) Log Message: ----------- Move the test for assigning on top of a Java method to a class that doesn't cause a headless exception; don't worry about the message, just check that the TypeError is raised Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2008-12-22 03:21:46 UTC (rev 5786) +++ trunk/jython/Lib/test/test_java_integration.py 2008-12-22 03:29:57 UTC (rev 5787) @@ -331,20 +331,11 @@ def test_bad_input_exception(self): self.assertRaises(ValueError, __import__, '') -class ButtonTest(unittest.TestCase): - - def test_setLabel(self): - try: - b = Button() - except HeadlessException: - return # can't raise TestSkipped - try: - b.setLabel = 4 - except TypeError, e: - self.failUnless("can't assign to this attribute in java instance: setLabel" in str(e)) - class ColorTest(unittest.TestCase): + def test_assigning_over_method(self): + self.assertRaises(TypeError, setattr, Color.RED, "getRGB", 4) + def test_static_fields(self): self.assertEquals(Color(255, 0, 0), Color.RED) # The bean accessor for getRed should be active on instances, but the static field red @@ -468,7 +459,6 @@ JavaReservedNamesTest, PyReservedNamesTest, ImportTest, - ButtonTest, ColorTest, TreePathTest, BigDecimalTest, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-22 03:21:49
|
Revision: 5786 http://jython.svn.sourceforge.net/jython/?rev=5786&view=rev Author: cgroves Date: 2008-12-22 03:21:46 +0000 (Mon, 22 Dec 2008) Log Message: ----------- Use Generic.map to create genericized versions of all the newly HashMapped instances. Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/handler/RowIdHandler.java trunk/jython/src/org/python/core/PySystemState.java trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java trunk/jython/src/org/python/modules/_weakref/GlobalRef.java trunk/jython/src/org/python/modules/cPickle.java Modified: trunk/jython/src/com/ziclix/python/sql/handler/RowIdHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/handler/RowIdHandler.java 2008-12-22 02:18:12 UTC (rev 5785) +++ trunk/jython/src/com/ziclix/python/sql/handler/RowIdHandler.java 2008-12-22 03:21:46 UTC (rev 5786) @@ -12,13 +12,13 @@ import com.ziclix.python.sql.DataHandler; import java.util.Map; -import java.util.HashMap; import java.sql.Statement; import java.sql.SQLException; import java.lang.reflect.Method; import org.python.core.PyObject; import org.python.core.Py; +import org.python.util.Generic; /** * Handle the rowid methods since the API is not available until JDBC 3.0. @@ -29,7 +29,7 @@ */ public abstract class RowIdHandler extends FilterDataHandler { - private static Map ROWIDS = new HashMap(); + private static Map<Class<?>, Object> ROWIDS = Generic.map(); private static Object CHECKED = new Object(); public RowIdHandler(DataHandler handler) { @@ -52,7 +52,7 @@ */ public PyObject getRowId(Statement stmt) throws SQLException { - Class c = stmt.getClass(); + Class<?> c = stmt.getClass(); Object o = ROWIDS.get(c); if (o == null) { Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2008-12-22 02:18:12 UTC (rev 5785) +++ trunk/jython/src/org/python/core/PySystemState.java 2008-12-22 03:21:46 UTC (rev 5786) @@ -7,7 +7,6 @@ import java.net.URL; import java.net.URLDecoder; import java.security.AccessControlException; -import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.StringTokenizer; @@ -21,6 +20,7 @@ import org.python.core.packagecache.SysPackageManager; import org.python.modules.Setup; import org.python.modules.zipimport.zipimporter; +import org.python.util.Generic; /** * The "sys" module. @@ -31,7 +31,7 @@ public static final String PYTHON_CACHEDIR = "python.cachedir"; public static final String PYTHON_CACHEDIR_SKIP = "python.cachedir.skip"; protected static final String CACHEDIR_DEFAULT_NAME = "cachedir"; - + public static final String JYTHON_JAR = "jython.jar"; public static final String JYTHON_COMPLETE_JAR = "jython-complete.jar"; @@ -76,7 +76,7 @@ public static PackageManager packageManager; public static File cachedir; - + private static PyList defaultPath; private static PyList defaultArgv; private static PyObject defaultExecutable; @@ -86,7 +86,7 @@ public static PyObject exec_prefix = Py.EmptyString; private static boolean initialized = false; - + /** The arguments passed to this program on the command line. */ public PyList argv = new PyList(); @@ -127,7 +127,7 @@ public PyObject last_traceback = Py.None; public PyObject __name__ = new PyString("sys"); - + public PyObject __dict__; private int recursionlimit = 1000; @@ -170,7 +170,7 @@ __dict__.__setitem__("displayhook", __displayhook__); __dict__.__setitem__("excepthook", __excepthook__); } - + void reload() throws PyIgnoreMethodTag { __dict__.invoke("update", getType().fastGetDict()); } @@ -426,7 +426,7 @@ platform = new PyString("java" + version); } - private static void initRegistry(Properties preProperties, Properties postProperties, + private static void initRegistry(Properties preProperties, Properties postProperties, boolean standalone, String jarFileName) { if (registry != null) { @@ -641,8 +641,8 @@ private static PyList initArgv(String[] args) { PyList argv = new PyList(); if (args != null) { - for (int i=0; i<args.length; i++) { - argv.append(new PyString(args[i])); + for (String arg : args) { + argv.append(new PyString(arg)); } } return argv; @@ -697,15 +697,15 @@ } private static void initBuiltins(Properties props) { - builtinNames = new HashMap<String,String>(); + builtinNames = Generic.map(); // add the oddball builtins that are specially handled builtinNames.put("__builtin__", ""); builtinNames.put("sys", ""); // add builtins specified in the Setup.java file - for (int i=0; i < Setup.builtinModules.length; i++) - addBuiltin(Setup.builtinModules[i]); + for (String builtinModule : Setup.builtinModules) + addBuiltin(builtinModule); // add builtins specified in the registry file String builtinprop = props.getProperty("python.modules.builtin", ""); @@ -723,7 +723,7 @@ } public static String getBuiltin(String name) { - return (String)builtinNames.get(name); + return builtinNames.get(name); } private static PyList initPath(Properties props, boolean standalone, String jarFileName) { @@ -737,15 +737,15 @@ // standalone jython: add the /Lib directory inside JYTHON_JAR to the path addPaths(path, jarFileName + "/Lib"); } - + return path; } - + /** * Check if we are in standalone mode. - * + * * @param jarFileName The name of the jar file - * + * * @return <code>true</code> if we have a standalone .jar file, <code>false</code> otherwise. */ private static boolean isStandalone(String jarFileName) { @@ -888,7 +888,6 @@ if (o == Py.None) return; - PySystemState sys = Py.getThreadState().systemState; PySystemState.builtins.__setitem__("_", Py.None); Py.stdout.println(o.__repr__()); PySystemState.builtins.__setitem__("_", o); Modified: trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java =================================================================== --- trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java 2008-12-22 02:18:12 UTC (rev 5785) +++ trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java 2008-12-22 03:21:46 UTC (rev 5786) @@ -4,6 +4,7 @@ package org.python.core.packagecache; import org.python.core.Options; +import org.python.util.Generic; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -19,9 +20,6 @@ import java.net.URL; import java.net.URLConnection; import java.security.AccessControlException; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -37,7 +35,7 @@ /** * Message log method - hook. This default impl does nothing. - * + * * @param msg message text */ protected void message(String msg) { @@ -45,7 +43,7 @@ /** * Warning log method - hook. This default impl does nothing. - * + * * @param warn warning text */ protected void warning(String warn) { @@ -53,7 +51,7 @@ /** * Comment log method - hook. This default impl does nothing. - * + * * @param msg message text */ protected void comment(String msg) { @@ -61,7 +59,7 @@ /** * Debug log method - hook. This default impl does nothing. - * + * * @param msg message text */ protected void debug(String msg) { @@ -72,7 +70,7 @@ * by {@link #addJarToPackages} in order to filter out classes whose name * contains '$' (e.g. inner classes,...). Should be used or overriden by * derived classes too. Also to be used in {@link #doDir}. - * + * * @param name class/pkg name * @param pkg if true, name refers to a pkg * @return true if name must be filtered out @@ -87,7 +85,7 @@ * classes. Should be used or overriden by derived classes too. Also to be * used in {@link #doDir}. Access perms can be read with * {@link #checkAccess}. - * + * * @param name class name * @param acc class access permissions as int * @return true if name must be filtered out @@ -100,11 +98,11 @@ private Map<String,JarXEntry> jarfiles; - private static String vectorToString(List vec) { - int n = vec.size(); + private static String listToString(List<String> list) { + int n = list.size(); StringBuilder ret = new StringBuilder(); for (int i = 0; i < n; i++) { - ret.append((String) vec.get(i)); + ret.append(list.get(i)); if (i < n - 1) { ret.append(","); } @@ -114,7 +112,7 @@ // Add a single class from zipFile to zipPackages // Only add valid, public classes - private void addZipEntry(Map zipPackages, ZipEntry entry, + private void addZipEntry(Map<String, List<String>[]> zipPackages, ZipEntry entry, ZipInputStream zip) throws IOException { String name = entry.getName(); // System.err.println("entry: "+name); @@ -142,9 +140,9 @@ return; } - List[] vec = (List[]) zipPackages.get(packageName); + List<String>[] vec = zipPackages.get(packageName); if (vec == null) { - vec = new ArrayList[] { new ArrayList(), new ArrayList() }; + vec = new List[] { Generic.list(), Generic.list() }; zipPackages.put(packageName, vec); } int access = checkAccess(zip); @@ -156,8 +154,8 @@ } // Extract all of the packages in a single jarfile - private Map getZipPackages(InputStream jarin) throws IOException { - Map zipPackages = new HashMap(); + private Map<String, String> getZipPackages(InputStream jarin) throws IOException { + Map<String, List<String>[]> zipPackages = Generic.map(); ZipInputStream zip = new ZipInputStream(jarin); @@ -168,16 +166,17 @@ } // Turn each vector into a comma-separated String - for (Object key : zipPackages.keySet()) { - List[] vec = (List[]) zipPackages.get(key); - String classes = vectorToString(vec[0]); + Map<String, String> transformed = Generic.map(); + for (String key : zipPackages.keySet()) { + List<String>[] vec = zipPackages.get(key); + String classes = listToString(vec[0]); if (vec[1].size() > 0) { - classes += '@' + vectorToString(vec[1]); + classes += '@' + listToString(vec[1]); } - zipPackages.put(key, classes); + transformed.put(key, classes); } - return zipPackages; + return transformed; } /** @@ -247,7 +246,7 @@ return; } - Map zipPackages = null; + Map<String, String> zipPackages = null; long mtime = 0; String jarcanon = null; @@ -264,7 +263,7 @@ jarcanon = jarurl.toString(); } - entry = (JarXEntry) this.jarfiles.get(jarcanon); + entry = this.jarfiles.get(jarcanon); if ((entry == null || !(new File(entry.cachefile).exists())) && cache) { @@ -345,7 +344,7 @@ // Read in cache file storing package info for a single .jar // Return null and delete this cachefile if it is invalid - private Map readCacheFile(JarXEntry entry, String jarcanon) { + private Map<String, String> readCacheFile(JarXEntry entry, String jarcanon) { String cachefile = entry.cachefile; long mtime = entry.mtime; @@ -361,7 +360,7 @@ deleteCacheFile(cachefile); return null; } - Map packs = new HashMap(); + Map<String, String> packs = Generic.map(); try { while (true) { String packageName = istream.readUTF(); @@ -406,7 +405,7 @@ */ protected void initCache() { this.indexModified = false; - this.jarfiles = new HashMap(); + this.jarfiles = Generic.map(); try { DataInputStream istream = inOpenIndex(); @@ -419,8 +418,7 @@ String jarcanon = istream.readUTF(); String cachefile = istream.readUTF(); long mtime = istream.readLong(); - this.jarfiles - .put(jarcanon, new JarXEntry(cachefile, mtime)); + this.jarfiles.put(jarcanon, new JarXEntry(cachefile, mtime)); } } catch (EOFException eof) { ; Modified: trunk/jython/src/org/python/modules/_weakref/GlobalRef.java =================================================================== --- trunk/jython/src/org/python/modules/_weakref/GlobalRef.java 2008-12-22 02:18:12 UTC (rev 5785) +++ trunk/jython/src/org/python/modules/_weakref/GlobalRef.java 2008-12-22 03:21:46 UTC (rev 5786) @@ -5,7 +5,6 @@ import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; import java.util.ArrayList; -import java.util.HashMap; import java.util.Map; import java.util.List; @@ -13,6 +12,7 @@ import org.python.core.PyException; import org.python.core.PyList; import org.python.core.PyObject; +import org.python.util.Generic; public class GlobalRef extends WeakReference { @@ -27,7 +27,7 @@ private static RefReaperThread reaperThread; - private static Map objects = new HashMap(); + private static Map<GlobalRef, GlobalRef> objects = Generic.map(); static { initReaperThread(); @@ -122,7 +122,7 @@ } public static GlobalRef newInstance(PyObject object) { - GlobalRef ref = (GlobalRef)objects.get(new GlobalRef(object)); + GlobalRef ref = objects.get(new GlobalRef(object)); if (ref == null) { ref = new GlobalRef(object); objects.put(ref, ref); Modified: trunk/jython/src/org/python/modules/cPickle.java =================================================================== --- trunk/jython/src/org/python/modules/cPickle.java 2008-12-22 02:18:12 UTC (rev 5785) +++ trunk/jython/src/org/python/modules/cPickle.java 2008-12-22 03:21:46 UTC (rev 5786) @@ -13,7 +13,6 @@ package org.python.modules; import java.math.BigInteger; -import java.util.HashMap; import java.util.Map; import org.python.core.ClassDictInit; @@ -44,6 +43,7 @@ import org.python.core.codecs; import org.python.core.exceptions; import org.python.core.imp; +import org.python.util.Generic; /** * @@ -1512,11 +1512,8 @@ } + private static Map<PyObject,PyObject> classmap = Generic.map(); - - - private static Map<PyObject,PyObject> classmap = new HashMap<PyObject,PyObject>(); - final private static PyObject whichmodule(PyObject cls, PyObject clsname) { @@ -1705,7 +1702,7 @@ private IOFile file; - public Map<String,PyObject> memo = new HashMap<String,PyObject>(); + public Map<String,PyObject> memo = Generic.map(); /** * For the benefit of persistency modules written using pickle, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-22 02:18:15
|
Revision: 5785 http://jython.svn.sourceforge.net/jython/?rev=5785&view=rev Author: cgroves Date: 2008-12-22 02:18:12 +0000 (Mon, 22 Dec 2008) Log Message: ----------- Use PyJavaType(java.lang.Class) as the metatype for instances of PyJavaType wrapping a Java class. This exposes Class methods like getMethods and getFields through the instance. Modified Paths: -------------- trunk/jython/CoreExposed.includes trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyException.java trunk/jython/src/org/python/core/PyJavaType.java trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/core/PyReflectedFunction.java trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/modules/ArrayModule.java Modified: trunk/jython/CoreExposed.includes =================================================================== --- trunk/jython/CoreExposed.includes 2008-12-21 23:25:39 UTC (rev 5784) +++ trunk/jython/CoreExposed.includes 2008-12-22 02:18:12 UTC (rev 5785) @@ -19,6 +19,7 @@ org/python/core/PyFunction.class org/python/core/PyGenerator.class org/python/core/PyInteger.class +org/python/core/PyJavaType.class org/python/core/PyList.class org/python/core/PyLong.class org/python/core/PyMethod.class Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2008-12-21 23:25:39 UTC (rev 5784) +++ trunk/jython/src/org/python/core/Py.java 2008-12-22 02:18:12 UTC (rev 5785) @@ -923,8 +923,7 @@ stderr.println("Java Traceback:"); java.io.CharArrayWriter buf = new java.io.CharArrayWriter(); if (t instanceof PyException) { - ((PyException) t).super__printStackTrace( - new java.io.PrintWriter(buf)); + ((PyException)t).super__printStackTrace(new java.io.PrintWriter(buf)); } else { t.printStackTrace(new java.io.PrintWriter(buf)); } @@ -1551,7 +1550,6 @@ */ public static PyObject makeClass(String name, PyObject[] bases, PyObject dict) { PyFrame frame = getFrame(); - if (dict.__finditem__("__module__") == null) { PyObject module = frame.getglobal("__name__"); if (module != null) { Modified: trunk/jython/src/org/python/core/PyException.java =================================================================== --- trunk/jython/src/org/python/core/PyException.java 2008-12-21 23:25:39 UTC (rev 5784) +++ trunk/jython/src/org/python/core/PyException.java 2008-12-22 02:18:12 UTC (rev 5785) @@ -3,24 +3,20 @@ import java.io.*; /** - * A wrapper for all python exception. Note that the wellknown - * python exception are <b>not</b> subclasses of PyException. - * Instead the python exception class is stored in the - * <code>type</code> field and value or class instance is stored - * in the <code>value</code> field. + * A wrapper for all python exception. Note that the wellknown python exception are <b>not</b> + * subclasses of PyException. Instead the python exception class is stored in the <code>type</code> + * field and value or class instance is stored in the <code>value</code> field. */ - public class PyException extends RuntimeException { + /** - * The python exception class (for class exception) or - * identifier (for string exception). + * The python exception class (for class exception) or identifier (for string exception). */ public PyObject type; /** - * The exception instance (for class exception) or exception - * value (for string exception). + * The exception instance (for class exception) or exception value (for string exception). */ public PyObject value = Py.None; Modified: trunk/jython/src/org/python/core/PyJavaType.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaType.java 2008-12-21 23:25:39 UTC (rev 5784) +++ trunk/jython/src/org/python/core/PyJavaType.java 2008-12-22 02:18:12 UTC (rev 5785) @@ -16,10 +16,12 @@ import org.python.core.util.StringUtil; import org.python.expose.ExposeAsSuperclass; +import org.python.expose.ExposedMethod; import org.python.expose.ExposedType; import org.python.util.Generic; -public class PyJavaType extends PyType implements ExposeAsSuperclass { +@ExposedType(name = "javatype") +public class PyJavaType extends PyType { private final static Class<?>[] OO = {PyObject.class, PyObject.class}; @@ -35,6 +37,14 @@ super(TYPE == null ? fromClass(PyType.class) : TYPE); } + @ExposedMethod(defaults = "null") + final PyList javatype_mro(PyObject o) { + if (o == null) { + return new PyList(mro); + } + return new PyList(((PyJavaType)o).mro); + } + @Override public Class<?> getProxyType() { return PyObject.class.isAssignableFrom(underlying_class) ? null : underlying_class; @@ -48,6 +58,10 @@ @Override protected void checkSetattr() {} + protected boolean useMetatypeFirst(PyObject attr) { + return !(attr instanceof PyReflectedField || attr instanceof PyReflectedFunction); + } + @Override protected void init() { name = underlying_class.getName(); @@ -62,10 +76,14 @@ // their interfaces computeLinearMro(baseClass); } else { + javaProxy = underlying_class; + objtype = PyType.fromClass(Class.class); // Wrapped Java types fill in their mro first using their base class and then all of // their interfaces. if (baseClass == null) { base = PyType.fromClass(PyObject.class); + } else if(underlying_class == Class.class) { + base = PyType.fromClass(PyType.class); } else { base = PyType.fromClass(baseClass); } @@ -300,8 +318,9 @@ PyBuiltinCallable equals = new PyBuiltinMethodNarrow("__eq__", 1, 1) { @Override public PyObject __call__(PyObject o) { - Object oAsJava = o.__tojava__(self.getJavaProxy().getClass()); - return self.getJavaProxy().equals(oAsJava) ? Py.True : Py.False; + Object proxy = self.getJavaProxy(); + Object oAsJava = o.__tojava__(proxy.getClass()); + return proxy.equals(oAsJava) ? Py.True : Py.False; } }; dict.__setitem__("__eq__", new PyMethodDescr(this, equals)); Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2008-12-21 23:25:39 UTC (rev 5784) +++ trunk/jython/src/org/python/core/PyObject.java 2008-12-22 02:18:12 UTC (rev 5785) @@ -44,7 +44,7 @@ */ protected Object javaProxy; - private PyType objtype; + PyType objtype; @ExposedGet(name = "__class__") public PyType getType() { @@ -1007,7 +1007,7 @@ protected void mergeClassDict(PyDictionary accum, PyObject aClass) { // Merge in the type's dict (if any) aClass.mergeDictAttr(accum, "__dict__"); - + // Recursively merge in the base types' (if any) dicts PyObject bases = aClass.__findattr__("__bases__"); if (bases == null) { Modified: trunk/jython/src/org/python/core/PyReflectedFunction.java =================================================================== --- trunk/jython/src/org/python/core/PyReflectedFunction.java 2008-12-21 23:25:39 UTC (rev 5784) +++ trunk/jython/src/org/python/core/PyReflectedFunction.java 2008-12-22 02:18:12 UTC (rev 5785) @@ -46,10 +46,6 @@ return new PyMethod(this, container, wherefound); } - public boolean _doset(PyObject container) { - throw Py.TypeError("java function not settable: " + __name__); - } - public PyObject getDoc() { return __doc__; } Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2008-12-21 23:25:39 UTC (rev 5784) +++ trunk/jython/src/org/python/core/PyType.java 2008-12-22 02:18:12 UTC (rev 5785) @@ -133,6 +133,12 @@ } metatype = winner; } + // Use PyType as the metaclass for Python subclasses of Java classes rather than PyJavaType. + // Using PyJavaType as metaclass exposes the java.lang.Object methods on the type, which + // doesn't make sense for python subclasses. + if (metatype == PyType.fromClass(Class.class)) { + metatype = TYPE; + } if (bases_list.length == 0) { bases_list = new PyObject[] {object_type}; } @@ -997,6 +1003,7 @@ newtype = new PyJavaType(); } + // If filling in the type above filled the type under creation, use that one PyType type = class_to_type.get(c); if (type != null) { @@ -1041,11 +1048,10 @@ PyType metatype = getType(); PyObject metaattr = metatype.lookup(name); - PyObject res = null; - if (metaattr != null) { + if (metaattr != null && useMetatypeFirst(metaattr)) { if (metaattr.isDataDescr()) { - res = metaattr.__get__(this, metatype); + PyObject res = metaattr.__get__(this, metatype); if (res != null) return res; } @@ -1054,7 +1060,7 @@ PyObject attr = lookup(name); if (attr != null) { - res = attr.__get__(null, this); + PyObject res = attr.__get__(null, this); if (res != null) { return res; } @@ -1067,6 +1073,14 @@ return null; } + /** + * Returns true if the given attribute retrieved from an object's metatype should be used before + * looking for the object on the actual object. + */ + protected boolean useMetatypeFirst(PyObject attr) { + return true; + } + @ExposedMethod final void type___setattr__(PyObject name, PyObject value) { type___setattr__(asName(name), value); Modified: trunk/jython/src/org/python/modules/ArrayModule.java =================================================================== --- trunk/jython/src/org/python/modules/ArrayModule.java 2008-12-21 23:25:39 UTC (rev 5784) +++ trunk/jython/src/org/python/modules/ArrayModule.java 2008-12-22 02:18:12 UTC (rev 5785) @@ -11,7 +11,7 @@ * The python array module, plus jython extensions from jarray. */ public class ArrayModule implements ClassDictInit { - + public static PyString __doc__ = new PyString( "This module defines a new object type which can efficiently represent\n" + "an array of basic values: characters, integers, floating point\n" + @@ -42,16 +42,16 @@ "\n" + "ArrayType -- type object for array objects\n" ); - - public static void classDictInit(PyObject dict){ + + public static void classDictInit(PyObject dict) { dict.__setitem__("array", PyType.fromClass(PyArray.class)); dict.__setitem__("ArrayType", PyType.fromClass(PyArray.class)); } - + /* - * These are jython extensions (from jarray module). + * These are jython extensions (from jarray module). * Note that the argument order is consistent with - * python array module, but is reversed from jarray module. + * python array module, but is reversed from jarray module. */ public static PyArray zeros(char typecode, int n) { return PyArray.zeros(n, typecode); @@ -59,5 +59,5 @@ public static PyArray zeros(Class type, int n) { return PyArray.zeros(n, type); - } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-21 23:25:41
|
Revision: 5784 http://jython.svn.sourceforge.net/jython/?rev=5784&view=rev Author: fwierzbicki Date: 2008-12-21 23:25:39 +0000 (Sun, 21 Dec 2008) Log Message: ----------- Added fastGetDoc to expose __doc__ on builtin classes, so, for example help(str.title) Will get the __doc__ back for str.title. Modified Paths: -------------- trunk/jython/src/org/python/core/PyMethodDescr.java Modified: trunk/jython/src/org/python/core/PyMethodDescr.java =================================================================== --- trunk/jython/src/org/python/core/PyMethodDescr.java 2008-12-21 22:28:30 UTC (rev 5783) +++ trunk/jython/src/org/python/core/PyMethodDescr.java 2008-12-21 23:25:39 UTC (rev 5784) @@ -20,6 +20,11 @@ meth.setInfo(this); } + @ExposedGet(name = "__doc__") + public String fastGetDoc() { + return meth.fastGetDoc(); + } + public int getMaxargs() { return maxargs; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2008-12-21 22:28:33
|
Revision: 5783 http://jython.svn.sourceforge.net/jython/?rev=5783&view=rev Author: amak Date: 2008-12-21 22:28:30 +0000 (Sun, 21 Dec 2008) Log Message: ----------- 1. Fixed a bug whereby timeouts were not being honoured when recv()ing (http://bugs.jython.com/issue1154) 2. Fixed another (previously unreported) bug that resulted in an exception when switching from non-blocking to timeout mode. Modified Paths: -------------- trunk/jython/Lib/socket.py trunk/jython/Lib/test/test_socket.py Modified: trunk/jython/Lib/socket.py =================================================================== --- trunk/jython/Lib/socket.py 2008-12-19 17:02:10 UTC (rev 5782) +++ trunk/jython/Lib/socket.py 2008-12-21 22:28:30 UTC (rev 5783) @@ -6,8 +6,6 @@ XXX Restrictions: - Only INET sockets -- No asynchronous behavior -- No socket options - Can't do a very good gethostbyaddr() right... AMAK: 20050527: added socket timeouts AMAK: 20070515: Added non-blocking (asynchronous) support @@ -210,16 +208,6 @@ timeout = None mode = MODE_BLOCKING - def read(self, buf): - bytebuf = java.nio.ByteBuffer.wrap(buf) - count = self.jchannel.read(bytebuf) - return count - - def write(self, buf): - bytebuf = java.nio.ByteBuffer.wrap(buf) - count = self.jchannel.write(bytebuf) - return count - def getpeername(self): return (self.jsocket.getInetAddress().getHostAddress(), self.jsocket.getPort() ) @@ -230,6 +218,7 @@ if self.mode == MODE_NONBLOCKING: self.jchannel.configureBlocking(0) if self.mode == MODE_TIMEOUT: + self.jchannel.configureBlocking(1) self._timeout_millis = int(timeout*1000) self.jsocket.setSoTimeout(self._timeout_millis) @@ -321,6 +310,36 @@ def finish_connect(self): return self.jchannel.finishConnect() + def _do_read_net(self, buf): + # Need two separate implementations because the java.nio APIs do not support timeouts + return self.jsocket.getInputStream().read(buf) + + def _do_read_nio(self, buf): + bytebuf = java.nio.ByteBuffer.wrap(buf) + count = self.jchannel.read(bytebuf) + return count + + def _do_write_net(self, buf): + self.jsocket.getOutputStream().write(buf) + return len(buf) + + def _do_write_nio(self, buf): + bytebuf = java.nio.ByteBuffer.wrap(buf) + count = self.jchannel.write(bytebuf) + return count + + def read(self, buf): + if self.mode == MODE_TIMEOUT: + return self._do_read_net(buf) + else: + return self._do_read_nio(buf) + + def write(self, buf): + if self.mode == MODE_TIMEOUT: + return self._do_write_net(buf) + else: + return self._do_write_nio(buf) + class _server_socket_impl(_nio_impl): options = { @@ -824,6 +843,8 @@ if self.sock_impl.jchannel.isConnectionPending(): self.sock_impl.jchannel.finishConnect() numwritten = self.sock_impl.write(s) + if numwritten == 0 and self.mode == MODE_NONBLOCKING: + raise would_block_error() return numwritten except java.lang.Exception, jlx: raise _map_exception(jlx) Modified: trunk/jython/Lib/test/test_socket.py =================================================================== --- trunk/jython/Lib/test/test_socket.py 2008-12-19 17:02:10 UTC (rev 5782) +++ trunk/jython/Lib/test/test_socket.py 2008-12-21 22:28:30 UTC (rev 5783) @@ -714,6 +714,16 @@ def _testRecv(self): self.serv_conn.send(MSG) + def testRecvTimeoutMode(self): + # Do this test in timeout mode, because the code path is different + self.cli_conn.settimeout(10) + msg = self.cli_conn.recv(1024) + self.assertEqual(msg, MSG) + + def _testRecvTimeoutMode(self): + self.serv_conn.settimeout(10) + self.serv_conn.send(MSG) + def testOverFlowRecv(self): # Testing receive in chunks over TCP seg1 = self.cli_conn.recv(len(MSG) - 3) @@ -1270,14 +1280,14 @@ bufsize = 2 # Exercise the buffering code -class TCPTimeoutTest(SocketTCPTest): +class TCPServerTimeoutTest(SocketTCPTest): - def testTCPTimeout(self): + def testAcceptTimeout(self): def raise_timeout(*args, **kwargs): self.serv.settimeout(1.0) self.serv.accept() self.failUnlessRaises(socket.timeout, raise_timeout, - "Error generating a timeout exception (TCP)") + "TCP socket accept failed to generate a timeout exception (TCP)") def testTimeoutZero(self): ok = False @@ -1293,9 +1303,9 @@ if not ok: self.fail("accept() returned success when we did not expect it") -class TCPClientTimeoutTest(unittest.TestCase): +class TCPClientTimeoutTest(SocketTCPTest): - def testClientTimeout(self): + def testConnectTimeout(self): cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) cli.settimeout(0.1) host = '192.168.192.168' @@ -1310,8 +1320,45 @@ socket.timeout. This tries to connect to %s in the assumption that it isn't used, but if it is on your network this failure is bogus.''' % host) - + def testRecvTimeout(self): + def raise_timeout(*args, **kwargs): + cli_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + cli_sock.connect( (HOST, PORT) ) + cli_sock.settimeout(1) + cli_sock.recv(1024) + self.failUnlessRaises(socket.timeout, raise_timeout, + "TCP socket recv failed to generate a timeout exception (TCP)") + # Disable this test, but leave it present for documentation purposes + # socket timeouts only work for read and accept, not for write + # http://java.sun.com/j2se/1.4.2/docs/api/java/net/SocketTimeoutException.html + def estSendTimeout(self): + def raise_timeout(*args, **kwargs): + cli_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + cli_sock.connect( (HOST, PORT) ) + # First fill the socket + cli_sock.settimeout(1) + sent = 0 + while True: + bytes_sent = cli_sock.send(MSG) + sent += bytes_sent + self.failUnlessRaises(socket.timeout, raise_timeout, + "TCP socket send failed to generate a timeout exception (TCP)") + + def testSwitchModes(self): + cli_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + cli_sock.connect( (HOST, PORT) ) + # set non-blocking mode + cli_sock.setblocking(0) + # then set timeout mode + cli_sock.settimeout(1) + try: + cli_sock.send(MSG) + except Exception, x: + self.fail("Switching mode from non-blocking to timeout raised exception: %s" % x) + else: + pass + # # AMAK: 20070307 # Corrected the superclass of UDPTimeoutTest @@ -1539,7 +1586,7 @@ TestSupportedOptions, TestUnsupportedOptions, BasicTCPTest, - TCPTimeoutTest, + TCPServerTimeoutTest, TCPClientTimeoutTest, TestExceptions, TestInvalidUsage, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2008-12-19 17:02:14
|
Revision: 5782 http://jython.svn.sourceforge.net/jython/?rev=5782&view=rev Author: amak Date: 2008-12-19 17:02:10 +0000 (Fri, 19 Dec 2008) Log Message: ----------- Checking in support for UDP broadcast special constants, including INADDR_ANY and INADDR_BROADCAST. See this bug for details http://bugs.jython.org/issue1043 Modified Paths: -------------- trunk/jython/Lib/socket.py trunk/jython/Lib/test/test_socket.py Modified: trunk/jython/Lib/socket.py =================================================================== --- trunk/jython/Lib/socket.py 2008-12-19 07:45:01 UTC (rev 5781) +++ trunk/jython/Lib/socket.py 2008-12-19 17:02:10 UTC (rev 5782) @@ -148,17 +148,6 @@ SHUT_WR = 1 SHUT_RDWR = 2 -__all__ = ['AF_UNSPEC', 'AF_INET', 'AF_INET6', 'AI_PASSIVE', 'SOCK_DGRAM', - 'SOCK_RAW', 'SOCK_RDM', 'SOCK_SEQPACKET', 'SOCK_STREAM', 'SOL_SOCKET', - 'SO_BROADCAST', 'SO_ERROR', 'SO_KEEPALIVE', 'SO_LINGER', 'SO_OOBINLINE', - 'SO_RCVBUF', 'SO_REUSEADDR', 'SO_SNDBUF', 'SO_TIMEOUT', 'TCP_NODELAY', - 'SocketType', 'error', 'herror', 'gaierror', 'timeout', - 'getfqdn', 'gethostbyaddr', 'gethostbyname', 'gethostname', - 'socket', 'getaddrinfo', 'getdefaulttimeout', 'setdefaulttimeout', - 'has_ipv6', 'htons', 'htonl', 'ntohs', 'ntohl', - 'SHUT_RD', 'SHUT_WR', 'SHUT_RDWR', - ] - AF_UNSPEC = 0 AF_INET = 2 AF_INET6 = 23 @@ -183,6 +172,9 @@ SO_TIMEOUT = 128 TCP_NODELAY = 256 + +INADDR_ANY = "0.0.0.0" +INADDR_BROADCAST = "255.255.255.255" # Options with negative constants are not supported # They are being added here so that code that refers to them @@ -201,6 +193,18 @@ SO_TYPE = -1024 SO_USELOOPBACK = -2048 +__all__ = ['AF_UNSPEC', 'AF_INET', 'AF_INET6', 'AI_PASSIVE', 'SOCK_DGRAM', + 'SOCK_RAW', 'SOCK_RDM', 'SOCK_SEQPACKET', 'SOCK_STREAM', 'SOL_SOCKET', + 'SO_BROADCAST', 'SO_ERROR', 'SO_KEEPALIVE', 'SO_LINGER', 'SO_OOBINLINE', + 'SO_RCVBUF', 'SO_REUSEADDR', 'SO_SNDBUF', 'SO_TIMEOUT', 'TCP_NODELAY', + 'INADDR_ANY', 'INADDR_BROADCAST', + 'SocketType', 'error', 'herror', 'gaierror', 'timeout', + 'getfqdn', 'gethostbyaddr', 'gethostbyname', 'gethostname', + 'socket', 'getaddrinfo', 'getdefaulttimeout', 'setdefaulttimeout', + 'has_ipv6', 'htons', 'htonl', 'ntohs', 'ntohl', + 'SHUT_RD', 'SHUT_WR', 'SHUT_RDWR', + ] + class _nio_impl: timeout = None @@ -685,7 +689,7 @@ def _get_jsocket(self): return self.sock_impl.jsocket -def _unpack_address_tuple(address_tuple, for_tx=False): +def _unpack_address_tuple(address_tuple): # TODO: Upgrade to support the 4-tuples used for IPv6 addresses # which include flowinfo and scope_id. # To be upgraded in synch with getaddrinfo @@ -701,11 +705,6 @@ # currently broken hostname = hostname.encode() hostname = hostname.strip() - if hostname == "<broadcast>": - if for_tx: - hostname = "255.255.255.255" - else: - hostname = "0.0.0.0" return hostname, address_tuple[1] class _tcpsocket(_nonblocking_api_mixin): @@ -888,7 +887,9 @@ def bind(self, addr): try: assert not self.sock_impl - host, port = _unpack_address_tuple(addr) + host, port = _unpack_address_tuple(addr) + if host == "": + host = INADDR_ANY host_address = java.net.InetAddress.getByName(host) self.sock_impl = _datagram_socket_impl(port, host_address, self.pending_options[SO_REUSEADDR]) self._config() @@ -928,7 +929,9 @@ if not self.sock_impl: self.sock_impl = _datagram_socket_impl() self._config() - host, port = _unpack_address_tuple(addr, True) + host, port = _unpack_address_tuple(addr) + if host == "<broadcast>": + host = INADDR_BROADCAST byte_array = java.lang.String(data).getBytes('iso-8859-1') result = self.sock_impl.sendto(byte_array, host, port, flags) return result Modified: trunk/jython/Lib/test/test_socket.py =================================================================== --- trunk/jython/Lib/test/test_socket.py 2008-12-19 07:45:01 UTC (rev 5781) +++ trunk/jython/Lib/test/test_socket.py 2008-12-19 17:02:10 UTC (rev 5782) @@ -873,7 +873,7 @@ self.serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) def testBroadcast(self): - self.serv.bind( ("<broadcast>", self.PORT) ) + self.serv.bind( ("", self.PORT) ) msg = self.serv.recv(len(EIGHT_BIT_MSG)) self.assertEqual(msg, EIGHT_BIT_MSG) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-19 07:45:11
|
Revision: 5781 http://jython.svn.sourceforge.net/jython/?rev=5781&view=rev Author: pjenvey Date: 2008-12-19 07:45:01 +0000 (Fri, 19 Dec 2008) Log Message: ----------- support load_dynamic -- always fails Modified Paths: -------------- trunk/jython/src/org/python/modules/imp.java Modified: trunk/jython/src/org/python/modules/imp.java =================================================================== --- trunk/jython/src/org/python/modules/imp.java 2008-12-19 07:13:56 UTC (rev 5780) +++ trunk/jython/src/org/python/modules/imp.java 2008-12-19 07:45:01 UTC (rev 5781) @@ -129,6 +129,14 @@ return null; } + public static PyObject load_dynamic(String name, String pathname) { + return load_dynamic(name, pathname, null); + } + + public static PyObject load_dynamic(String name, String pathname, PyObject file) { + throw Py.ImportError("No module named " + name); + } + public static PyObject load_source(String modname, String filename) { return load_source(modname, filename, null); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-12-19 07:14:01
|
Revision: 5780 http://jython.svn.sourceforge.net/jython/?rev=5780&view=rev Author: zyasoft Date: 2008-12-19 07:13:56 +0000 (Fri, 19 Dec 2008) Log Message: ----------- For org.python.core and modules: * Replaced Vector and Hashtable with ArrayList and HashMap respectively. * Converted StringBuffer to StringBuilder where thread confined. Modified Paths: -------------- trunk/jython/src/org/python/core/AbstractArray.java trunk/jython/src/org/python/core/BaseSet.java trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyDictionary.java trunk/jython/src/org/python/core/PyFile.java trunk/jython/src/org/python/core/PyInstance.java trunk/jython/src/org/python/core/PyList.java trunk/jython/src/org/python/core/PyStringMap.java trunk/jython/src/org/python/core/PySystemState.java trunk/jython/src/org/python/core/PyTraceback.java trunk/jython/src/org/python/core/PyTuple.java trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/core/imp.java trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java trunk/jython/src/org/python/modules/_collections/PyDeque.java trunk/jython/src/org/python/modules/_weakref/GlobalRef.java trunk/jython/src/org/python/modules/binascii.java trunk/jython/src/org/python/modules/cPickle.java trunk/jython/src/org/python/modules/sre/PatternObject.java trunk/jython/src/org/python/modules/time/Time.java trunk/jython/src/org/python/modules/ucnhash.java Modified: trunk/jython/src/org/python/core/AbstractArray.java =================================================================== --- trunk/jython/src/org/python/core/AbstractArray.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/AbstractArray.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -533,7 +533,7 @@ * @see java.lang.Object#toString() */ public String toString() { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append("["); Object base = getArray(); Modified: trunk/jython/src/org/python/core/BaseSet.java =================================================================== --- trunk/jython/src/org/python/core/BaseSet.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/BaseSet.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -387,7 +387,7 @@ if (!ts.enterRepr(this)) { return name + "(...)"; } - StringBuffer buf = new StringBuffer(name).append("(["); + StringBuilder buf = new StringBuilder(name).append("(["); for (Iterator i = _set.iterator(); i.hasNext();) { buf.append(((PyObject)i.next()).__repr__().toString()); if (i.hasNext()) { Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/Py.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -1056,7 +1056,7 @@ } static String formatException(PyObject type, PyObject value, PyObject tb) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); if (PyException.isExceptionClass(type)) { String className = PyException.exceptionClassName(type); Modified: trunk/jython/src/org/python/core/PyDictionary.java =================================================================== --- trunk/jython/src/org/python/core/PyDictionary.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/PyDictionary.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -187,7 +187,7 @@ return "{...}"; } - StringBuffer buf = new StringBuffer("{"); + StringBuilder buf = new StringBuilder("{"); for (Entry<PyObject, PyObject> entry : table.entrySet()) { buf.append((entry.getKey()).__repr__().toString()); Modified: trunk/jython/src/org/python/core/PyFile.java =================================================================== --- trunk/jython/src/org/python/core/PyFile.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/PyFile.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -490,7 +490,7 @@ @ExposedMethod(names = {"__str__", "__repr__"}) final String file_toString() { - StringBuffer s = new StringBuffer("<"); + StringBuilder s = new StringBuilder("<"); if (file.closed()) { s.append("closed "); } else { Modified: trunk/jython/src/org/python/core/PyInstance.java =================================================================== --- trunk/jython/src/org/python/core/PyInstance.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/PyInstance.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -1,6 +1,5 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.core; -import java.util.Hashtable; /** * A python class instance. @@ -76,8 +75,6 @@ public PyInstance() {} - private static Hashtable primitiveMap; - public Object __tojava__(Class c) { if (c.isInstance(this)) return this; Modified: trunk/jython/src/org/python/core/PyList.java =================================================================== --- trunk/jython/src/org/python/core/PyList.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/PyList.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -417,7 +417,7 @@ if(!ts.enterRepr(this)) { return "[...]"; } - StringBuffer buf = new StringBuffer("["); + StringBuilder buf = new StringBuilder("["); int length = size(); PyObject[] array = getArray(); for(int i = 0; i < length - 1; i++) { Modified: trunk/jython/src/org/python/core/PyStringMap.java =================================================================== --- trunk/jython/src/org/python/core/PyStringMap.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/PyStringMap.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -131,7 +131,7 @@ if (!ts.enterRepr(this)) { return "{...}"; } - StringBuffer buf = new StringBuffer("{"); + StringBuilder buf = new StringBuilder("{"); for (Entry<Object, PyObject> entry : table.entrySet()) { Object key = entry.getKey(); if (key instanceof String) { Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/PySystemState.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -7,8 +7,7 @@ import java.net.URL; import java.net.URLDecoder; import java.security.AccessControlException; -import java.util.Enumeration; -import java.util.Hashtable; +import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.StringTokenizer; @@ -72,7 +71,7 @@ "Amsterdam.\n" + "All Rights Reserved.\n\n"); - private static Hashtable builtinNames; + private static Map<String,String> builtinNames; public static PyTuple builtin_module_names = null; public static PackageManager packageManager; @@ -160,22 +159,13 @@ __displayhook__ = new PySystemStateFunctions("displayhook", 10, 1, 1); __excepthook__ = new PySystemStateFunctions("excepthook", 30, 3, 3); - // This isn't quite right... if(builtins == null){ builtins = new PyStringMap(); __builtin__.fillWithBuiltins(builtins); } PyModule __builtin__ = new PyModule("__builtin__", builtins); modules.__setitem__("__builtin__", __builtin__); - __dict__ = new PyStringMap(); - - // This isn't right either, because __dict__ can be directly - // accessed from Python, for example: - // - // >>> sys.__dict__['settrace'] - // <java function settrace 81> - __dict__.invoke("update", getType().fastGetDict()); __dict__.__setitem__("displayhook", __displayhook__); __dict__.__setitem__("excepthook", __excepthook__); @@ -707,7 +697,7 @@ } private static void initBuiltins(Properties props) { - builtinNames = new Hashtable(); + builtinNames = new HashMap<String,String>(); // add the oddball builtins that are specially handled builtinNames.put("__builtin__", ""); @@ -724,10 +714,11 @@ addBuiltin(tok.nextToken()); int n = builtinNames.size(); - PyObject [] built_mod = new PyObject[n]; - Enumeration keys = builtinNames.keys(); - for (int i=0; i<n; i++) - built_mod[i] = Py.newString((String)keys.nextElement()); + PyObject [] built_mod = new PyObject[n]; + int i = 0; + for (String key : builtinNames.keySet()) { + built_mod[i++] = Py.newString(key); + } builtin_module_names = new PyTuple(built_mod); } Modified: trunk/jython/src/org/python/core/PyTraceback.java =================================================================== --- trunk/jython/src/org/python/core/PyTraceback.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/PyTraceback.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -101,7 +101,7 @@ return line; } - public void dumpStack(StringBuffer buf) { + public void dumpStack(StringBuilder buf) { buf.append(tracebackInfo()); if (tb_next != Py.None && tb_next != this) { ((PyTraceback)tb_next).dumpStack(buf); @@ -111,7 +111,7 @@ } public String dumpStack() { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append("Traceback (most recent call last):\n"); dumpStack(buf); return buf.toString(); Modified: trunk/jython/src/org/python/core/PyTuple.java =================================================================== --- trunk/jython/src/org/python/core/PyTuple.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/PyTuple.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -272,7 +272,7 @@ @ExposedMethod final String tuple___repr__() { - StringBuffer buf = new StringBuffer("("); + StringBuilder buf = new StringBuilder("("); PyObject[] array = getArray(); int arrayLen = size(); for (int i = 0; i < arrayLen-1; i++) { Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/PyType.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -651,7 +651,7 @@ } private static PyException mro_error(PyObject[][] to_merge, int[] remain) { - StringBuffer msg = new StringBuffer("Cannot create a consistent method resolution\n" + StringBuilder msg = new StringBuilder("Cannot create a consistent method resolution\n" + "order (MRO) for bases "); PyDictionary set = new PyDictionary(); for (int i = 0; i < to_merge.length; i++) { Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/imp.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -503,7 +503,7 @@ * @return the loaded module */ public static PyObject load(String name) { - return import_first(name, new StringBuffer()); + return import_first(name, new StringBuilder()); } /** @@ -560,7 +560,7 @@ * @return null or None */ private static PyObject import_next(PyObject mod, - StringBuffer parentNameBuffer, String name, String outerFullName, PyObject fromlist) { + StringBuilder parentNameBuffer, String name, String outerFullName, PyObject fromlist) { if (parentNameBuffer.length() > 0) { parentNameBuffer.append('.'); } @@ -594,7 +594,7 @@ // never returns null or None private static PyObject import_first(String name, - StringBuffer parentNameBuffer) { + StringBuilder parentNameBuffer) { PyObject ret = import_next(null, parentNameBuffer, name, null, null); if (ret == null || ret == Py.None) { throw Py.ImportError("No module named " + name); @@ -603,7 +603,7 @@ } - private static PyObject import_first(String name, StringBuffer parentNameBuffer, String fullName, PyObject fromlist) { + private static PyObject import_first(String name, StringBuilder parentNameBuffer, String fullName, PyObject fromlist) { PyObject ret = import_next(null, parentNameBuffer, name, fullName, fromlist); if (ret == null || ret == Py.None) { if (JavaImportHelper.tryAddPackage(fullName, fromlist)) { @@ -621,7 +621,7 @@ // never returns null or None // ??pending: check if result is really a module/jpkg/jclass? private static PyObject import_logic(PyObject mod, - StringBuffer parentNameBuffer, String dottedName, String fullName, PyObject fromlist) { + StringBuilder parentNameBuffer, String dottedName, String fullName, PyObject fromlist) { int dot = 0; int last_dot = 0; @@ -673,7 +673,7 @@ } else { firstName = name.substring(0, dot); } - StringBuffer parentNameBuffer = new StringBuffer(pkgMod != null ? pkgName : ""); + StringBuilder parentNameBuffer = new StringBuilder(pkgMod != null ? pkgName : ""); PyObject topMod = import_next(pkgMod, parentNameBuffer, firstName, name, fromlist); if (topMod == Py.None || topMod == null) { // Add None to sys.modules for submodule or subpackage names that aren't found, but @@ -682,7 +682,7 @@ if (topMod == null && pkgMod != null) { modules.__setitem__(parentNameBuffer.toString().intern(), Py.None); } - parentNameBuffer = new StringBuffer(""); + parentNameBuffer = new StringBuilder(""); // could throw ImportError topMod = import_first(firstName, parentNameBuffer, name, fromlist); } @@ -697,7 +697,7 @@ } if (fromlist != null && fromlist != Py.None) { - StringBuffer modNameBuffer = new StringBuffer(name); + StringBuilder modNameBuffer = new StringBuilder(name); for (PyObject submodName : fromlist.asIterable()) { if (mod.__findattr__(submodName.toString()) != null || submodName.toString().equals("*")) { Modified: trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java =================================================================== --- trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -20,8 +20,11 @@ import java.net.URLConnection; import java.security.AccessControlException; import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; +import java.util.HashMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -95,13 +98,13 @@ private boolean indexModified; - private Hashtable jarfiles; + private Map<String,JarXEntry> jarfiles; - private static String vectorToString(Vector vec) { + private static String vectorToString(List vec) { int n = vec.size(); - StringBuffer ret = new StringBuffer(); + StringBuilder ret = new StringBuilder(); for (int i = 0; i < n; i++) { - ret.append((String) vec.elementAt(i)); + ret.append((String) vec.get(i)); if (i < n - 1) { ret.append(","); } @@ -111,7 +114,7 @@ // Add a single class from zipFile to zipPackages // Only add valid, public classes - private void addZipEntry(Hashtable zipPackages, ZipEntry entry, + private void addZipEntry(Map zipPackages, ZipEntry entry, ZipInputStream zip) throws IOException { String name = entry.getName(); // System.err.println("entry: "+name); @@ -139,22 +142,22 @@ return; } - Vector[] vec = (Vector[]) zipPackages.get(packageName); + List[] vec = (List[]) zipPackages.get(packageName); if (vec == null) { - vec = new Vector[] { new Vector(), new Vector() }; + vec = new ArrayList[] { new ArrayList(), new ArrayList() }; zipPackages.put(packageName, vec); } int access = checkAccess(zip); if ((access != -1) && !filterByAccess(name, access)) { - vec[0].addElement(className); + vec[0].add(className); } else { - vec[1].addElement(className); + vec[1].add(className); } } // Extract all of the packages in a single jarfile - private Hashtable getZipPackages(InputStream jarin) throws IOException { - Hashtable zipPackages = new Hashtable(); + private Map getZipPackages(InputStream jarin) throws IOException { + Map zipPackages = new HashMap(); ZipInputStream zip = new ZipInputStream(jarin); @@ -165,9 +168,8 @@ } // Turn each vector into a comma-separated String - for (Enumeration e = zipPackages.keys(); e.hasMoreElements();) { - Object key = e.nextElement(); - Vector[] vec = (Vector[]) zipPackages.get(key); + for (Object key : zipPackages.keySet()) { + List[] vec = (List[]) zipPackages.get(key); String classes = vectorToString(vec[0]); if (vec[1].size() > 0) { classes += '@' + vectorToString(vec[1]); @@ -245,7 +247,7 @@ return; } - Hashtable zipPackages = null; + Map zipPackages = null; long mtime = 0; String jarcanon = null; @@ -327,10 +329,10 @@ } - private void addPackages(Hashtable zipPackages, String jarfile) { - for (Enumeration e = zipPackages.keys(); e.hasMoreElements();) { - String pkg = (String) e.nextElement(); - String classes = (String) zipPackages.get(pkg); + private void addPackages(Map<String,String> zipPackages, String jarfile) { + for (Entry<String,String> entry : zipPackages.entrySet()) { + String pkg = entry.getKey(); + String classes = entry.getValue(); int idx = classes.indexOf('@'); if (idx >= 0 && Options.respectJavaAccessibility) { @@ -343,7 +345,7 @@ // Read in cache file storing package info for a single .jar // Return null and delete this cachefile if it is invalid - private Hashtable readCacheFile(JarXEntry entry, String jarcanon) { + private Map readCacheFile(JarXEntry entry, String jarcanon) { String cachefile = entry.cachefile; long mtime = entry.mtime; @@ -359,7 +361,7 @@ deleteCacheFile(cachefile); return null; } - Hashtable packs = new Hashtable(); + Map packs = new HashMap(); try { while (true) { String packageName = istream.readUTF(); @@ -380,16 +382,15 @@ // Write a cache file storing package info for a single .jar private void writeCacheFile(JarXEntry entry, String jarcanon, - Hashtable zipPackages, boolean brandNew) { + Map<String,String> zipPackages, boolean brandNew) { try { DataOutputStream ostream = outCreateCacheFile(entry, brandNew); ostream.writeUTF(jarcanon); ostream.writeLong(entry.mtime); comment("rewriting cachefile for '" + jarcanon + "'"); - for (Enumeration e = zipPackages.keys(); e.hasMoreElements();) { - String packageName = (String) e.nextElement(); - String classes = (String) zipPackages.get(packageName); + for (String packageName : zipPackages.keySet()) { + String classes = zipPackages.get(packageName); ostream.writeUTF(packageName); ostream.writeUTF(classes); } @@ -405,7 +406,7 @@ */ protected void initCache() { this.indexModified = false; - this.jarfiles = new Hashtable(); + this.jarfiles = new HashMap(); try { DataInputStream istream = inOpenIndex(); @@ -436,22 +437,22 @@ * outOpenIndex(). */ public void saveCache() { - if (this.jarfiles == null || !this.indexModified) { + if (jarfiles == null || !indexModified) { return; } - this.indexModified = false; + indexModified = false; comment("writing modified index file"); try { DataOutputStream ostream = outOpenIndex(); - for (Enumeration e = this.jarfiles.keys(); e.hasMoreElements();) { - String jarcanon = (String) e.nextElement(); - JarXEntry entry = (JarXEntry) this.jarfiles.get(jarcanon); + for (Entry<String,JarXEntry> entry : jarfiles.entrySet()) { + String jarcanon = entry.getKey(); + JarXEntry xentry = entry.getValue(); ostream.writeUTF(jarcanon); - ostream.writeUTF(entry.cachefile); - ostream.writeLong(entry.mtime); + ostream.writeUTF(xentry.cachefile); + ostream.writeLong(xentry.mtime); } ostream.close(); } catch (IOException ioe) { Modified: trunk/jython/src/org/python/modules/_collections/PyDeque.java =================================================================== --- trunk/jython/src/org/python/modules/_collections/PyDeque.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/modules/_collections/PyDeque.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -228,7 +228,7 @@ if (!ts.enterRepr(this)) { return "[...]"; } - StringBuffer buf = new StringBuffer("deque").append("(["); + StringBuilder buf = new StringBuilder("deque").append("(["); for (Node tmp = header.right; tmp != header; tmp = tmp.right) { buf.append(tmp.data.__repr__().toString()); if (tmp.right != header) { Modified: trunk/jython/src/org/python/modules/_weakref/GlobalRef.java =================================================================== --- trunk/jython/src/org/python/modules/_weakref/GlobalRef.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/modules/_weakref/GlobalRef.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -4,9 +4,10 @@ import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import java.util.Vector; +import java.util.List; import org.python.core.Py; import org.python.core.PyException; @@ -20,7 +21,7 @@ /** Whether the hash value was calculated by the underlying object. */ boolean realHash; - private Vector references = new Vector(); + private List references = new ArrayList(); private static ReferenceQueue referenceQueue = new ReferenceQueue(); @@ -59,11 +60,11 @@ public synchronized void add(AbstractReference ref) { Reference r = new WeakReference(ref); - references.addElement(r); + references.add(r); } private final AbstractReference getReferenceAt(int idx) { - WeakReference wref = (WeakReference)references.elementAt(idx); + WeakReference wref = (WeakReference)references.get(idx); return (AbstractReference)wref.get(); } @@ -75,7 +76,7 @@ for (int i = references.size() - 1; i >= 0; i--) { AbstractReference r = getReferenceAt(i); if (r == null) { - references.removeElementAt(i); + references.remove(i); } else if (r.callback == null && r.getClass() == cls) { return r; } @@ -90,7 +91,7 @@ for (int i = references.size() - 1; i >= 0; i--) { AbstractReference r = getReferenceAt(i); if (r == null) { - references.removeElementAt(i); + references.remove(i); } else { r.call(); } @@ -101,20 +102,20 @@ for (int i = references.size() - 1; i >= 0; i--) { AbstractReference r = getReferenceAt(i); if (r == null) { - references.removeElementAt(i); + references.remove(i); } } return references.size(); } synchronized public PyList refs() { - Vector list = new Vector(); + List list = new ArrayList(); for (int i = references.size() - 1; i >= 0; i--) { AbstractReference r = getReferenceAt(i); if (r == null) { - references.removeElementAt(i); + references.remove(i); } else { - list.addElement(r); + list.add(r); } } return new PyList(list); Modified: trunk/jython/src/org/python/modules/binascii.java =================================================================== --- trunk/jython/src/org/python/modules/binascii.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/modules/binascii.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -279,7 +279,7 @@ if (ascii_data.length() == 0) return new PyString(""); - StringBuffer bin_data = new StringBuffer(); + StringBuilder bin_data = new StringBuilder(); char this_ch; int i; @@ -357,7 +357,7 @@ throw new PyException(Error, "At most 45 bytes at once"); } - StringBuffer ascii_data = new StringBuffer(); + StringBuilder ascii_data = new StringBuilder(); // Store the length */ ascii_data.append((char)(' ' + (bin_len & 077))); @@ -426,7 +426,7 @@ int ascii_len = ascii_data.length(); int bin_len = 0; - StringBuffer bin_data = new StringBuffer(); + StringBuilder bin_data = new StringBuilder(); for(int i = 0; ascii_len > 0 ; ascii_len--, i++) { // Skip some punctuation @@ -487,7 +487,7 @@ char this_ch; int leftchar = 0; - StringBuffer ascii_data = new StringBuffer(); + StringBuilder ascii_data = new StringBuilder(); int bin_len = bin_data.length(); if (bin_len > BASE64_MAXBIN) { @@ -539,7 +539,7 @@ int len = ascii_data.length(); - StringBuffer bin_data = new StringBuffer(); + StringBuilder bin_data = new StringBuilder(); for(int i = 0; len > 0 ; len--, i++) { // Get the byte and look it up @@ -585,7 +585,7 @@ static public String rlecode_hqx(String in_data) { int len = in_data.length(); - StringBuffer out_data = new StringBuffer(); + StringBuilder out_data = new StringBuilder(); for (int in=0; in < len; in++) { char ch = in_data.charAt(in); @@ -632,7 +632,7 @@ int len = bin_data.length(); - StringBuffer ascii_data = new StringBuffer(); + StringBuilder ascii_data = new StringBuilder(); for(int i = 0; len > 0; len--, i++) { // Shift into our buffer, and output any 6bits ready @@ -677,7 +677,7 @@ if (in_len == 0) return ""; - StringBuffer out_data = new StringBuffer(); + StringBuilder out_data = new StringBuilder(); // Handle first byte separately (since we have to get angry // in case of an orphaned RLE code). @@ -837,7 +837,7 @@ public static PyString b2a_hex(String argbuf) { int arglen = argbuf.length(); - StringBuffer retbuf = new StringBuffer(arglen*2); + StringBuilder retbuf = new StringBuilder(arglen*2); /* make hex version of string, taken from shamodule.c */ for (int i = 0; i < arglen; i++) { @@ -874,7 +874,7 @@ if (arglen % 2 != 0) throw Py.TypeError("Odd-length string"); - StringBuffer retbuf = new StringBuffer(arglen/2); + StringBuilder retbuf = new StringBuilder(arglen/2); for (int i = 0; i < arglen; i += 2) { int top = Character.digit(argbuf.charAt(i), 16); @@ -893,7 +893,7 @@ final private static char[] upper_hexdigit = "0123456789ABCDEF".toCharArray(); - private static StringBuffer qpEscape(StringBuffer sb, char c) + private static StringBuilder qpEscape(StringBuilder sb, char c) { sb.append('='); sb.append(upper_hexdigit[(c >>> 4) & 0xF]); @@ -921,7 +921,7 @@ { ArgParser ap = new ArgParser("a2b_qp", arg, kws, new String[] {"s", "header"}); String s = ap.getString(0); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); boolean header = getIntFlagAsBool(ap, 1, 0, "an integer is required"); if (header) @@ -979,7 +979,7 @@ lineEnd = "\n"; s = RN_TO_N.matcher(s).replaceAll("\n"); } - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int count = 0; for (int i=0, m=s.length(); i<m; i++) { char c = s.charAt(i); Modified: trunk/jython/src/org/python/modules/cPickle.java =================================================================== --- trunk/jython/src/org/python/modules/cPickle.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/modules/cPickle.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -13,7 +13,8 @@ package org.python.modules; import java.math.BigInteger; -import java.util.Hashtable; +import java.util.HashMap; +import java.util.Map; import org.python.core.ClassDictInit; import org.python.core.Py; @@ -746,7 +747,7 @@ // Use any python object as a file. static class ObjectIOFile implements IOFile { char[] charr = new char[1]; - StringBuffer buff = new StringBuffer(); + StringBuilder buff = new StringBuilder(); PyObject write; PyObject read; PyObject readline; @@ -1514,12 +1515,12 @@ - private static Hashtable classmap = new Hashtable(); + private static Map<PyObject,PyObject> classmap = new HashMap<PyObject,PyObject>(); final private static PyObject whichmodule(PyObject cls, PyObject clsname) { - PyObject name = (PyObject)classmap.get(cls); + PyObject name = classmap.get(cls); if (name != null) return name; @@ -1704,7 +1705,7 @@ private IOFile file; - public Hashtable memo = new Hashtable(); + public Map<String,PyObject> memo = new HashMap<String,PyObject>(); /** * For the benefit of persistency modules written using pickle, @@ -2193,7 +2194,7 @@ final private void load_get() { String py_str = file.readlineNoNl(); - PyObject value = (PyObject)memo.get(py_str); + PyObject value = memo.get(py_str); if (value == null) throw new PyException(BadPickleGet, py_str); push(value); @@ -2201,7 +2202,7 @@ final private void load_binget() { String py_key = String.valueOf((int)file.read(1).charAt(0)); - PyObject value = (PyObject)memo.get(py_key); + PyObject value = memo.get(py_key); if (value == null) throw new PyException(BadPickleGet, py_key); push(value); @@ -2210,7 +2211,7 @@ final private void load_long_binget() { int i = read_binint(); String py_key = String.valueOf(i); - PyObject value = (PyObject)memo.get(py_key); + PyObject value = memo.get(py_key); if (value == null) throw new PyException(BadPickleGet, py_key); push(value); Modified: trunk/jython/src/org/python/modules/sre/PatternObject.java =================================================================== --- trunk/jython/src/org/python/modules/sre/PatternObject.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/modules/sre/PatternObject.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -246,7 +246,7 @@ SRE_STATE state = new SRE_STATE(string, start, end, flags); - Vector list = new Vector(); + final List list = new ArrayList(); while (state.start <= state.end) { state.state_reset(); @@ -271,7 +271,7 @@ break; } - list.addElement(item); + list.add(item); if (state.ptr == state.start) state.start = state.ptr + 1; Modified: trunk/jython/src/org/python/modules/time/Time.java =================================================================== --- trunk/jython/src/org/python/modules/time/Time.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/modules/time/Time.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -411,7 +411,7 @@ } public static PyString asctime(PyTuple tup) { - StringBuffer buf = new StringBuffer(25); + StringBuilder buf = new StringBuilder(25); buf.append(enshortdays[item(tup, 6)]).append(' '); buf.append(enshortmonths[item(tup, 1)]).append(' '); int dayOfMonth = item(tup, 2); Modified: trunk/jython/src/org/python/modules/ucnhash.java =================================================================== --- trunk/jython/src/org/python/modules/ucnhash.java 2008-12-19 06:00:48 UTC (rev 5779) +++ trunk/jython/src/org/python/modules/ucnhash.java 2008-12-19 07:13:56 UTC (rev 5780) @@ -163,7 +163,7 @@ int end = worddata.length; if (idx < wordoffs.length-1) end = wordoffs[idx+1]; - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (int i = offset; i < end; i++) buf.append(charmap[worddata[i]]); return buf.toString(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-12-19 06:00:50
|
Revision: 5779 http://jython.svn.sourceforge.net/jython/?rev=5779&view=rev Author: zyasoft Date: 2008-12-19 06:00:48 +0000 (Fri, 19 Dec 2008) Log Message: ----------- Enabled ClassDictInit modules to set their __name__ so that it matches the name part of name:class in org.python.modules.Setup (or equivalently registry setting python.modules.builtin). This fixes introspection issues where __import__(name).__name__ != name. Modified Paths: -------------- trunk/jython/Lib/test/test_builtin_jy.py trunk/jython/src/org/python/core/PyJavaType.java trunk/jython/src/org/python/modules/_newmodule.java trunk/jython/src/org/python/modules/_weakref/WeakrefModule.java trunk/jython/src/org/python/modules/random/RandomModule.java trunk/jython/src/org/python/modules/time/Time.java Modified: trunk/jython/Lib/test/test_builtin_jy.py =================================================================== --- trunk/jython/Lib/test/test_builtin_jy.py 2008-12-18 20:12:14 UTC (rev 5778) +++ trunk/jython/Lib/test/test_builtin_jy.py 2008-12-19 06:00:48 UTC (rev 5779) @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +1# -*- coding: utf-8 -*- import sys import unittest import test.test_support @@ -157,6 +157,18 @@ exec code in ns self.assertEqual(foo, ns['a']) +class ModuleNameTest(unittest.TestCase): + """Tests that the module when imported has the same __name__""" + + def test_names(self): + for name in sys.builtin_module_names: + if name != '_jython' and name not in ('time', '_random', 'array', '_collections', '_ast'): + module = __import__(name) + self.assertEqual(name, module.__name__) + + + + def test_main(): test.test_support.run_unittest(BuiltinTest, LoopTest, @@ -167,7 +179,9 @@ ReprTest, CallableTest, ConversionTest, - ExecEvalTest) + ExecEvalTest, + ModuleNameTest, + ) if __name__ == "__main__": test_main() Modified: trunk/jython/src/org/python/core/PyJavaType.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaType.java 2008-12-18 20:12:14 UTC (rev 5778) +++ trunk/jython/src/org/python/core/PyJavaType.java 2008-12-19 06:00:48 UTC (rev 5779) @@ -281,6 +281,11 @@ try { Method m = underlying_class.getMethod("classDictInit", PyObject.class); m.invoke(null, dict); + // allow the class to override its name after it is loaded + PyObject nameSpecified = dict.__finditem__("__name__"); + if (nameSpecified != null) { + name = nameSpecified.toString(); + } } catch (Exception exc) { throw Py.JavaError(exc); } Modified: trunk/jython/src/org/python/modules/_newmodule.java =================================================================== --- trunk/jython/src/org/python/modules/_newmodule.java 2008-12-18 20:12:14 UTC (rev 5778) +++ trunk/jython/src/org/python/modules/_newmodule.java 2008-12-19 06:00:48 UTC (rev 5779) @@ -1,6 +1,7 @@ /* Copyright (c) 2001, 2003 Finn Bock, Samuele Pedroni */ package org.python.modules; +import org.python.core.ClassDictInit; import org.python.core.Py; import org.python.core.PyClass; import org.python.core.PyObject; @@ -11,8 +12,13 @@ * The internal new module; just provides a hack for new.classobj. * */ -public class _newmodule { +public class _newmodule implements ClassDictInit { + public static void classDictInit(PyObject dict) + { + dict.__setitem__("__name__", Py.newString("_new")); + } + public static PyObject classobj(String name, PyTuple bases, PyObject dict) { // XXX: Hack to return new style classes (originally from // r4225). types.ClassType (PyClass) should be doing this Modified: trunk/jython/src/org/python/modules/_weakref/WeakrefModule.java =================================================================== --- trunk/jython/src/org/python/modules/_weakref/WeakrefModule.java 2008-12-18 20:12:14 UTC (rev 5778) +++ trunk/jython/src/org/python/modules/_weakref/WeakrefModule.java 2008-12-19 06:00:48 UTC (rev 5779) @@ -20,6 +20,7 @@ public static void classDictInit(PyObject dict) { dict.__setitem__("__doc__", __doc__); + dict.__setitem__("__name__", Py.newString("_weakref")); dict.__setitem__("ref", ReferenceType.TYPE); dict.__setitem__("ReferenceType", ReferenceType.TYPE); dict.__setitem__("ProxyType", ProxyType.TYPE); Modified: trunk/jython/src/org/python/modules/random/RandomModule.java =================================================================== --- trunk/jython/src/org/python/modules/random/RandomModule.java 2008-12-18 20:12:14 UTC (rev 5778) +++ trunk/jython/src/org/python/modules/random/RandomModule.java 2008-12-19 06:00:48 UTC (rev 5779) @@ -9,6 +9,8 @@ private RandomModule() {} public static void classDictInit(PyObject dict) { + dict.invoke("clear"); dict.__setitem__("Random", PyRandom.TYPE); + dict.__setitem__("__name__", Py.newString("_random")); } } Modified: trunk/jython/src/org/python/modules/time/Time.java =================================================================== --- trunk/jython/src/org/python/modules/time/Time.java 2008-12-18 20:12:14 UTC (rev 5778) +++ trunk/jython/src/org/python/modules/time/Time.java 2008-12-19 06:00:48 UTC (rev 5779) @@ -112,6 +112,7 @@ dict.__setitem__("time", new TimeFunctions("time", 0, 0)); dict.__setitem__("clock", new TimeFunctions("clock", 1, 0)); dict.__setitem__("struct_time", PyTimeTuple.TYPE); + dict.__setitem__("__name__", Py.newString("time")); // calculate the static variables tzname, timezone, altzone, daylight TimeZone tz = TimeZone.getDefault(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2008-12-18 20:12:23
|
Revision: 5778 http://jython.svn.sourceforge.net/jython/?rev=5778&view=rev Author: amak Date: 2008-12-18 20:12:14 +0000 (Thu, 18 Dec 2008) Log Message: ----------- Added unit test to explicitly check for selecting on socket.fileno(). Related to a bug in 2.2, as reported in http://bugs.jython.org/issue1211 Modified Paths: -------------- trunk/jython/Lib/test/test_select.py Modified: trunk/jython/Lib/test/test_select.py =================================================================== --- trunk/jython/Lib/test/test_select.py 2008-12-18 17:43:35 UTC (rev 5777) +++ trunk/jython/Lib/test/test_select.py 2008-12-18 20:12:14 UTC (rev 5778) @@ -178,6 +178,18 @@ else: self.fail("Registering blocking socket should have raised select.error") + def testSelectOnSocketFileno(self): + self.cli_conn = self.serv.accept() + + def _testSelectOnSocketFileno(self): + self.cli.setblocking(0) + self.cli.connect( (self.HOST, self.PORT) ) + return + try: + rfd, wfd, xfd = select.select([self.cli.fileno()], [], [], 1) + except Exception, x: + self.fail("Selecting on socket.fileno() should not have raised exception: %s" % str(x)) + class TestPipes(unittest.TestCase): verbose = 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2008-12-18 17:43:39
|
Revision: 5777 http://jython.svn.sourceforge.net/jython/?rev=5777&view=rev Author: amak Date: 2008-12-18 17:43:35 +0000 (Thu, 18 Dec 2008) Log Message: ----------- Restoring an important line that got lost back r3251, which checked if the object passed to _getselectable() was actually already a SelectableChannel. Added unit test to explicitly check for same. This was illustrated by a failure in the telnetlib module, as reported in http://bugs.jython.org/issue1211 Modified Paths: -------------- branches/Release_2_2maint/jython/Lib/select.py branches/Release_2_2maint/jython/Lib/test/test_select.py Modified: branches/Release_2_2maint/jython/Lib/select.py =================================================================== --- branches/Release_2_2maint/jython/Lib/select.py 2008-12-18 11:05:16 UTC (rev 5776) +++ branches/Release_2_2maint/jython/Lib/select.py 2008-12-18 17:43:35 UTC (rev 5777) @@ -43,6 +43,8 @@ POLLNVAL = 32 def _getselectable(selectable_object): + if isinstance(selectable_object, java.nio.channels.SelectableChannel): + return selectable_object for method in ['getchannel', 'fileno']: try: channel = getattr(selectable_object, method)() Modified: branches/Release_2_2maint/jython/Lib/test/test_select.py =================================================================== --- branches/Release_2_2maint/jython/Lib/test/test_select.py 2008-12-18 11:05:16 UTC (rev 5776) +++ branches/Release_2_2maint/jython/Lib/test/test_select.py 2008-12-18 17:43:35 UTC (rev 5777) @@ -181,6 +181,17 @@ else: self.fail("Registering blocking socket should have raised select.error") + def testSelectOnSocketFileno(self): + self.cli_conn = self.serv.accept() + + def _testSelectOnSocketFileno(self): + self.cli.connect( (test_socket.HOST, test_socket.PORT) ) + self.cli.setblocking(0) + try: + rfd, wfd, xfd = select.select([self.cli.fileno()], [], [], 1) + except Exception, x: + self.fail("Selecting on socket.fileno() should not have raised exception: %s" % str(x)) + class TestPipes(unittest.TestCase): verbose = 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2008-12-18 11:05:20
|
Revision: 5776 http://jython.svn.sourceforge.net/jython/?rev=5776&view=rev Author: amak Date: 2008-12-18 11:05:16 +0000 (Thu, 18 Dec 2008) Log Message: ----------- Fix for broken SSL support. Thanks to dmbaggett for the patch. http://bugs.jython.org/issue1182 Modified Paths: -------------- branches/Release_2_2maint/jython/Lib/socket.py Modified: branches/Release_2_2maint/jython/Lib/socket.py =================================================================== --- branches/Release_2_2maint/jython/Lib/socket.py 2008-12-18 11:03:44 UTC (rev 5775) +++ branches/Release_2_2maint/jython/Lib/socket.py 2008-12-18 11:05:16 UTC (rev 5776) @@ -1320,6 +1320,8 @@ def __init__(self, plain_sock, keyfile=None, certfile=None): self.ssl_sock = self.make_ssl_socket(plain_sock) + self._in_buf = java.io.BufferedInputStream(self.ssl_sock.getInputStream()) + self._out_buf = java.io.BufferedOutputStream(self.ssl_sock.getOutputStream()) def make_ssl_socket(self, plain_socket, auto_close=0): java_net_socket = plain_socket._get_jsocket() @@ -1333,10 +1335,8 @@ return ssl_socket def read(self, n=4096): - # Probably needs some work on efficency - in_buf = java.io.BufferedInputStream(self.ssl_sock.getInputStream()) data = jarray.zeros(n, 'b') - m = in_buf.read(data, 0, n) + m = self._in_buf.read(data, 0, n) if m <= 0: return "" if m < n: @@ -1344,10 +1344,9 @@ return data.tostring() def write(self, s): - # Probably needs some work on efficency - out = java.io.BufferedOutputStream(self.ssl_sock.getOutputStream()) - out.write(s) - out.flush() + self._out_buf.write(s) + self._out_buf.flush() + return len(s) def _get_server_cert(self): return self.ssl_sock.getSession().getPeerCertificates()[0] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2008-12-18 11:03:48
|
Revision: 5775 http://jython.svn.sourceforge.net/jython/?rev=5775&view=rev Author: amak Date: 2008-12-18 11:03:44 +0000 (Thu, 18 Dec 2008) Log Message: ----------- Fix for broken SSL support. Thanks to dmbaggett for the patch. http://bugs.jython.org/issue1182 Modified Paths: -------------- trunk/jython/Lib/socket.py Modified: trunk/jython/Lib/socket.py =================================================================== --- trunk/jython/Lib/socket.py 2008-12-17 19:42:40 UTC (rev 5774) +++ trunk/jython/Lib/socket.py 2008-12-18 11:03:44 UTC (rev 5775) @@ -1350,6 +1350,8 @@ def __init__(self, plain_sock, keyfile=None, certfile=None): self.ssl_sock = self.make_ssl_socket(plain_sock) + self._in_buf = java.io.BufferedInputStream(self.ssl_sock.getInputStream()) + self._out_buf = java.io.BufferedOutputStream(self.ssl_sock.getOutputStream()) def make_ssl_socket(self, plain_socket, auto_close=0): java_net_socket = plain_socket._get_jsocket() @@ -1363,10 +1365,8 @@ return ssl_socket def read(self, n=4096): - # Probably needs some work on efficency - in_buf = java.io.BufferedInputStream(self.ssl_sock.getInputStream()) data = jarray.zeros(n, 'b') - m = in_buf.read(data, 0, n) + m = self._in_buf.read(data, 0, n) if m <= 0: return "" if m < n: @@ -1374,10 +1374,9 @@ return data.tostring() def write(self, s): - # Probably needs some work on efficency - out = java.io.BufferedOutputStream(self.ssl_sock.getOutputStream()) - out.write(s) - out.flush() + self._out_buf.write(s) + self._out_buf.flush() + return len(s) def _get_server_cert(self): return self.ssl_sock.getSession().getPeerCertificates()[0] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-17 19:42:44
|
Revision: 5774 http://jython.svn.sourceforge.net/jython/?rev=5774&view=rev Author: fwierzbicki Date: 2008-12-17 19:42:40 +0000 (Wed, 17 Dec 2008) Log Message: ----------- Fix for http://bugs.jython.org/issue1063. On stack overflows we now properly throw a Python RuntimeError instead of a Java StackOverflowError. This also allows us to use an the CPython test_exceptions.py unmodified. Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java Removed Paths: ------------- trunk/jython/Lib/test/test_exceptions.py Deleted: trunk/jython/Lib/test/test_exceptions.py =================================================================== --- trunk/jython/Lib/test/test_exceptions.py 2008-12-17 07:09:26 UTC (rev 5773) +++ trunk/jython/Lib/test/test_exceptions.py 2008-12-17 19:42:40 UTC (rev 5774) @@ -1,349 +0,0 @@ -# Python test set -- part 5, built-in exceptions - -import os -import sys -import unittest -import warnings -import pickle, cPickle - -from test.test_support import TESTFN, unlink, run_unittest - -# XXX This is not really enough, each *operation* should be tested! - -class ExceptionTests(unittest.TestCase): - - def testReload(self): - # Reloading the built-in exceptions module failed prior to Py2.2, while it - # should act the same as reloading built-in sys. - try: - import exceptions - reload(exceptions) - except ImportError, e: - self.fail("reloading exceptions: %s" % e) - - def raise_catch(self, exc, excname): - try: - raise exc, "spam" - except exc, err: - buf1 = str(err) - try: - raise exc("spam") - except exc, err: - buf2 = str(err) - self.assertEquals(buf1, buf2) - self.assertEquals(exc.__name__, excname) - - def testRaising(self): - self.raise_catch(AttributeError, "AttributeError") - self.assertRaises(AttributeError, getattr, sys, "undefined_attribute") - - self.raise_catch(EOFError, "EOFError") - fp = open(TESTFN, 'w') - fp.close() - fp = open(TESTFN, 'r') - savestdin = sys.stdin - try: - try: - sys.stdin = fp - x = raw_input() - except EOFError: - pass - finally: - sys.stdin = savestdin - fp.close() - unlink(TESTFN) - - self.raise_catch(IOError, "IOError") - self.assertRaises(IOError, open, 'this file does not exist', 'r') - - self.raise_catch(ImportError, "ImportError") - self.assertRaises(ImportError, __import__, "undefined_module") - - self.raise_catch(IndexError, "IndexError") - x = [] - self.assertRaises(IndexError, x.__getitem__, 10) - - self.raise_catch(KeyError, "KeyError") - x = {} - self.assertRaises(KeyError, x.__getitem__, 'key') - - self.raise_catch(KeyboardInterrupt, "KeyboardInterrupt") - - self.raise_catch(MemoryError, "MemoryError") - - self.raise_catch(NameError, "NameError") - try: x = undefined_variable - except NameError: pass - - self.raise_catch(OverflowError, "OverflowError") - x = 1 - for dummy in range(128): - x += x # this simply shouldn't blow up - - self.raise_catch(RuntimeError, "RuntimeError") - - self.raise_catch(SyntaxError, "SyntaxError") - try: exec '/\n' - except SyntaxError: pass - - self.raise_catch(IndentationError, "IndentationError") - - self.raise_catch(TabError, "TabError") - # can only be tested under -tt, and is the only test for -tt - #try: compile("try:\n\t1/0\n \t1/0\nfinally:\n pass\n", '<string>', 'exec') - #except TabError: pass - #else: self.fail("TabError not raised") - - self.raise_catch(SystemError, "SystemError") - - self.raise_catch(SystemExit, "SystemExit") - self.assertRaises(SystemExit, sys.exit, 0) - - self.raise_catch(TypeError, "TypeError") - try: [] + () - except TypeError: pass - - self.raise_catch(ValueError, "ValueError") - self.assertRaises(ValueError, chr, 10000) - - self.raise_catch(ZeroDivisionError, "ZeroDivisionError") - try: x = 1/0 - except ZeroDivisionError: pass - - self.raise_catch(Exception, "Exception") - try: x = 1/0 - except Exception, e: pass - - def testSyntaxErrorMessage(self): - # make sure the right exception message is raised for each of - # these code fragments - - def ckmsg(src, msg): - try: - compile(src, '<fragment>', 'exec') - except SyntaxError, e: - if e.msg != msg: - self.fail("expected %s, got %s" % (msg, e.msg)) - else: - self.fail("failed to get expected SyntaxError") - - s = '''while 1: - try: - pass - finally: - continue''' - - if not sys.platform.startswith('java'): - ckmsg(s, "'continue' not supported inside 'finally' clause") - - s = '''if 1: - try: - continue - except: - pass''' - - ckmsg(s, "'continue' not properly in loop") - ckmsg("continue\n", "'continue' not properly in loop") - - def testSettingException(self): - # test that setting an exception at the C level works even if the - # exception object can't be constructed. - - class BadException: - def __init__(self_): - raise RuntimeError, "can't instantiate BadException" - - def test_capi1(): - import _testcapi - try: - _testcapi.raise_exception(BadException, 1) - except TypeError, err: - exc, err, tb = sys.exc_info() - co = tb.tb_frame.f_code - self.assertEquals(co.co_name, "test_capi1") - self.assert_(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) - else: - self.fail("Expected exception") - - def test_capi2(): - import _testcapi - try: - _testcapi.raise_exception(BadException, 0) - except RuntimeError, err: - exc, err, tb = sys.exc_info() - co = tb.tb_frame.f_code - self.assertEquals(co.co_name, "__init__") - self.assert_(co.co_filename.endswith('test_exceptions'+os.extsep+'py')) - co2 = tb.tb_frame.f_back.f_code - self.assertEquals(co2.co_name, "test_capi2") - else: - self.fail("Expected exception") - - if not sys.platform.startswith('java'): - test_capi1() - test_capi2() - - def test_WindowsError(self): - try: - WindowsError - except NameError: - pass - else: - self.failUnlessEqual(str(WindowsError(1001)), - "1001") - self.failUnlessEqual(str(WindowsError(1001, "message")), - "[Error 1001] message") - self.failUnlessEqual(WindowsError(1001, "message").errno, 22) - self.failUnlessEqual(WindowsError(1001, "message").winerror, 1001) - - def testAttributes(self): - # test that exception attributes are happy - - exceptionList = [ - (BaseException, (), {'message' : '', 'args' : ()}), - (BaseException, (1, ), {'message' : 1, 'args' : (1,)}), - (BaseException, ('foo',), - {'message' : 'foo', 'args' : ('foo',)}), - (BaseException, ('foo', 1), - {'message' : '', 'args' : ('foo', 1)}), - (SystemExit, ('foo',), - {'message' : 'foo', 'args' : ('foo',), 'code' : 'foo'}), - (IOError, ('foo',), - {'message' : 'foo', 'args' : ('foo',), 'filename' : None, - 'errno' : None, 'strerror' : None}), - (IOError, ('foo', 'bar'), - {'message' : '', 'args' : ('foo', 'bar'), 'filename' : None, - 'errno' : 'foo', 'strerror' : 'bar'}), - (IOError, ('foo', 'bar', 'baz'), - {'message' : '', 'args' : ('foo', 'bar'), 'filename' : 'baz', - 'errno' : 'foo', 'strerror' : 'bar'}), - (IOError, ('foo', 'bar', 'baz', 'quux'), - {'message' : '', 'args' : ('foo', 'bar', 'baz', 'quux')}), - (EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'), - {'message' : '', 'args' : ('errnoStr', 'strErrorStr'), - 'strerror' : 'strErrorStr', 'errno' : 'errnoStr', - 'filename' : 'filenameStr'}), - (EnvironmentError, (1, 'strErrorStr', 'filenameStr'), - {'message' : '', 'args' : (1, 'strErrorStr'), 'errno' : 1, - 'strerror' : 'strErrorStr', 'filename' : 'filenameStr'}), - (SyntaxError, ('msgStr',), - {'message' : 'msgStr', 'args' : ('msgStr',), 'text' : None, - 'print_file_and_line' : None, 'msg' : 'msgStr', - 'filename' : None, 'lineno' : None, 'offset' : None}), - (SyntaxError, ('msgStr', ('filenameStr', 'linenoStr', 'offsetStr', - 'textStr')), - {'message' : '', 'offset' : 'offsetStr', 'text' : 'textStr', - 'args' : ('msgStr', ('filenameStr', 'linenoStr', - 'offsetStr', 'textStr')), - 'print_file_and_line' : None, 'msg' : 'msgStr', - 'filename' : 'filenameStr', 'lineno' : 'linenoStr'}), - (SyntaxError, ('msgStr', 'filenameStr', 'linenoStr', 'offsetStr', - 'textStr', 'print_file_and_lineStr'), - {'message' : '', 'text' : None, - 'args' : ('msgStr', 'filenameStr', 'linenoStr', 'offsetStr', - 'textStr', 'print_file_and_lineStr'), - 'print_file_and_line' : None, 'msg' : 'msgStr', - 'filename' : None, 'lineno' : None, 'offset' : None}), - (UnicodeError, (), {'message' : '', 'args' : (),}), - (UnicodeEncodeError, ('ascii', u'a', 0, 1, 'ordinal not in range'), - {'message' : '', 'args' : ('ascii', u'a', 0, 1, - 'ordinal not in range'), - 'encoding' : 'ascii', 'object' : u'a', - 'start' : 0, 'reason' : 'ordinal not in range'}), - (UnicodeDecodeError, ('ascii', '\xff', 0, 1, 'ordinal not in range'), - {'message' : '', 'args' : ('ascii', '\xff', 0, 1, - 'ordinal not in range'), - 'encoding' : 'ascii', 'object' : '\xff', - 'start' : 0, 'reason' : 'ordinal not in range'}), - (UnicodeTranslateError, (u"\u3042", 0, 1, "ouch"), - {'message' : '', 'args' : (u'\u3042', 0, 1, 'ouch'), - 'object' : u'\u3042', 'reason' : 'ouch', - 'start' : 0, 'end' : 1}), - ] - try: - exceptionList.append( - (WindowsError, (1, 'strErrorStr', 'filenameStr'), - {'message' : '', 'args' : (1, 'strErrorStr'), - 'strerror' : 'strErrorStr', 'winerror' : 1, - 'errno' : 22, 'filename' : 'filenameStr'}) - ) - except NameError: - pass - - for exc, args, expected in exceptionList: - try: - raise exc(*args) - except BaseException, e: - if type(e) is not exc: - raise - # Verify module name - self.assertEquals(type(e).__module__, 'exceptions') - # Verify no ref leaks in Exc_str() - s = str(e) - for checkArgName in expected: - self.assertEquals(repr(getattr(e, checkArgName)), - repr(expected[checkArgName]), - 'exception "%s", attribute "%s"' % - (repr(e), checkArgName)) - - # test for pickling support - for p in pickle, cPickle: - for protocol in range(p.HIGHEST_PROTOCOL + 1): - new = p.loads(p.dumps(e, protocol)) - for checkArgName in expected: - got = repr(getattr(new, checkArgName)) - want = repr(expected[checkArgName]) - self.assertEquals(got, want, - 'pickled "%r", attribute "%s' % - (e, checkArgName)) - - def testSlicing(self): - # Test that you can slice an exception directly instead of requiring - # going through the 'args' attribute. - args = (1, 2, 3) - exc = BaseException(*args) - self.failUnlessEqual(exc[:], args) - - def testKeywordArgs(self): - # test that builtin exception don't take keyword args, - # but user-defined subclasses can if they want - self.assertRaises(TypeError, BaseException, a=1) - - class DerivedException(BaseException): - def __init__(self, fancy_arg): - BaseException.__init__(self) - self.fancy_arg = fancy_arg - - x = DerivedException(fancy_arg=42) - self.assertEquals(x.fancy_arg, 42) - - def testInfiniteRecursion(self): - def f(): - return f() - self.assertRaises(RuntimeError, f) - - def g(): - try: - return g() - except ValueError: - return -1 - self.assertRaises(RuntimeError, g) - - def testUnicodeStrUsage(self): - # Make sure both instances and classes have a str and unicode - # representation. - self.failUnless(str(Exception)) - self.failUnless(unicode(Exception)) - self.failUnless(str(Exception('a'))) - self.failUnless(unicode(Exception(u'a'))) - - -def test_main(): - from test import test_support - if test_support.is_jython: - # XXX: http://bugs.jython.org/issue1063 - del ExceptionTests.testInfiniteRecursion - run_unittest(ExceptionTests) - -if __name__ == '__main__': - test_main() Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2008-12-17 07:09:26 UTC (rev 5773) +++ trunk/jython/src/org/python/core/Py.java 2008-12-17 19:42:40 UTC (rev 5774) @@ -444,6 +444,8 @@ return (PyException) t; } else if (t instanceof InvocationTargetException) { return JavaError(((InvocationTargetException) t).getTargetException()); + } else if (t instanceof StackOverflowError) { + return Py.RuntimeError("maximum recursion depth exceeded"); } else if (t instanceof OutOfMemoryError) { memory_error((OutOfMemoryError) t); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-17 07:09:29
|
Revision: 5773 http://jython.svn.sourceforge.net/jython/?rev=5773&view=rev Author: pjenvey Date: 2008-12-17 07:09:26 +0000 (Wed, 17 Dec 2008) Log Message: ----------- forgot to proxy EnumerationIter Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py trunk/jython/src/org/python/core/PyJavaType.java Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2008-12-17 07:07:56 UTC (rev 5772) +++ trunk/jython/Lib/test/test_java_integration.py 2008-12-17 07:09:26 UTC (rev 5773) @@ -6,7 +6,7 @@ from test import test_support from java.awt import (Dimension, Component, Rectangle, Button, Color, HeadlessException) -from java.util import ArrayList, Vector, HashMap, Hashtable +from java.util import ArrayList, HashMap, Hashtable, StringTokenizer, Vector from java.io import FileOutputStream, FileWriter, OutputStreamWriter from java.lang import Runnable, Thread, ThreadGroup, System, Runtime, Math, Byte @@ -450,7 +450,11 @@ del m["a"] self.assertEquals(0, len(m)) + def test_enumerable_delegation(self): + tokenizer = StringTokenizer('foo bar') + self.assertEquals(list(iter(tokenizer)), ['foo', 'bar']) + def test_main(): test_support.run_unittest(AbstractOnSyspathTest, InstantiationTest, Modified: trunk/jython/src/org/python/core/PyJavaType.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaType.java 2008-12-17 07:07:56 UTC (rev 5772) +++ trunk/jython/src/org/python/core/PyJavaType.java 2008-12-17 07:09:26 UTC (rev 5773) @@ -409,7 +409,7 @@ return false; } - private class EnumerationIter extends PyIterator { + private static class EnumerationIter extends PyIterator { private Enumeration<Object> proxy; @@ -495,6 +495,13 @@ }; collectionProxies.put(Iterator.class, new PyBuiltinMethod[] {iteratorProxy}); + PyBuiltinMethodNarrow enumerationProxy = new PyBuiltinMethodNarrow("__iter__", 0, 0) { + public PyObject __call__() { + return new EnumerationIter(((Enumeration)self.getJavaProxy())); + } + }; + collectionProxies.put(Enumeration.class, new PyBuiltinMethod[] {enumerationProxy}); + // Map doesn't extend Collection, so it needs its own version of len, iter and contains PyBuiltinMethodNarrow mapLenProxy = new MapMethod("__len__", 0, 0) { @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-17 07:08:01
|
Revision: 5772 http://jython.svn.sourceforge.net/jython/?rev=5772&view=rev Author: pjenvey Date: 2008-12-17 07:07:56 +0000 (Wed, 17 Dec 2008) Log Message: ----------- feed me, Seymour Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-12-17 03:56:56 UTC (rev 5771) +++ trunk/jython/build.xml 2008-12-17 07:07:56 UTC (rev 5772) @@ -178,9 +178,9 @@ <pathelement path="${exposed.dir}" /> <pathelement path="${compile.dir}" /> </path> - <!-- 64 bit Java 6 needs about 96m for regrtest on most platforms, but Apple's needs - 144m --> - <property name="regrtest.Xmx" value="-Xmx144m" /> + <!-- 64 bit Java 6 needs roughly 96m for regrtest on most platforms, but Apple's needs + more --> + <property name="regrtest.Xmx" value="-Xmx160m" /> </target> <target name="version-init"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |