Top Description Fields Constructors Methods
org.python.core

public Class Abstract

extends Object
Class Inheritance
Known Direct Subclasses
org.python.core.Callables, org.python.core.PyNumber, org.python.core.PySequence
Imports
java.lang.invoke.MethodHandle, java.util.function.Supplier, org.python.base.InterpreterError, .MissingFeature, org.python.core.Slot.EmptyException

The "abstract interface" to operations on Python objects. Methods here execute the slot functions of the type definition of the objects passed in. A primary application is to the CPython byte code interpreter. (Methods here often correspond closely to a CPython opcode.)

In CPython, the methods are found in Objects/abstract.c

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final String
protected static final String
protected static final String
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
protected
Abstract()

There are only static methods here, so no instances should be created.

Method Summary

Modifier and TypeMethod and Description
public static TypeError

Returns:

exception to throw
argumentTypeError
(String
name of function or operation
f
,
String
of argument
name
,
String
describing the expected kind of argument
t
,
Object
actual argument (not its type)
o
)

Create a TypeError with a message along the lines "F() [name] argument must be T, not X", involving a function name, an argument name, an expected type description T and the type X of o, e.g. "split() separator argument must be str or None, 'tuple'".

public static TypeError

Returns:

exception to throw
argumentTypeError
(String
name of function or operation
f
,
int
ordinal of argument: 1 for "first", etc., 0 for ""
n
,
String
describing the expected kind of argument
t
,
Object
actual argument (not its type)
o
)

Create a TypeError with a message along the lines "F() [nth] argument must be T, not X", involving a function name, optionally an ordinal n, an expected type description T and the type X of o, e.g. "int() argument must be a string, a bytes-like object or a number, not 'list'" or "complex() second argument must be a number, not 'type'".

private static TypeError

Returns:

an error to throw
attributeAccessError
(Object
object accessed
o
,
String
of attribute
name
,
Slot
operation
slot
)

Crafted error supporting getAttr(Object, PyUnicode), setAttr(Object, PyUnicode, Object), and delAttr(Object, PyUnicode).

pack-priv static TypeError

Returns:

exception to throw
attributeNameTypeError
(Object
actual object offered as a name
name
)

Create a TypeError with a message along the lines "attribute name must be string, not 'X'" giving the type X of name.

pack-priv static TypeError

Returns:

exception to throw
attrMustBe
(String
of the attribute
name
,
String
expected kind of thing
kind
,
Object
provided to set this attribute in some object
value
)

Create a TypeError with a message along the lines "N must be set to T, not a X object" involving the name N of the attribute, any descriptive phrase T and the type X of value, e.g. "__dict__ must be set to a dictionary, not a 'list' object".

pack-priv static TypeError

Returns:

exception to throw
attrMustBeString
(String
of the attribute
name
,
Object
provided to set this attribute in some object
value
)

Create a TypeError with a message along the lines "N must be set to a string, not a X object".

pack-priv static void
badInternalCall()

Throw generic something went wrong internally (last resort).

pack-priv static TypeError

Returns:

exception to throw
cantSetAttributeError
(Object
actual object on which setting failed
obj
)

Create a TypeError with a message along the lines "can't set attributes of X" giving str of name.

public static void
delAttr(Object
object to operate on
o
,
String
of attribute
name
)

del o.name with Python semantics.

public static void
delAttr(Object
object to operate on
o
,
Object
of attribute
name
)

del o.name with Python semantics.

pack-priv static Object

Returns:

o.name
getAttr
(Object
object to operate on
o
,
String
of attribute
name
)

o.name with Python semantics.

pack-priv static Object

Returns:

o.name
getAttr
(Object
object to operate on
o
,
Object
of attribute
name
)

o.name with Python semantics.

private static PyTuple

Returns:

cls.__bases__ or null
getBasesOf
(Object
normally a type object
cls
)

Get cls.__bases__, a Python tuple, by name from the object invoking __getattribute__.

pack-priv static Object

Returns:

an iterator on o
getIterator
(Object
the claimed iterable object
o
)

This is equivalent to the Python expression iter(o).

pack-priv static <
the type of exception to throw
E extends PyException
>
Object

Returns:

an iterator on o
getIterator
(Object
the claimed iterable object
o
,
Supplier<E>
a supplier (e.g. lambda expression) for the exception
exc
)

Equivalent to getIterator(Object), with the opportunity to specify the kind of Python exception to raise.

pack-priv static int

Returns:

the hash
hash
(Object
to hash
v
)

Compute and return the hash value of an object.

pack-priv static InterpreterError

Returns:

exception to throw
impossibleArgumentError
(String
expected kind of argument
d
,
Object
actual argument (not its type)
o
)

Create an InterpreterError for use where a Python method (or special method) implementation receives an argument that should be impossible in a correct interpreter.

pack-priv static IndexError

Returns:

exception to throw
indexOutOfRange
(String
object accessed
name
)

Create an IndexError with a message along the lines "N index out of range", where N is usually a function or type name.

pack-priv static TypeError

Returns:

exception to throw
indexTypeError
(PyType
type of target of function or operation
t
,
PyType
type of object presented as an index
x
)

Create a TypeError with a message along the lines "T indices must be integers or slices, not X" involving the a target type T and a purported index type X presented, e.g. "list indices must be integers or slices, not str".

pack-priv static TypeError

Returns:

exception to throw
indexTypeError
(Object
target of function or operation
o
,
Object
actual object presented as an index
i
)

Create a TypeError with a message along the lines "T indices must be integers or slices, not X" involving the type name T of a target o and the type name X of i presented as an index, e.g. "list indices must be integers or slices, not str".

private static boolean

Returns:

whether derived is a sub-class of cls
isSubclassHelper
(Object
candidate derived type
derived
,
Object
type that may be an ancestor of derived
cls
)

