/** * Equivalent to the standard Python __int__ method. * Should only be overridden by numeric objects that can be * reasonably coerced into an integer. * * @return an integer corresponding to the value of this object. **/ public PyObject __int__() { throw Py.AttributeError("__int__"); }
/** * Equivalent to the standard Python conjugate method. * Should only be overridden by numeric objects that can calculate a * complex conjugate. * * @return the complex conjugate. **/ public PyObject conjugate() { throw Py.AttributeError("conjugate"); }
/** * Equivalent to the standard Python __long__ method. * Should only be overridden by numeric objects that can be * reasonably coerced into a python long. * * @return a PyLong or PyInteger corresponding to the value of this object. **/ public PyObject __long__() { throw Py.AttributeError("__long__"); }
/** * Equivalent to the standard Python __trunc__ method. * Should only be overridden by numeric objects that can reasonably * be truncated to an Integral. * * @return the Integral closest to x between 0 and x. **/ public PyObject __trunc__() { throw Py.AttributeError("__trunc__"); }
/** * Equivalent to the standard Python __float__ method. * Should only be overridden by numeric objects that can be * reasonably coerced into a python float. * * @return a float corresponding to the value of this object. **/ public PyFloat __float__() { throw Py.AttributeError("__float__"); }
/** * Equivalent to the standard Python __complex__ method. * Should only be overridden by numeric objects that can be * reasonably coerced into a python complex number. * * @return a complex number corresponding to the value of this object. **/ public PyComplex __complex__() { throw Py.AttributeError("__complex__"); }
/** * Equivalent to the standard Python bit_length method. * Should only be overridden by numeric objects that can calculate a * bit_length. * * @return the bit_length of this object. **/ public int bit_length() { throw Py.AttributeError("bit_length"); }
/** * Customized AttributeError for class objects. */ @Override public void noAttributeError(String name) { throw Py.AttributeError(String.format("class %.50s has no attribute '%.400s'", __name__, name)); }
@Override public void noAttributeError(String name) { throw Py.AttributeError(String.format("%.50s instance has no attribute '%.400s'", instclass.__name__, name)); }
private void throwReadonly(String name) { for (int i = 0; i < __members__.length; i++) { if (__members__[i] == name) { throw Py.TypeError("readonly attribute"); } } throw Py.AttributeError(name); }
public void __set__(PyObject obj, PyObject value) { if (!_doset(obj, value)) { throw Py.AttributeError("object internal __set__ impl is abstract"); } }
private void throwReadonly(String name) { for (int i = 0; i < __members__.length; i++) if (__members__[i] == name) throw Py.TypeError("readonly attribute"); throw Py.AttributeError(name); }
private void initAdapter() { if (adapterClass == null) { adapterClass = getAdapterClass(eventClass); try { adapterField = adapterClass.getField(__name__); } catch (NoSuchFieldException exc) { throw Py.AttributeError("Internal bean event error: " + __name__); } } }
@ExposedSet(name = "maxlen") public void setMaxlen(PyObject o) { // this has to be here because by default, if not defined, // the Jython object model raise a TypeError, where we usually expect // AttributeError here; due to a CPython 2.7 idiosyncracy that has // since been fixed for 3.x in http://bugs.python.org/issue1687163 throw Py.AttributeError("attribute 'maxlen' of 'collections.deque' objects is not writable"); }
/** * Raises AttributeError on type objects. The message differs from * PyObject#noAttributeError, to mimic CPython behaviour. */ public void noAttributeError(String name) { throw Py.AttributeError(String.format("type object '%.50s' has no attribute '%.400s'", fastGetName(), name)); }
@ExposedMethod(doc = BuiltinDocs.property___delete___doc) final void property___delete__(PyObject obj) { if (fdel == null) { throw Py.AttributeError("can't delete attribute"); } fdel.__call__(obj); }
@ExposedMethod(doc = BuiltinDocs.property___set___doc) final void property___set__(PyObject obj, PyObject value) { if (fset == null) { throw Py.AttributeError("can't set attribute"); } fset.__call__(obj, value); }
@ExposedMethod(defaults = "null", doc = BuiltinDocs.property___get___doc) final PyObject property___get__(PyObject obj, PyObject type) { if (obj == null || obj == Py.None) { return this; } if (fget == null) { throw Py.AttributeError("unreadable attribute"); } return fget.__call__(obj); }
@ExposedSet(name = "quoting") public void setQuoting(PyObject obj) { throw Py.AttributeError(String.format("attribute '%s' of '%s' objects is not writable", "quoting", getType().fastGetName())); }
@ExposedSet(name = "__dict__") public void setDict(PyObject newDict) { // Analogous to CPython's descrobject:getset_set throw Py.AttributeError(String.format("attribute '__dict__' of '%s' objects is not " + "writable", getType().fastGetName())); }