Index: PyClassMethod.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyClassMethod.java,v retrieving revision 2.1 diff -u -r2.1 PyClassMethod.java --- PyClassMethod.java 22 Feb 2005 04:19:30 -0000 2.1 +++ PyClassMethod.java 6 Apr 2006 03:28:43 -0000 @@ -6,7 +6,45 @@ public final static String exposed_name = "classmethod"; public static void typeSetup(PyObject dict, PyType.Newstyle marker) { - // xxx __get__ + class exposed___get__ extends PyBuiltinFunctionNarrow { + + private PyClassMethod self; + + public PyObject getSelf() { + return self; + } + + exposed___get__(PyClassMethod self,PyBuiltinFunction.Info info) { + super(info); + this.self=self; + } + + public PyBuiltinFunction makeBound(PyObject self) { + return new exposed___get__((PyClassMethod)self,info); + } + + public PyObject __call__(PyObject arg0,PyObject arg1) { + return self.__get__(arg0,arg1); + } + + public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) { + PyClassMethod self=(PyClassMethod)gself; + return self.__get__(arg0,arg1); + } + + + public PyObject __call__(PyObject arg0) { + return self.__get__(arg0, null); + } + + public PyObject inst_call(PyObject gself,PyObject arg0) { + PyClassMethod self=(PyClassMethod)gself; + return self.__get__(arg0, null); + } + + } + dict.__setitem__("__get__",new PyMethodDescr("__get__",PyClassMethod.class,1,2,new exposed___get__(null,null))); + // xxx __init__ dict @@ -29,6 +67,9 @@ protected PyObject callable; public PyClassMethod(PyObject callable) { + if (!callable.isCallable()) { + throw Py.TypeError("'" + callable.getType().fastGetName() + "' object is not callable"); + } this.callable = callable; }