Return true iff derived is a Python sub-class of cls (including where it is the same class).

pack-priv static boolean

Returns:

if Python-truthy
isTrue
(Object
to test
v
)

Test a value used as condition in a for or if statement.

pack-priv static boolean

Returns:

true if o supports the iterator protocol
iterableCheck
(Object
to test
o
)

Return true if the object o supports the iterator protocol (has __iter__).

pack-priv static boolean

Returns:

true if o is an iterator
iteratorCheck
(Object
to test
o
)

Return true if the object o is an iterator (has __next__).

pack-priv static Object

Returns:

the attribute or null
lookupAttr
(Object
the object in which to look for the attribute
o
,
Object
of the attribute sought
name
)

Python o.name: returning null when not found (in place of AttributeError as would getAttr(Object, Object)).

pack-priv static Object

Returns:

the attribute or null
lookupAttr
(Object
the object in which to look for the attribute
o
,
String
of the attribute sought
name
)

Python o.name returning null when not found (in place of AttributeError as would getAttr(Object, String)).

pack-priv static AttributeError

Returns:

exception to throw
mandatoryAttributeError
(Object
object accessed
v
,
Object
of attribute
name
)

Create a AttributeError with a message along the lines "'T' object attribute N cannot be deleted", where T is the type of the object accessed.

pack-priv static AttributeError

Returns:

exception to throw
mandatoryAttributeOnType
(PyType
of object accessed
type
,
Object
of attribute
name
)

Create a AttributeError with a message along the lines "'T' object attribute N cannot be deleted", where T is the type given.

pack-priv static Object

Returns:

the next item
next
(Object
the iterator
iter
)

Return the next value from the Python iterator iter.

pack-priv static AttributeError

Returns:

exception to throw
noAttributeError
(Object
object accessed
v
,
Object
of attribute
name
)

Create a AttributeError with a message along the lines "'T' object has no attribute N", where T is the type of the object accessed.

pack-priv static AttributeError

Returns:

exception to throw
noAttributeOnType
(PyType
of object accessed
type
,
Object
of attribute
name
)

Create a AttributeError with a message along the lines "'T' object has no attribute N", where T is the type given.

private static String
ordinal(int n)

pack-priv static AttributeError

Returns:

exception to throw
readonlyAttributeError
(Object
object accessed
v
,
Object
of attribute
name
)

Create a AttributeError with a message along the lines "'T' object attribute N is read-only", where T is the type of the object accessed.

pack-priv static AttributeError

Returns:

exception to throw
readonlyAttributeOnType
(PyType
of object accessed
type
,
Object
of attribute
name
)

Create a AttributeError with a message along the lines "'T' object attribute N is read-only", where T is the type given.

pack-priv static boolean

Returns:

ẁhether derived is a sub-class of cls by these criteria.
recursiveIsSubclass
(Object
candidate derived type.
derived
,
Object
type that may be an ancestor of derived, (but not a tuple of such).
cls
)

Return true iff the class derived is identical to or derived from the class cls.

pack-priv static Object

Returns:

the string representation o
repr
(Object
object
o
)

The equivalent of the Python expression repr(o), and is called by the repr() built-in function.

pack-priv static TypeError

Returns:

exception to throw
requiredTypeError
(String
expected kind of thing
t
,
Object
actual object involved
o
)

Create a TypeError with a message along the lines "T is required, not X" involving any descriptive phrase T and the type X of o, e.g. "a bytes-like object is required, not 'str'".

pack-priv static Object

Returns:

o
returnDeprecation
(String
name of function or operation
f
,
String
expected type of return
t
,
Object
actual object returned
o
)

Submit a DeprecationWarning call (which may result in an exception) with the same message as returnTypeError(String, String, Object), the whole followed by one about deprecation of the facility.

pack-priv static TypeError

Returns:

exception to throw
returnTypeError
(String
name of function or operation
f
,
String
expected type of return
t
,
Object
actual object returned
o
)

Create a TypeError with a message along the lines "F returned non-T (type X)" involving a function name, an expected type T and the type X of o, e.g. "__int__ returned non-int (type str)".

pack-priv static Object

Returns:

comparison result
richCompare
(Object
left operand
v
,
Object
right operand
w
,
Comparison
comparison type
op
)

Perform a rich comparison, raising TypeError when the requested comparison operator is not supported.

pack-priv static boolean

Returns:

comparison result
richCompareBool
(Object
left operand
v
,
Object
right operand
w
,
Comparison
comparison type
op
)

Perform a rich comparison with boolean result.

pack-priv static <
type of exception
T extends PyException
>
boolean

Returns:

comparison result
richCompareBool
(Object
left operand
v
,
Object
right operand
w
,
Comparison
comparison type
op
,
Supplier<T>
supplies an exception of the desired type
exc
)

Perform a rich comparison with boolean result.

public static void
setAttr(Object
object to operate on
o
,
String
of attribute
name
,
Object
to set
value
)

o.name = value with Python semantics.

public static void
setAttr(Object
object to operate on
o
,
Object
of attribute
name
,
Object
to set
value
)

o.name = value with Python semantics.

pack-priv static Object

Returns:

the string representation o
str
(Object
object
o
)

The equivalent of the Python expression str(o).

public static <
target type defined by c
T
>
T

Returns:

converted value
tojava
(Object
the Object to convert.
o
,
Class<T>
the class to convert it to.
c
)

Convert a given Object to an instance of a Java class.

public static TypeError

Returns:

exception to throw
typeError
(String
format for message with a %s first
fmt
,
Object...
arguments to the formatted message, where Python type name of args[0] will replace it
args
)

Create a TypeError with a message involving the type of args[0] and optionally other arguments.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait