From: <pj...@us...> - 2008-08-21 23:59:49
|
Revision: 5232 http://jython.svn.sourceforge.net/jython/?rev=5232&view=rev Author: pjenvey Date: 2008-08-21 23:59:46 +0000 (Thu, 21 Aug 2008) Log Message: ----------- document TypeError vs AttributeError here 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-08-21 19:44:29 UTC (rev 5231) +++ trunk/jython/src/org/python/core/PyObject.java 2008-08-21 23:59:46 UTC (rev 5232) @@ -829,6 +829,9 @@ } public void readonlyAttributeError(String name) { + // XXX: Should be an AttributeError but CPython throws TypeError for read only + // member descriptors (in structmember.c::PyMember_SetOne), which is expected by a + // few tests. fixed in py3k: http://bugs.python.org/issue1687163 throw Py.TypeError("readonly attribute"); } 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: <le...@us...> - 2009-02-04 00:51:50
|
Revision: 6010 http://jython.svn.sourceforge.net/jython/?rev=6010&view=rev Author: leosoto Date: 2009-02-04 00:51:47 +0000 (Wed, 04 Feb 2009) Log Message: ----------- PyObject#reduce_2: Use invoke("iteritems") instead of this.iteritems() to avoid problems with dict subclasses which override iteritems on python code. Fixes #1257 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 2009-02-03 21:25:23 UTC (rev 6009) +++ trunk/jython/src/org/python/core/PyObject.java 2009-02-04 00:51:47 UTC (rev 6010) @@ -3904,7 +3904,7 @@ if (!(this instanceof PyDictionary)) { dictitems = Py.None; } else { - dictitems = ((PyDictionary)this).iteritems(); + dictitems = invoke("iteritems"); } PyObject copyreg = __builtin__.__import__("copy_reg", null, null, Py.EmptyTuple); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-09 01:26:43
|
Revision: 6193 http://jython.svn.sourceforge.net/jython/?rev=6193&view=rev Author: pjenvey Date: 2009-04-09 01:26:22 +0000 (Thu, 09 Apr 2009) Log Message: ----------- rearrange per coding standards 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 2009-04-08 21:45:35 UTC (rev 6192) +++ trunk/jython/src/org/python/core/PyObject.java 2009-04-09 01:26:22 UTC (rev 6193) @@ -7,6 +7,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; + import org.python.expose.ExposedDelete; import org.python.expose.ExposedGet; import org.python.expose.ExposedMethod; @@ -24,26 +25,62 @@ public static final PyType TYPE = PyType.fromClass(PyObject.class); - //XXX: in CPython object.__new__ has a doc string... - @ExposedNew - @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 -// if (args.length > 0) { -// throw Py.TypeError("default __new__ takes no parameters"); -// } + /** The type of this object. */ + PyType objtype; + /** + * An underlying Java instance that this object is wrapping or is a subclass + * of. Anything attempting to use the proxy should go through {@link #getJavaProxy()} + * which ensures that it's initialized. + */ + protected Object javaProxy; + + /** Primitives classes their wrapper classes. */ + private static final Map<Class<?>, Class<?>> primitiveMap = Generic.map(); + + static { + primitiveMap.put(Character.TYPE, Character.class); + primitiveMap.put(Boolean.TYPE, Boolean.class); + primitiveMap.put(Byte.TYPE, Byte.class); + primitiveMap.put(Short.TYPE, Short.class); + primitiveMap.put(Integer.TYPE, Integer.class); + primitiveMap.put(Long.TYPE, Long.class); + primitiveMap.put(Float.TYPE, Float.class); + primitiveMap.put(Double.TYPE, Double.class); } + public PyObject(PyType objtype) { + this.objtype = objtype; + } + /** - * An underlying Java instance that this object is wrapping or is a subclass of. Anything - * attempting to use the proxy should go through {@link #getJavaProxy()} which ensures that it's - * initialized. + * The standard constructor for a <code>PyObject</code>. It will set the <code>objtype</code> + * field to correspond to the specific subclass of <code>PyObject</code> being instantiated. + **/ + public PyObject() { + objtype = PyType.fromClass(getClass()); + } + + /** + * Creates the PyObject for the base type. The argument only exists to make the constructor + * distinct. */ - protected Object javaProxy; + PyObject(boolean ignored) { + objtype = (PyType)this; + } - PyType objtype; + //XXX: in CPython object.__new__ has a doc string... + @ExposedNew + @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 + /* + if (args.length > 0) { + throw Py.TypeError("default __new__ takes no parameters"); + } + */ + } @ExposedGet(name = "__class__") public PyType getType() { @@ -82,27 +119,7 @@ return Py.None; } - public PyObject(PyType objtype) { - this.objtype = objtype; - } - /** - * Creates the PyObject for the base type. The argument only exists to make the constructor - * distinct. - */ - PyObject(boolean ignored) { - objtype = (PyType)this; - } - - /** - * The standard constructor for a <code>PyObject</code>. It will set the <code>objtype</code> - * field to correspond to the specific subclass of <code>PyObject</code> being instantiated. - **/ - public PyObject() { - objtype = PyType.fromClass(getClass()); - } - - /** * Dispatch __init__ behavior */ public void dispatch__init__(PyType type, PyObject[] args, String[] keywords) {} @@ -288,18 +305,6 @@ return javaProxy; } - private static final Map<Class<?>, Class<?>> primitiveMap = Generic.map(); - static { - primitiveMap.put(Character.TYPE, Character.class); - primitiveMap.put(Boolean.TYPE, Boolean.class); - primitiveMap.put(Byte.TYPE, Byte.class); - primitiveMap.put(Short.TYPE, Short.class); - primitiveMap.put(Integer.TYPE, Integer.class); - primitiveMap.put(Long.TYPE, Long.class); - primitiveMap.put(Float.TYPE, Float.class); - primitiveMap.put(Double.TYPE, Double.class); - } - /** * The basic method to override when implementing a callable object. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-04 06:34:59
|
Revision: 6292 http://jython.svn.sourceforge.net/jython/?rev=6292&view=rev Author: pjenvey Date: 2009-05-04 06:34:46 +0000 (Mon, 04 May 2009) Log Message: ----------- we can safely shortcut _cmp on identity match 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 2009-05-04 06:07:19 UTC (rev 6291) +++ trunk/jython/src/org/python/core/PyObject.java 2009-05-04 06:34:46 UTC (rev 6292) @@ -1252,6 +1252,10 @@ * @return -1 if this < 0; 0 if this == o; +1 if this > o **/ public final int _cmp(PyObject o) { + if (this == o) { + return 0; + } + PyObject token = null; ThreadState ts = Py.getThreadState(); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-09 22:31:12
|
Revision: 6320 http://jython.svn.sourceforge.net/jython/?rev=6320&view=rev Author: pjenvey Date: 2009-05-09 22:30:55 +0000 (Sat, 09 May 2009) Log Message: ----------- less verbose unbootstraped message 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 2009-05-09 21:06:49 UTC (rev 6319) +++ trunk/jython/src/org/python/core/PyObject.java 2009-05-09 22:30:55 UTC (rev 6320) @@ -47,6 +47,12 @@ primitiveMap.put(Long.TYPE, Long.class); primitiveMap.put(Float.TYPE, Float.class); primitiveMap.put(Double.TYPE, Double.class); + + if (Py.BOOTSTRAP_TYPES.size() > 0) { + Py.writeWarning("init", "Bootstrap types weren't encountered in bootstrapping: " + + Py.BOOTSTRAP_TYPES); + + } } public PyObject(PyType objtype) { @@ -4068,13 +4074,6 @@ // OverflowErrors are handled in PyLong.asIndex return __index__().asInt(); } - - static { - for (Class<?> unbootstrapped : Py.BOOTSTRAP_TYPES) { - Py.writeWarning("init", "Bootstrap type wasn't encountered in bootstrapping[class=" - + unbootstrapped + "]"); - } - } } /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2010-04-09 04:40:58
|
Revision: 7008 http://jython.svn.sourceforge.net/jython/?rev=7008&view=rev Author: pjenvey Date: 2010-04-09 04:40:52 +0000 (Fri, 09 Apr 2010) Log Message: ----------- accommodate __long__ returning an int 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 2010-04-09 03:21:55 UTC (rev 7007) +++ trunk/jython/src/org/python/core/PyObject.java 2010-04-09 04:40:52 UTC (rev 7008) @@ -4054,7 +4054,7 @@ } throw pye; } - if (!(longObj instanceof PyLong)) { + if (!(longObj instanceof PyLong || longObj instanceof PyInteger)) { // Shouldn't happen except with buggy builtin types throw Py.TypeError("integer conversion failed"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-04-26 18:24:50
|
Revision: 7049 http://jython.svn.sourceforge.net/jython/?rev=7049&view=rev Author: zyasoft Date: 2010-04-26 18:24:42 +0000 (Mon, 26 Apr 2010) Log Message: ----------- Actual fix for missing synchronized on PyObject#getJavaProxy (missed checkin) 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 2010-04-26 18:16:08 UTC (rev 7048) +++ trunk/jython/src/org/python/core/PyObject.java 2010-04-26 18:24:42 UTC (rev 7049) @@ -174,6 +174,7 @@ return new PyString(toString()); } + @Override public String toString() { return object_toString(); } @@ -220,6 +221,7 @@ return new PyInteger(hashCode()); } + @Override public int hashCode() { return object___hash__(); } @@ -234,6 +236,7 @@ * If overridden, it is the subclasses responsibility to ensure that * <code>a.equals(b) == true</code> iff <code>cmp(a,b) == 0</code> **/ + @Override public boolean equals(Object ob_other) { if(ob_other == this) { return true; @@ -291,7 +294,7 @@ return Py.NoConversion; } - protected Object getJavaProxy() { + protected synchronized Object getJavaProxy() { if (javaProxy == null) { proxyInit(); } @@ -1890,7 +1893,7 @@ // situations // XXX: This method isn't expensive but could (and maybe // should?) be optimized for worst case scenarios - return op == "+" && (t1 == PyString.TYPE || t1 == PyUnicode.TYPE) && + return (op == "+") && (t1 == PyString.TYPE || t1 == PyUnicode.TYPE) && (t2.isSubType(PyString.TYPE) || t2.isSubType(PyUnicode.TYPE)); } @@ -4116,6 +4119,7 @@ list = elements; } + @Override public int hashCode() { int x, y; int len = list.length; @@ -4129,6 +4133,7 @@ return x; } + @Override public boolean equals(Object o) { if (!(o instanceof PyIdentityTuple)) return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2010-06-03 02:38:49
|
Revision: 7062 http://jython.svn.sourceforge.net/jython/?rev=7062&view=rev Author: pjenvey Date: 2010-06-03 02:38:42 +0000 (Thu, 03 Jun 2010) Log Message: ----------- simplify 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 2010-06-01 23:30:30 UTC (rev 7061) +++ trunk/jython/src/org/python/core/PyObject.java 2010-06-03 02:38:42 UTC (rev 7062) @@ -281,9 +281,9 @@ // convert faux floats // XXX: should also convert faux ints, but that breaks test_java_visibility // (ReflectedArgs resolution) - if (c == Double.TYPE || c == Double.class || c == Float.TYPE || c == Float.class) { + if (c == Double.class || c == Float.class) { try { - return __float__().getValue(); + return __float__().asDouble(); } catch (PyException pye) { if (!pye.match(Py.AttributeError)) { throw pye; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |