cpython/Objects/typeobject.c

/* Type object implementation */

#include "Python.h"
#include "pycore_abstract.h"      // _PySequence_IterSearch()
#include "pycore_call.h"          // _PyObject_VectorcallTstate()
#include "pycore_code.h"          // CO_FAST_FREE
#include "pycore_dict.h"          // _PyDict_KeysSize()
#include "pycore_frame.h"         // _PyInterpreterFrame
#include "pycore_lock.h"          // _PySeqLock_*
#include "pycore_long.h"          // _PyLong_IsNegative(), _PyLong_GetOne()
#include "pycore_memoryobject.h"  // _PyMemoryView_FromBufferProc()
#include "pycore_modsupport.h"    // _PyArg_NoKwnames()
#include "pycore_moduleobject.h"  // _PyModule_GetDef()
#include "pycore_object.h"        // _PyType_HasFeature()
#include "pycore_object_alloc.h"  // _PyObject_MallocWithType()
#include "pycore_pyerrors.h"      // _PyErr_Occurred()
#include "pycore_pystate.h"       // _PyThreadState_GET()
#include "pycore_symtable.h"      // _Py_Mangle()
#include "pycore_typeobject.h"    // struct type_cache
#include "pycore_unionobject.h"   // _Py_union_type_or
#include "pycore_weakref.h"       // _PyWeakref_GET_REF()
#include "opcode.h"               // MAKE_CELL

#include <stddef.h>               // ptrdiff_t

/*[clinic input]
class type "PyTypeObject *" "&PyType_Type"
class object "PyObject *" "&PyBaseObject_Type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=4b94608d231c434b]*/

#include "clinic/typeobject.c.h"

/* Support type attribute lookup cache */

/* The cache can keep references to the names alive for longer than
   they normally would.  This is why the maximum size is limited to
   MCACHE_MAX_ATTR_SIZE, since it might be a problem if very large
   strings are used as attribute names. */
#define MCACHE_MAX_ATTR_SIZE
#define MCACHE_HASH(version, name_hash)

#define MCACHE_HASH_METHOD(type, name)
#define MCACHE_CACHEABLE_NAME(name)

#define NEXT_GLOBAL_VERSION_TAG
#define NEXT_VERSION_TAG(interp)

#ifdef Py_GIL_DISABLED

// There's a global lock for mutation of types.  This avoids having to take
// additional locks while doing various subclass processing which may result
// in odd behaviors w.r.t. running with the GIL as the outer type lock could
// be released and reacquired during a subclass update if there's contention
// on the subclass lock.
#define TYPE_LOCK
#define BEGIN_TYPE_LOCK
#define END_TYPE_LOCK

#define BEGIN_TYPE_DICT_LOCK

#define END_TYPE_DICT_LOCK

#define ASSERT_TYPE_LOCK_HELD

#else

#define BEGIN_TYPE_LOCK()
#define END_TYPE_LOCK()
#define BEGIN_TYPE_DICT_LOCK(d)
#define END_TYPE_DICT_LOCK()
#define ASSERT_TYPE_LOCK_HELD()

#endif


PySlot_Offset;

static void
slot_bf_releasebuffer(PyObject *self, Py_buffer *buffer);

static void
releasebuffer_call_python(PyObject *self, Py_buffer *buffer);

static PyObject *
slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds);

static PyObject *
lookup_maybe_method(PyObject *self, PyObject *attr, int *unbound);

static int
slot_tp_setattro(PyObject *self, PyObject *name, PyObject *value);


static inline PyTypeObject *
type_from_ref(PyObject *ref)
{}


/* helpers for for static builtin types */

#ifndef NDEBUG
static inline int
managed_static_type_index_is_set(PyTypeObject *self)
{
    return self->tp_subclasses != NULL;
}
#endif

static inline size_t
managed_static_type_index_get(PyTypeObject *self)
{}

static inline void
managed_static_type_index_set(PyTypeObject *self, size_t index)
{}

static inline void
managed_static_type_index_clear(PyTypeObject *self)
{}

static PyTypeObject *
static_ext_type_lookup(PyInterpreterState *interp, size_t index,
                       int64_t *p_interp_count)
{}

static managed_static_type_state *
managed_static_type_state_get(PyInterpreterState *interp, PyTypeObject *self)
{}

/* For static types we store some state in an array on each interpreter. */
managed_static_type_state *
_PyStaticType_GetState(PyInterpreterState *interp, PyTypeObject *self)
{}

/* Set the type's per-interpreter state. */
static void
managed_static_type_state_init(PyInterpreterState *interp, PyTypeObject *self,
                               int isbuiltin, int initial)
{}

/* Reset the type's per-interpreter state.
   This basically undoes what managed_static_type_state_init() did. */
static void
managed_static_type_state_clear(PyInterpreterState *interp, PyTypeObject *self,
                                int isbuiltin, int final)
{}



PyObject *
_PyStaticType_GetBuiltins(void)
{}


// Also see _PyStaticType_InitBuiltin() and _PyStaticType_FiniBuiltin().

/* end static builtin helpers */


static inline void
start_readying(PyTypeObject *type)
{}

static inline void
stop_readying(PyTypeObject *type)
{}

static inline int
is_readying(PyTypeObject *type)
{}


/* accessors for objects stored on PyTypeObject */

static inline PyObject *
lookup_tp_dict(PyTypeObject *self)
{}

PyObject *
_PyType_GetDict(PyTypeObject *self)
{}

PyObject *
PyType_GetDict(PyTypeObject *self)
{}

static inline void
set_tp_dict(PyTypeObject *self, PyObject *dict)
{}

static inline void
clear_tp_dict(PyTypeObject *self)
{}


static inline PyObject *
lookup_tp_bases(PyTypeObject *self)
{}

PyObject *
_PyType_GetBases(PyTypeObject *self)
{}

static inline void
set_tp_bases(PyTypeObject *self, PyObject *bases, int initial)
{}

static inline void
clear_tp_bases(PyTypeObject *self, int final)
{}


static inline PyObject *
lookup_tp_mro(PyTypeObject *self)
{}

PyObject *
_PyType_GetMRO(PyTypeObject *self)
{}

static inline void
set_tp_mro(PyTypeObject *self, PyObject *mro, int initial)
{}

static inline void
clear_tp_mro(PyTypeObject *self, int final)
{}


static PyObject *
init_tp_subclasses(PyTypeObject *self)
{}

static void
clear_tp_subclasses(PyTypeObject *self)
{}

static inline PyObject *
lookup_tp_subclasses(PyTypeObject *self)
{}

int
_PyType_HasSubclasses(PyTypeObject *self)
{}

PyObject*
_PyType_GetSubclasses(PyTypeObject *self)
{}

/* end accessors for objects stored on PyTypeObject */


/*
 * finds the beginning of the docstring's introspection signature.
 * if present, returns a pointer pointing to the first '('.
 * otherwise returns NULL.
 *
 * doesn't guarantee that the signature is valid, only that it
 * has a valid prefix.  (the signature must also pass skip_signature.)
 */
static const char *
find_signature(const char *name, const char *doc)
{}

#define SIGNATURE_END_MARKER
#define SIGNATURE_END_MARKER_LENGTH
/*
 * skips past the end of the docstring's introspection signature.
 * (assumes doc starts with a valid signature prefix.)
 */
static const char *
skip_signature(const char *doc)
{}

int
_PyType_CheckConsistency(PyTypeObject *type)
{}

static const char *
_PyType_DocWithoutSignature(const char *name, const char *internal_doc)
{}

PyObject *
_PyType_GetDocFromInternalDoc(const char *name, const char *internal_doc)
{}

static const char *
signature_from_flags(int flags)
{}

PyObject *
_PyType_GetTextSignatureFromInternalDoc(const char *name, const char *internal_doc, int flags)
{}


static struct type_cache*
get_type_cache(void)
{}


static void
type_cache_clear(struct type_cache *cache, PyObject *value)
{}


void
_PyType_InitCache(PyInterpreterState *interp)
{}


static unsigned int
_PyType_ClearCache(PyInterpreterState *interp)
{}


unsigned int
PyType_ClearCache(void)
{}


void
_PyTypes_Fini(PyInterpreterState *interp)
{}


int
PyType_AddWatcher(PyType_WatchCallback callback)
{}

static inline int
validate_watcher_id(PyInterpreterState *interp, int watcher_id)
{}

int
PyType_ClearWatcher(int watcher_id)
{}

static int assign_version_tag(PyInterpreterState *interp, PyTypeObject *type);

int
PyType_Watch(int watcher_id, PyObject* obj)
{}

int
PyType_Unwatch(int watcher_id, PyObject* obj)
{}

static void
set_version_unlocked(PyTypeObject *tp, unsigned int version)
{}

static void
type_modified_unlocked(PyTypeObject *type)
{}

void
PyType_Modified(PyTypeObject *type)
{}

static int
is_subtype_with_mro(PyObject *a_mro, PyTypeObject *a, PyTypeObject *b);

static void
type_mro_modified(PyTypeObject *type, PyObject *bases) {}

/*
The Tier 2 interpreter requires looking up the type object by the type version, so it can install
watchers to understand when they change.

So we add a global cache from type version to borrowed references of type objects.

This is similar to func_version_cache.
*/

void
_PyType_SetVersion(PyTypeObject *tp, unsigned int version)
{}

PyTypeObject *
_PyType_LookupByVersion(unsigned int version)
{}

unsigned int
_PyType_GetVersionForCurrentState(PyTypeObject *tp)
{}



#define MAX_VERSIONS_PER_CLASS

static int
assign_version_tag(PyInterpreterState *interp, PyTypeObject *type)
{}

int PyUnstable_Type_AssignVersionTag(PyTypeObject *type)
{}


static PyMemberDef type_members[] =;

static int
check_set_special_type_attr(PyTypeObject *type, PyObject *value, const char *name)
{}

const char *
_PyType_Name(PyTypeObject *type)
{}

static PyObject *
type_name(PyTypeObject *type, void *context)
{}

static PyObject *
type_qualname(PyTypeObject *type, void *context)
{}

static int
type_set_name(PyTypeObject *type, PyObject *value, void *context)
{}

static int
type_set_qualname(PyTypeObject *type, PyObject *value, void *context)
{}

static PyObject *
type_module(PyTypeObject *type)
{}

static PyObject *
type_get_module(PyTypeObject *type, void *context)
{}

static int
type_set_module(PyTypeObject *type, PyObject *value, void *context)
{}


PyObject *
_PyType_GetFullyQualifiedName(PyTypeObject *type, char sep)
{}

PyObject *
PyType_GetFullyQualifiedName(PyTypeObject *type)
{}


static PyObject *
type_abstractmethods(PyTypeObject *type, void *context)
{}

static int
type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context)
{}

static PyObject *
type_get_bases(PyTypeObject *type, void *context)
{}

static PyObject *
type_get_mro(PyTypeObject *type, void *context)
{}

static PyTypeObject *best_base(PyObject *);
static int mro_internal(PyTypeObject *, PyObject **);
static int type_is_subtype_base_chain(PyTypeObject *, PyTypeObject *);
static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, const char *);
static int add_subclass(PyTypeObject*, PyTypeObject*);
static int add_all_subclasses(PyTypeObject *type, PyObject *bases);
static void remove_subclass(PyTypeObject *, PyTypeObject *);
static void remove_all_subclasses(PyTypeObject *type, PyObject *bases);
static void update_all_slots(PyTypeObject *);

update_callback;
static int update_subclasses(PyTypeObject *type, PyObject *attr_name,
                             update_callback callback, void *data);
static int recurse_down_subclasses(PyTypeObject *type, PyObject *name,
                                   update_callback callback, void *data);

static int
mro_hierarchy(PyTypeObject *type, PyObject *temp)
{}

static int
type_set_bases_unlocked(PyTypeObject *type, PyObject *new_bases, void *context)
{}

static int
type_set_bases(PyTypeObject *type, PyObject *new_bases, void *context)
{}

static PyObject *
type_dict(PyTypeObject *type, void *context)
{}

static PyObject *
type_get_doc(PyTypeObject *type, void *context)
{}

static PyObject *
type_get_text_signature(PyTypeObject *type, void *context)
{}

static int
type_set_doc(PyTypeObject *type, PyObject *value, void *context)
{}

static PyObject *
type_get_annotate(PyTypeObject *type, void *Py_UNUSED(ignored))
{}

static int
type_set_annotate(PyTypeObject *type, PyObject *value, void *Py_UNUSED(ignored))
{}

static PyObject *
type_get_annotations(PyTypeObject *type, void *context)
{}

static int
type_set_annotations(PyTypeObject *type, PyObject *value, void *context)
{}

static PyObject *
type_get_type_params(PyTypeObject *type, void *context)
{}

static int
type_set_type_params(PyTypeObject *type, PyObject *value, void *context)
{}


/*[clinic input]
type.__instancecheck__ -> bool

    instance: object
    /

Check if an object is an instance.
[clinic start generated code]*/

static int
type___instancecheck___impl(PyTypeObject *self, PyObject *instance)
/*[clinic end generated code: output=08b6bf5f591c3618 input=cdbfeaee82c01a0f]*/
{}

/*[clinic input]
type.__subclasscheck__ -> bool

    subclass: object
    /

Check if a class is a subclass.
[clinic start generated code]*/

static int
type___subclasscheck___impl(PyTypeObject *self, PyObject *subclass)
/*[clinic end generated code: output=97a4e51694500941 input=071b2ca9e03355f4]*/
{}


static PyGetSetDef type_getsets[] =;

static PyObject *
type_repr(PyObject *self)
{}

static PyObject *
type_call(PyObject *self, PyObject *args, PyObject *kwds)
{}

PyObject *
_PyType_NewManagedObject(PyTypeObject *type)
{}

PyObject *
_PyType_AllocNoTrack(PyTypeObject *type, Py_ssize_t nitems)
{}

PyObject *
PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
{}

PyObject *
PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
{}

/* Helpers for subtyping */

static inline PyMemberDef *
_PyHeapType_GET_MEMBERS(PyHeapTypeObject* type)
{}

static int
traverse_slots(PyTypeObject *type, PyObject *self, visitproc visit, void *arg)
{}

static int
subtype_traverse(PyObject *self, visitproc visit, void *arg)
{}

static void
clear_slots(PyTypeObject *type, PyObject *self)
{}

static int
subtype_clear(PyObject *self)
{}

static void
subtype_dealloc(PyObject *self)
{}

static PyTypeObject *solid_base(PyTypeObject *type);

/* type test with subclassing support */

static int
type_is_subtype_base_chain(PyTypeObject *a, PyTypeObject *b)
{}

static int
is_subtype_with_mro(PyObject *a_mro, PyTypeObject *a, PyTypeObject *b)
{}

int
PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b)
{}

/* Routines to do a method lookup in the type without looking in the
   instance dictionary (so we can't use PyObject_GetAttr) but still
   binding it to the instance.

   Variants:

   - _PyObject_LookupSpecial() returns NULL without raising an exception
     when the _PyType_LookupRef() call fails;

   - lookup_maybe_method() and lookup_method() are internal routines similar
     to _PyObject_LookupSpecial(), but can return unbound PyFunction
     to avoid temporary method object. Pass self as first argument when
     unbound == 1.
*/

PyObject *
_PyObject_LookupSpecial(PyObject *self, PyObject *attr)
{}

/* Steals a reference to self */
PyObject *
_PyObject_LookupSpecialMethod(PyObject *self, PyObject *attr, PyObject **self_or_null)
{}

static PyObject *
lookup_maybe_method(PyObject *self, PyObject *attr, int *unbound)
{}

static PyObject *
lookup_method(PyObject *self, PyObject *attr, int *unbound)
{}


static inline PyObject*
vectorcall_unbound(PyThreadState *tstate, int unbound, PyObject *func,
                   PyObject *const *args, Py_ssize_t nargs)
{}

static PyObject*
call_unbound_noarg(int unbound, PyObject *func, PyObject *self)
{}

/* A variation of PyObject_CallMethod* that uses lookup_method()
   instead of PyObject_GetAttrString().

   args is an argument vector of length nargs. The first element in this
   vector is the special object "self" which is used for the method lookup */
static PyObject *
vectorcall_method(PyObject *name, PyObject *const *args, Py_ssize_t nargs)
{}

/* Clone of vectorcall_method() that returns NotImplemented
 * when the lookup fails. */
static PyObject *
vectorcall_maybe(PyThreadState *tstate, PyObject *name,
                 PyObject *const *args, Py_ssize_t nargs)
{}

/*
    Method resolution order algorithm C3 described in
    "A Monotonic Superclass Linearization for Dylan",
    by Kim Barrett, Bob Cassel, Paul Haahr,
    David A. Moon, Keith Playford, and P. Tucker Withington.
    (OOPSLA 1996)

    Some notes about the rules implied by C3:

    No duplicate bases.
    It isn't legal to repeat a class in a list of base classes.

    The next three properties are the 3 constraints in "C3".

    Local precedence order.
    If A precedes B in C's MRO, then A will precede B in the MRO of all
    subclasses of C.

    Monotonicity.
    The MRO of a class must be an extension without reordering of the
    MRO of each of its superclasses.

    Extended Precedence Graph (EPG).
    Linearization is consistent if there is a path in the EPG from
    each class to all its successors in the linearization.  See
    the paper for definition of EPG.
 */

static int
tail_contains(PyObject *tuple, int whence, PyObject *o)
{}

static PyObject *
class_name(PyObject *cls)
{}

static int
check_duplicates(PyObject *tuple)
{}

/* Raise a TypeError for an MRO order disagreement.

   It's hard to produce a good error message.  In the absence of better
   insight into error reporting, report the classes that were candidates
   to be put next into the MRO.  There is some conflict between the
   order in which they should be put in the MRO, but it's hard to
   diagnose what constraint can't be satisfied.
*/

static void
set_mro_error(PyObject **to_merge, Py_ssize_t to_merge_size, int *remain)
{}

static int
pmerge(PyObject *acc, PyObject **to_merge, Py_ssize_t to_merge_size)
{}

static PyObject *
mro_implementation_unlocked(PyTypeObject *type)
{}

static PyObject *
mro_implementation(PyTypeObject *type)
{}

/*[clinic input]
type.mro

Return a type's method resolution order.
[clinic start generated code]*/

static PyObject *
type_mro_impl(PyTypeObject *self)
/*[clinic end generated code: output=bffc4a39b5b57027 input=28414f4e156db28d]*/
{}

static int
mro_check(PyTypeObject *type, PyObject *mro)
{}

/* Lookups an mcls.mro method, invokes it and checks the result (if needed,
   in case of a custom mro() implementation).

   Keep in mind that during execution of this function type->tp_mro
   can be replaced due to possible reentrance (for example,
   through type_set_bases):

      - when looking up the mcls.mro attribute (it could be
        a user-provided descriptor);

      - from inside a custom mro() itself;

      - through a finalizer of the return value of mro().
*/
static PyObject *
mro_invoke(PyTypeObject *type)
{}

/* Calculates and assigns a new MRO to type->tp_mro.
   Return values and invariants:

     - Returns 1 if a new MRO value has been set to type->tp_mro due to
       this call of mro_internal (no tricky reentrancy and no errors).

       In case if p_old_mro argument is not NULL, a previous value
       of type->tp_mro is put there, and the ownership of this
       reference is transferred to a caller.
       Otherwise, the previous value (if any) is decref'ed.

     - Returns 0 in case when type->tp_mro gets changed because of
       reentering here through a custom mro() (see a comment to mro_invoke).

       In this case, a refcount of an old type->tp_mro is adjusted
       somewhere deeper in the call stack (by the innermost mro_internal
       or its caller) and may become zero upon returning from here.
       This also implies that the whole hierarchy of subclasses of the type
       has seen the new value and updated their MRO accordingly.

     - Returns -1 in case of an error.
*/
static int
mro_internal_unlocked(PyTypeObject *type, int initial, PyObject **p_old_mro)
{}

static int
mro_internal(PyTypeObject *type, PyObject **p_old_mro)
{}

/* Calculate the best base amongst multiple base classes.
   This is the first one that's on the path to the "solid base". */

static PyTypeObject *
best_base(PyObject *bases)
{}

static int
shape_differs(PyTypeObject *t1, PyTypeObject *t2)
{}

static PyTypeObject *
solid_base(PyTypeObject *type)
{}

static void object_dealloc(PyObject *);
static PyObject *object_new(PyTypeObject *, PyObject *, PyObject *);
static int object_init(PyObject *, PyObject *, PyObject *);
static int update_slot(PyTypeObject *, PyObject *);
static void fixup_slot_dispatchers(PyTypeObject *);
static int type_new_set_names(PyTypeObject *);
static int type_new_init_subclass(PyTypeObject *, PyObject *);

/*
 * Helpers for  __dict__ descriptor.  We don't want to expose the dicts
 * inherited from various builtin types.  The builtin base usually provides
 * its own __dict__ descriptor, so we use that when we can.
 */
static PyTypeObject *
get_builtin_base_with_dict(PyTypeObject *type)
{}

static PyObject *
get_dict_descriptor(PyTypeObject *type)
{}

static void
raise_dict_descr_error(PyObject *obj)
{}

static PyObject *
subtype_dict(PyObject *obj, void *context)
{}

static int
subtype_setdict(PyObject *obj, PyObject *value, void *context)
{}

static PyObject *
subtype_getweakref(PyObject *obj, void *context)
{}

/* Three variants on the subtype_getsets list. */

static PyGetSetDef subtype_getsets_full[] =;

static PyGetSetDef subtype_getsets_dict_only[] =;

static PyGetSetDef subtype_getsets_weakref_only[] =;

static int
valid_identifier(PyObject *s)
{}

static int
type_init(PyObject *cls, PyObject *args, PyObject *kwds)
{}


unsigned long
PyType_GetFlags(PyTypeObject *type)
{}


int
PyType_SUPPORTS_WEAKREFS(PyTypeObject *type)
{}


/* Determine the most derived metatype. */
PyTypeObject *
_PyType_CalculateMetaclass(PyTypeObject *metatype, PyObject *bases)
{}


// Forward declaration
static PyObject *
type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds);

type_new_ctx;


/* Check for valid slot names and two special cases */
static int
type_new_visit_slots(type_new_ctx *ctx)
{}


/* Copy slots into a list, mangle names and sort them.
   Sorted names are needed for __class__ assignment.
   Convert them back to tuple at the end.
*/
static PyObject*
type_new_copy_slots(type_new_ctx *ctx, PyObject *dict)
{}


static void
type_new_slots_bases(type_new_ctx *ctx)
{}


static int
type_new_slots_impl(type_new_ctx *ctx, PyObject *dict)
{}


static Py_ssize_t
type_new_slots(type_new_ctx *ctx, PyObject *dict)
{}


static PyTypeObject*
type_new_alloc(type_new_ctx *ctx)
{}


static int
type_new_set_name(const type_new_ctx *ctx, PyTypeObject *type)
{}


/* Set __module__ in the dict */
static int
type_new_set_module(PyTypeObject *type)
{}


/* Set ht_qualname to dict['__qualname__'] if available, else to
   __name__.  The __qualname__ accessor will look for ht_qualname. */
static int
type_new_set_ht_name(PyTypeObject *type)
{}


/* Set tp_doc to a copy of dict['__doc__'], if the latter is there
   and is a string.  The __doc__ accessor will first look for tp_doc;
   if that fails, it will still look into __dict__. */
static int
type_new_set_doc(PyTypeObject *type)
{}


static int
type_new_staticmethod(PyTypeObject *type, PyObject *attr)
{}


static int
type_new_classmethod(PyTypeObject *type, PyObject *attr)
{}


/* Add descriptors for custom slots from __slots__, or for __dict__ */
static int
type_new_descriptors(const type_new_ctx *ctx, PyTypeObject *type)
{}


static void
type_new_set_slots(const type_new_ctx *ctx, PyTypeObject *type)
{}


/* store type in class' cell if one is supplied */
static int
type_new_set_classcell(PyTypeObject *type)
{}

static int
type_new_set_classdictcell(PyTypeObject *type)
{}

static int
type_new_set_attrs(const type_new_ctx *ctx, PyTypeObject *type)
{}


static int
type_new_get_slots(type_new_ctx *ctx, PyObject *dict)
{}


static PyTypeObject*
type_new_init(type_new_ctx *ctx)
{}


static PyObject*
type_new_impl(type_new_ctx *ctx)
{}


static int
type_new_get_bases(type_new_ctx *ctx, PyObject **type)
{}


static PyObject *
type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
{}


static PyObject *
type_vectorcall(PyObject *metatype, PyObject *const *args,
                 size_t nargsf, PyObject *kwnames)
{}

/* An array of type slot offsets corresponding to Py_tp_* constants,
  * for use in e.g. PyType_Spec and PyType_GetSlot.
  * Each entry has two offsets: "slot_offset" and "subslot_offset".
  * If is subslot_offset is -1, slot_offset is an offset within the
  * PyTypeObject struct.
  * Otherwise slot_offset is an offset to a pointer to a sub-slots struct
  * (such as "tp_as_number"), and subslot_offset is the offset within
  * that struct.
  * The actual table is generated by a script.
  */
static const PySlot_Offset pyslot_offsets[] =;

/* Align up to the nearest multiple of alignof(max_align_t)
 * (like _Py_ALIGN_UP, but for a size rather than pointer)
 */
static Py_ssize_t
_align_up(Py_ssize_t size)
{}

/* Given a PyType_FromMetaclass `bases` argument (NULL, type, or tuple of
 * types), return a tuple of types.
 */
inline static PyObject *
get_bases_tuple(PyObject *bases_in, PyType_Spec *spec)
{}

static inline int
check_basicsize_includes_size_and_offsets(PyTypeObject* type)
{}

static int
check_immutable_bases(const char *type_name, PyObject *bases, int skip_first)
{}


/* Set *dest to the offset specified by a special "__*offset__" member.
 * Return 0 on success, -1 on failure.
 */
static inline int
special_offset_from_member(
            const PyMemberDef *memb /* may be NULL */,
            Py_ssize_t type_data_offset,
            Py_ssize_t *dest /* not NULL */)
{}

PyObject *
PyType_FromMetaclass(
    PyTypeObject *metaclass, PyObject *module,
    PyType_Spec *spec, PyObject *bases_in)
{}

PyObject *
PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
{}

PyObject *
PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
{}

PyObject *
PyType_FromSpec(PyType_Spec *spec)
{}

PyObject *
PyType_GetName(PyTypeObject *type)
{}

PyObject *
PyType_GetQualName(PyTypeObject *type)
{}

PyObject *
PyType_GetModuleName(PyTypeObject *type)
{}

void *
PyType_GetSlot(PyTypeObject *type, int slot)
{}

PyObject *
PyType_GetModule(PyTypeObject *type)
{}

void *
PyType_GetModuleState(PyTypeObject *type)
{}


/* Get the module of the first superclass where the module has the
 * given PyModuleDef.
 */
PyObject *
PyType_GetModuleByDef(PyTypeObject *type, PyModuleDef *def)
{}


static PyTypeObject *
get_base_by_token_recursive(PyObject *bases, void *token)
{}

int
PyType_GetBaseByToken(PyTypeObject *type, void *token, PyTypeObject **result)
{}


void *
PyObject_GetTypeData(PyObject *obj, PyTypeObject *cls)
{}

Py_ssize_t
PyType_GetTypeDataSize(PyTypeObject *cls)
{}

void *
PyObject_GetItemData(PyObject *obj)
{}

/* Internal API to look for a name through the MRO, bypassing the method cache.
   This returns a borrowed reference, and might set an exception.
   'error' is set to: -1: error with exception; 1: error without exception; 0: ok */
static PyObject *
find_name_in_mro(PyTypeObject *type, PyObject *name, int *error)
{}

/* Check if the "readied" PyUnicode name
   is a double-underscore special name. */
static int
is_dunder_name(PyObject *name)
{}

static PyObject *
update_cache(struct type_cache_entry *entry, PyObject *name, unsigned int version_tag, PyObject *value)
{}

#if Py_GIL_DISABLED

static void
update_cache_gil_disabled(struct type_cache_entry *entry, PyObject *name,
                          unsigned int version_tag, PyObject *value)
{
    _PySeqLock_LockWrite(&entry->sequence);

    // update the entry
    if (entry->name == name &&
        entry->value == value &&
        entry->version == version_tag) {
        // We raced with another update, bail and restore previous sequence.
        _PySeqLock_AbandonWrite(&entry->sequence);
        return;
    }

    PyObject *old_value = update_cache(entry, name, version_tag, value);

    // Then update sequence to the next valid value
    _PySeqLock_UnlockWrite(&entry->sequence);

    Py_DECREF(old_value);
}

#endif

void
_PyTypes_AfterFork(void)
{}

/* Internal API to look for a name through the MRO.
   This returns a borrowed reference, and doesn't set an exception! */
PyObject *
_PyType_LookupRef(PyTypeObject *type, PyObject *name)
{}

PyObject *
_PyType_Lookup(PyTypeObject *type, PyObject *name)
{}

static void
set_flags(PyTypeObject *self, unsigned long mask, unsigned long flags)
{}

void
_PyType_SetFlags(PyTypeObject *self, unsigned long mask, unsigned long flags)
{}

int
_PyType_Validate(PyTypeObject *ty, _py_validate_type validate, unsigned int *tp_version)
{}

static void
set_flags_recursive(PyTypeObject *self, unsigned long mask, unsigned long flags)
{}

void
_PyType_SetFlagsRecursive(PyTypeObject *self, unsigned long mask, unsigned long flags)
{}

/* This is similar to PyObject_GenericGetAttr(),
   but uses _PyType_LookupRef() instead of just looking in type->tp_dict.

   The argument suppress_missing_attribute is used to provide a
   fast path for hasattr. The possible values are:

   * NULL: do not suppress the exception
   * Non-zero pointer: suppress the PyExc_AttributeError and
     set *suppress_missing_attribute to 1 to signal we are returning NULL while
     having suppressed the exception (other exceptions are not suppressed)

   */
PyObject *
_Py_type_getattro_impl(PyTypeObject *type, PyObject *name, int * suppress_missing_attribute)
{}

/* This is similar to PyObject_GenericGetAttr(),
   but uses _PyType_LookupRef() instead of just looking in type->tp_dict. */
PyObject *
_Py_type_getattro(PyObject *type, PyObject *name)
{}

static int
type_update_dict(PyTypeObject *type, PyDictObject *dict, PyObject *name,
                 PyObject *value, PyObject **old_value)
{}

static int
type_setattro(PyObject *self, PyObject *name, PyObject *value)
{}


static void
type_dealloc_common(PyTypeObject *type)
{}


static void
clear_static_tp_subclasses(PyTypeObject *type, int isbuiltin)
{}

static void
clear_static_type_objects(PyInterpreterState *interp, PyTypeObject *type,
                          int isbuiltin, int final)
{}


static void
fini_static_type(PyInterpreterState *interp, PyTypeObject *type,
                 int isbuiltin, int final)
{}

void
_PyTypes_FiniExtTypes(PyInterpreterState *interp)
{}

void
_PyStaticType_FiniBuiltin(PyInterpreterState *interp, PyTypeObject *type)
{}


static void
type_dealloc(PyObject *self)
{}


/*[clinic input]
type.__subclasses__

Return a list of immediate subclasses.
[clinic start generated code]*/

static PyObject *
type___subclasses___impl(PyTypeObject *self)
/*[clinic end generated code: output=eb5eb54485942819 input=5af66132436f9a7b]*/
{}

static PyObject *
type_prepare(PyObject *self, PyObject *const *args, Py_ssize_t nargs,
             PyObject *kwnames)
{}


/*
   Merge the __dict__ of aclass into dict, and recursively also all
   the __dict__s of aclass's base classes.  The order of merging isn't
   defined, as it's expected that only the final set of dict keys is
   interesting.
   Return 0 on success, -1 on error.
*/

static int
merge_class_dict(PyObject *dict, PyObject *aclass)
{}

/* __dir__ for type objects: returns __dict__ and __bases__.
   We deliberately don't suck up its __class__, as methods belonging to the
   metaclass would probably be more confusing than helpful.
*/
/*[clinic input]
type.__dir__

Specialized __dir__ implementation for types.
[clinic start generated code]*/

static PyObject *
type___dir___impl(PyTypeObject *self)
/*[clinic end generated code: output=69d02fe92c0f15fa input=7733befbec645968]*/
{}

/*[clinic input]
type.__sizeof__

Return memory consumption of the type object.
[clinic start generated code]*/

static PyObject *
type___sizeof___impl(PyTypeObject *self)
/*[clinic end generated code: output=766f4f16cd3b1854 input=99398f24b9cf45d6]*/
{}

static PyMethodDef type_methods[] =;

PyDoc_STRVAR(type_doc,
"type(object) -> the object's type\n"
"type(name, bases, dict, **kwds) -> a new type");

static int
type_traverse(PyObject *self, visitproc visit, void *arg)
{}

static int
type_clear(PyObject *self)
{}

static int
type_is_gc(PyObject *type)
{}


static PyNumberMethods type_as_number =;

PyTypeObject PyType_Type =;


/* The base type of all types (eventually)... except itself. */

/* You may wonder why object.__new__() only complains about arguments
   when object.__init__() is not overridden, and vice versa.

   Consider the use cases:

   1. When neither is overridden, we want to hear complaints about
      excess (i.e., any) arguments, since their presence could
      indicate there's a bug.

   2. When defining an Immutable type, we are likely to override only
      __new__(), since __init__() is called too late to initialize an
      Immutable object.  Since __new__() defines the signature for the
      type, it would be a pain to have to override __init__() just to
      stop it from complaining about excess arguments.

   3. When defining a Mutable type, we are likely to override only
      __init__().  So here the converse reasoning applies: we don't
      want to have to override __new__() just to stop it from
      complaining.

   4. When __init__() is overridden, and the subclass __init__() calls
      object.__init__(), the latter should complain about excess
      arguments; ditto for __new__().

   Use cases 2 and 3 make it unattractive to unconditionally check for
   excess arguments.  The best solution that addresses all four use
   cases is as follows: __init__() complains about excess arguments
   unless __new__() is overridden and __init__() is not overridden
   (IOW, if __init__() is overridden or __new__() is not overridden);
   symmetrically, __new__() complains about excess arguments unless
   __init__() is overridden and __new__() is not overridden
   (IOW, if __new__() is overridden or __init__() is not overridden).

   However, for backwards compatibility, this breaks too much code.
   Therefore, in 2.6, we'll *warn* about excess arguments when both
   methods are overridden; for all other cases we'll use the above
   rules.

*/

/* Forward */
static PyObject *
object_new(PyTypeObject *type, PyObject *args, PyObject *kwds);

static int
excess_args(PyObject *args, PyObject *kwds)
{}

static int
object_init(PyObject *self, PyObject *args, PyObject *kwds)
{}

static PyObject *
object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{}

static void
object_dealloc(PyObject *self)
{}

static PyObject *
object_repr(PyObject *self)
{}

static PyObject *
object_str(PyObject *self)
{}

static PyObject *
object_richcompare(PyObject *self, PyObject *other, int op)
{}

PyObject*
_Py_BaseObject_RichCompare(PyObject* self, PyObject* other, int op)
{}

static PyObject *
object_get_class(PyObject *self, void *closure)
{}

static int
compatible_with_tp_base(PyTypeObject *child)
{}

static int
same_slots_added(PyTypeObject *a, PyTypeObject *b)
{}

static int
compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, const char* attr)
{}



static int
object_set_class_world_stopped(PyObject *self, PyTypeObject *newto)
{}

static int
object_set_class(PyObject *self, PyObject *value, void *closure)
{}

static PyGetSetDef object_getsets[] =;


/* Stuff to implement __reduce_ex__ for pickle protocols >= 2.
   We fall back to helpers in copyreg for:
   - pickle protocols < 2
   - calculating the list of slot names (done only once per class)
   - the __newobj__ function (which is used as a token but never called)
*/

static PyObject *
import_copyreg(void)
{}

static PyObject *
_PyType_GetSlotNames(PyTypeObject *cls)
{}

static PyObject *
object_getstate_default(PyObject *obj, int required)
{}

static PyObject *
object_getstate(PyObject *obj, int required)
{}

PyObject *
_PyObject_GetState(PyObject *obj)
{}

/*[clinic input]
object.__getstate__

Helper for pickle.
[clinic start generated code]*/

static PyObject *
object___getstate___impl(PyObject *self)
/*[clinic end generated code: output=5a2500dcb6217e9e input=692314d8fbe194ee]*/
{}

static int
_PyObject_GetNewArguments(PyObject *obj, PyObject **args, PyObject **kwargs)
{}

static int
_PyObject_GetItemsIter(PyObject *obj, PyObject **listitems,
                       PyObject **dictitems)
{}

static PyObject *
reduce_newobj(PyObject *obj)
{}

/*
 * There were two problems when object.__reduce__ and object.__reduce_ex__
 * were implemented in the same function:
 *  - trying to pickle an object with a custom __reduce__ method that
 *    fell back to object.__reduce__ in certain circumstances led to
 *    infinite recursion at Python level and eventual RecursionError.
 *  - Pickling objects that lied about their type by overwriting the
 *    __class__ descriptor could lead to infinite recursion at C level
 *    and eventual segfault.
 *
 * Because of backwards compatibility, the two methods still have to
 * behave in the same way, even if this is not required by the pickle
 * protocol. This common functionality was moved to the _common_reduce
 * function.
 */
static PyObject *
_common_reduce(PyObject *self, int proto)
{}

/*[clinic input]
object.__reduce__

Helper for pickle.
[clinic start generated code]*/

static PyObject *
object___reduce___impl(PyObject *self)
/*[clinic end generated code: output=d4ca691f891c6e2f input=11562e663947e18b]*/
{}

/*[clinic input]
object.__reduce_ex__

  protocol: int
  /

Helper for pickle.
[clinic start generated code]*/

static PyObject *
object___reduce_ex___impl(PyObject *self, int protocol)
/*[clinic end generated code: output=2e157766f6b50094 input=f326b43fb8a4c5ff]*/
{}

static PyObject *
object_subclasshook(PyObject *cls, PyObject *args)
{}

PyDoc_STRVAR(object_subclasshook_doc,
"Abstract classes can override this to customize issubclass().\n"
"\n"
"This is invoked early on by abc.ABCMeta.__subclasscheck__().\n"
"It should return True, False or NotImplemented.  If it returns\n"
"NotImplemented, the normal algorithm is used.  Otherwise, it\n"
"overrides the normal algorithm (and the outcome is cached).\n");

static PyObject *
object_init_subclass(PyObject *cls, PyObject *arg)
{}

PyDoc_STRVAR(object_init_subclass_doc,
"This method is called when a class is subclassed.\n"
"\n"
"The default implementation does nothing. It may be\n"
"overridden to extend subclasses.\n");

/*[clinic input]
object.__format__

  format_spec: unicode
  /

Default object formatter.

Return str(self) if format_spec is empty. Raise TypeError otherwise.
[clinic start generated code]*/

static PyObject *
object___format___impl(PyObject *self, PyObject *format_spec)
/*[clinic end generated code: output=34897efb543a974b input=b94d8feb006689ea]*/
{}

/*[clinic input]
object.__sizeof__

Size of object in memory, in bytes.
[clinic start generated code]*/

static PyObject *
object___sizeof___impl(PyObject *self)
/*[clinic end generated code: output=73edab332f97d550 input=1200ff3dfe485306]*/
{}

/* __dir__ for generic objects: returns __dict__, __class__,
   and recursively up the __class__.__bases__ chain.
*/
/*[clinic input]
object.__dir__

Default dir() implementation.
[clinic start generated code]*/

static PyObject *
object___dir___impl(PyObject *self)
/*[clinic end generated code: output=66dd48ea62f26c90 input=0a89305bec669b10]*/
{}

static PyMethodDef object_methods[] =;

PyDoc_STRVAR(object_doc,
"object()\n--\n\n"
"The base class of the class hierarchy.\n\n"
"When called, it accepts no arguments and returns a new featureless\n"
"instance that has no instance attributes and cannot be given any.\n");

PyTypeObject PyBaseObject_Type =;


static int
type_add_method(PyTypeObject *type, PyMethodDef *meth)
{}

int
_PyType_AddMethod(PyTypeObject *type, PyMethodDef *meth)
{}


/* Add the methods from tp_methods to the __dict__ in a type object */
static int
type_add_methods(PyTypeObject *type)
{}


static int
type_add_members(PyTypeObject *type)
{}


static int
type_add_getset(PyTypeObject *type)
{}


static void
inherit_special(PyTypeObject *type, PyTypeObject *base)
{}

static int
overrides_hash(PyTypeObject *type)
{}

static int
inherit_slots(PyTypeObject *type, PyTypeObject *base)
{}

static int add_operators(PyTypeObject *type);
static int add_tp_new_wrapper(PyTypeObject *type);

#define COLLECTION_FLAGS

static int
type_ready_pre_checks(PyTypeObject *type)
{}


static int
type_ready_set_base(PyTypeObject *type)
{}

static int
type_ready_set_type(PyTypeObject *type)
{}

static int
type_ready_set_bases(PyTypeObject *type, int initial)
{}


static int
type_ready_set_dict(PyTypeObject *type)
{}


/* If the type dictionary doesn't contain a __doc__, set it from
   the tp_doc slot. */
static int
type_dict_set_doc(PyTypeObject *type)
{}


static int
type_ready_fill_dict(PyTypeObject *type)
{}

static int
type_ready_preheader(PyTypeObject *type)
{}

static int
type_ready_mro(PyTypeObject *type, int initial)
{}


// For static types, inherit tp_as_xxx structures from the base class
// if it's NULL.
//
// For heap types, tp_as_xxx structures are not NULL: they are set to the
// PyHeapTypeObject.as_xxx fields by type_new_alloc().
static void
type_ready_inherit_as_structs(PyTypeObject *type, PyTypeObject *base)
{}

static void
inherit_patma_flags(PyTypeObject *type, PyTypeObject *base) {}

static int
type_ready_inherit(PyTypeObject *type)
{}


/* Hack for tp_hash and __hash__.
   If after all that, tp_hash is still NULL, and __hash__ is not in
   tp_dict, set tp_hash to PyObject_HashNotImplemented and
   tp_dict['__hash__'] equal to None.
   This signals that __hash__ is not inherited. */
static int
type_ready_set_hash(PyTypeObject *type)
{}


/* Link into each base class's list of subclasses */
static int
type_ready_add_subclasses(PyTypeObject *type)
{}


// Set tp_new and the "__new__" key in the type dictionary.
// Use the Py_TPFLAGS_DISALLOW_INSTANTIATION flag.
static int
type_ready_set_new(PyTypeObject *type, int initial)
{}

static int
type_ready_managed_dict(PyTypeObject *type)
{}

static int
type_ready_post_checks(PyTypeObject *type)
{}


static int
type_ready(PyTypeObject *type, int initial)
{}

int
PyType_Ready(PyTypeObject *type)
{}


static int
init_static_type(PyInterpreterState *interp, PyTypeObject *self,
                 int isbuiltin, int initial)
{}

int
_PyStaticType_InitForExtension(PyInterpreterState *interp, PyTypeObject *self)
{}

int
_PyStaticType_InitBuiltin(PyInterpreterState *interp, PyTypeObject *self)
{}


static int
add_subclass(PyTypeObject *base, PyTypeObject *type)
{}

static int
add_all_subclasses(PyTypeObject *type, PyObject *bases)
{}

static PyObject *
get_subclasses_key(PyTypeObject *type, PyTypeObject *base)
{}

static void
remove_subclass(PyTypeObject *base, PyTypeObject *type)
{}

static void
remove_all_subclasses(PyTypeObject *type, PyObject *bases)
{}

static int
check_num_args(PyObject *ob, int n)
{}

static Py_ssize_t
check_pow_args(PyObject *ob)
{}

/* Generic wrappers for overloadable 'operators' such as __getitem__ */

/* There's a wrapper *function* for each distinct function typedef used
   for type object slots (e.g. binaryfunc, ternaryfunc, etc.).  There's a
   wrapper *table* for each distinct operation (e.g. __len__, __add__).
   Most tables have only one entry; the tables for binary operators have two
   entries, one regular and one with reversed arguments. */

static PyObject *
wrap_lenfunc(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_inquirypred(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_binaryfunc(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_binaryfunc_l(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_binaryfunc_r(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_ternaryfunc(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_ternaryfunc_r(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_unaryfunc(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_indexargfunc(PyObject *self, PyObject *args, void *wrapped)
{}

static Py_ssize_t
getindex(PyObject *self, PyObject *arg)
{}

static PyObject *
wrap_sq_item(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_sq_delitem(PyObject *self, PyObject *args, void *wrapped)
{}

/* XXX objobjproc is a misnomer; should be objargpred */
static PyObject *
wrap_objobjproc(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_objobjargproc(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_delitem(PyObject *self, PyObject *args, void *wrapped)
{}

/* Helper to check for object.__setattr__ or __delattr__ applied to a type.
   This is called the Carlo Verre hack after its discoverer.  See
   https://mail.python.org/pipermail/python-dev/2003-April/034535.html
   */
static int
hackcheck_unlocked(PyObject *self, setattrofunc func, const char *what)
{}

static int
hackcheck(PyObject *self, setattrofunc func, const char *what)
{}

static PyObject *
wrap_setattr(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_delattr(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_hashfunc(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_call(PyObject *self, PyObject *args, void *wrapped, PyObject *kwds)
{}

static PyObject *
wrap_del(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_richcmpfunc(PyObject *self, PyObject *args, void *wrapped, int op)
{}

#undef RICHCMP_WRAPPER
#define RICHCMP_WRAPPER(NAME, OP)

RICHCMP_WRAPPER(lt, Py_LT)
RICHCMP_WRAPPER(le, Py_LE)
RICHCMP_WRAPPER(eq, Py_EQ)
RICHCMP_WRAPPER(ne, Py_NE)
RICHCMP_WRAPPER(gt, Py_GT)
RICHCMP_WRAPPER(ge, Py_GE)

static PyObject *
wrap_next(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_descr_get(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_descr_set(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_descr_delete(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_buffer(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_releasebuffer(PyObject *self, PyObject *args, void *wrapped)
{}

static PyObject *
wrap_init(PyObject *self, PyObject *args, void *wrapped, PyObject *kwds)
{}

static PyObject *
tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
{}

static struct PyMethodDef tp_new_methoddef[] =;

static int
add_tp_new_wrapper(PyTypeObject *type)
{}

/* Slot wrappers that call the corresponding __foo__ slot.  See comments
   below at override_slots() for more explanation. */

#define SLOT0(FUNCNAME, DUNDER)

#define SLOT1(FUNCNAME, DUNDER, ARG1TYPE)

/* Boolean helper for SLOT1BINFULL().
   right.__class__ is a nontrivial subclass of left.__class__. */
static int
method_is_overloaded(PyObject *left, PyObject *right, PyObject *name)
{}


#define SLOT1BINFULL(FUNCNAME, TESTFUNC, SLOTNAME, DUNDER, RDUNDER)

#define SLOT1BIN(FUNCNAME, SLOTNAME, DUNDER, RDUNDER)

static Py_ssize_t
slot_sq_length(PyObject *self)
{}

static PyObject *
slot_sq_item(PyObject *self, Py_ssize_t i)
{}

static int
slot_sq_ass_item(PyObject *self, Py_ssize_t index, PyObject *value)
{}

static int
slot_sq_contains(PyObject *self, PyObject *value)
{}

#define slot_mp_length

SLOT1(slot_mp_subscript, __getitem__, PyObject *)

static int
slot_mp_ass_subscript(PyObject *self, PyObject *key, PyObject *value)
{}

SLOT1BIN()
SLOT1BIN()
SLOT1BIN()
SLOT1BIN()
SLOT1BIN()
SLOT1BIN()

static PyObject *slot_nb_power(PyObject *, PyObject *, PyObject *);

SLOT1BINFULL()

static PyObject *
slot_nb_power(PyObject *self, PyObject *other, PyObject *modulus)
{}

SLOT0()
SLOT0()
SLOT0()

static int
slot_nb_bool(PyObject *self)
{}


static PyObject *
slot_nb_index(PyObject *self)
{}


SLOT0()
SLOT1BIN()
SLOT1BIN()
SLOT1BIN()
SLOT1BIN()
SLOT1BIN()

SLOT0()
SLOT0()
SLOT1(slot_nb_inplace_add, __iadd__, PyObject *)
SLOT1(slot_nb_inplace_subtract, __isub__, PyObject *)
SLOT1(slot_nb_inplace_multiply, __imul__, PyObject *)
SLOT1(slot_nb_inplace_matrix_multiply, __imatmul__, PyObject *)
SLOT1(slot_nb_inplace_remainder, __imod__, PyObject *)
/* Can't use SLOT1 here, because nb_inplace_power is ternary */
static PyObject *
slot_nb_inplace_power(PyObject *self, PyObject * arg1, PyObject *arg2)
{}
SLOT1(slot_nb_inplace_lshift, __ilshift__, PyObject *)
SLOT1(slot_nb_inplace_rshift, __irshift__, PyObject *)
SLOT1(slot_nb_inplace_and, __iand__, PyObject *)
SLOT1(slot_nb_inplace_xor, __ixor__, PyObject *)
SLOT1(slot_nb_inplace_or, __ior__, PyObject *)
SLOT1BIN()
SLOT1BIN()
SLOT1(slot_nb_inplace_floor_divide, __ifloordiv__, PyObject *)
SLOT1(slot_nb_inplace_true_divide, __itruediv__, PyObject *)

static PyObject *
slot_tp_repr(PyObject *self)
{}

SLOT0()

static Py_hash_t
slot_tp_hash(PyObject *self)
{}

static PyObject *
slot_tp_call(PyObject *self, PyObject *args, PyObject *kwds)
{}

/* There are two slot dispatch functions for tp_getattro.

   - _Py_slot_tp_getattro() is used when __getattribute__ is overridden
     but no __getattr__ hook is present;

   - _Py_slot_tp_getattr_hook() is used when a __getattr__ hook is present.

   The code in update_one_slot() always installs _Py_slot_tp_getattr_hook();
   this detects the absence of __getattr__ and then installs the simpler
   slot if necessary. */

PyObject *
_Py_slot_tp_getattro(PyObject *self, PyObject *name)
{}

static inline PyObject *
call_attribute(PyObject *self, PyObject *attr, PyObject *name)
{}

PyObject *
_Py_slot_tp_getattr_hook(PyObject *self, PyObject *name)
{}

static int
slot_tp_setattro(PyObject *self, PyObject *name, PyObject *value)
{}

static PyObject *name_op[] =;

static PyObject *
slot_tp_richcompare(PyObject *self, PyObject *other, int op)
{}

static PyObject *
slot_tp_iter(PyObject *self)
{}

static PyObject *
slot_tp_iternext(PyObject *self)
{}

static PyObject *
slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type)
{}

static int
slot_tp_descr_set(PyObject *self, PyObject *target, PyObject *value)
{}

static int
slot_tp_init(PyObject *self, PyObject *args, PyObject *kwds)
{}

static PyObject *
slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{}

static void
slot_tp_finalize(PyObject *self)
{}

PyBufferWrapper;

static int
bufferwrapper_traverse(PyBufferWrapper *self, visitproc visit, void *arg)
{}

static void
bufferwrapper_dealloc(PyObject *self)
{}

static void
bufferwrapper_releasebuf(PyObject *self, Py_buffer *view)
{}

static PyBufferProcs bufferwrapper_as_buffer =;


PyTypeObject _PyBufferWrapper_Type =;

static int
slot_bf_getbuffer(PyObject *self, Py_buffer *buffer, int flags)
{}

static releasebufferproc
releasebuffer_maybe_call_super_unlocked(PyObject *self, Py_buffer *buffer)
{}

static void
releasebuffer_maybe_call_super(PyObject *self, Py_buffer *buffer)
{}

static void
releasebuffer_call_python(PyObject *self, Py_buffer *buffer)
{}

/*
 * bf_releasebuffer is very delicate, because we need to ensure that
 * C bf_releasebuffer slots are called correctly (or we'll leak memory),
 * but we cannot trust any __release_buffer__ implemented in Python to
 * do so correctly. Therefore, if a base class has a C bf_releasebuffer
 * slot, we call it directly here. That is safe because this function
 * only gets called from C callers of the bf_releasebuffer slot. Python
 * code that calls __release_buffer__ directly instead goes through
 * wrap_releasebuffer(), which doesn't call the bf_releasebuffer slot
 * directly but instead simply releases the associated memoryview.
 */
static void
slot_bf_releasebuffer(PyObject *self, Py_buffer *buffer)
{}

static PyObject *
slot_am_await(PyObject *self)
{}

static PyObject *
slot_am_aiter(PyObject *self)
{}

static PyObject *
slot_am_anext(PyObject *self)
{}

/*
Table mapping __foo__ names to tp_foo offsets and slot_tp_foo wrapper functions.

The table is ordered by offsets relative to the 'PyHeapTypeObject' structure,
which incorporates the additional structures used for numbers, sequences and
mappings.  Note that multiple names may map to the same slot (e.g. __eq__,
__ne__ etc. all map to tp_richcompare) and one name may map to multiple slots
(e.g. __str__ affects tp_str as well as tp_repr). The table is terminated with
an all-zero entry.
*/

#undef TPSLOT
#undef FLSLOT
#undef BUFSLOT
#undef AMSLOT
#undef ETSLOT
#undef SQSLOT
#undef MPSLOT
#undef NBSLOT
#undef UNSLOT
#undef IBSLOT
#undef BINSLOT
#undef RBINSLOT

#define TPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC)
#define FLSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC, FLAGS)
#define ETSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC)
#define BUFSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC)
#define AMSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC)
#define SQSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC)
#define MPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC)
#define NBSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC)
#define UNSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC)
#define IBSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC)
#define BINSLOT(NAME, SLOT, FUNCTION, DOC)
#define RBINSLOT(NAME, SLOT, FUNCTION, DOC)
#define BINSLOTNOTINFIX(NAME, SLOT, FUNCTION, DOC)
#define RBINSLOTNOTINFIX(NAME, SLOT, FUNCTION, DOC)

static pytype_slotdef slotdefs[] =;

/* Given a type pointer and an offset gotten from a slotdef entry, return a
   pointer to the actual slot.  This is not quite the same as simply adding
   the offset to the type pointer, since it takes care to indirect through the
   proper indirection pointer (as_buffer, etc.); it returns NULL if the
   indirection pointer is NULL. */
static void **
slotptr(PyTypeObject *type, int ioffset)
{}

/* Return a slot pointer for a given name, but ONLY if the attribute has
   exactly one slot function.  The name must be an interned string. */
static void **
resolve_slotdups(PyTypeObject *type, PyObject *name)
{}


/* Common code for update_slots_callback() and fixup_slot_dispatchers().
 *
 * This is meant to set a "slot" like type->tp_repr or
 * type->tp_as_sequence->sq_concat by looking up special methods like
 * __repr__ or __add__. The opposite (adding special methods from slots) is
 * done by add_operators(), called from PyType_Ready(). Since update_one_slot()
 * calls PyType_Ready() if needed, the special methods are already in place.
 *
 * The special methods corresponding to each slot are defined in the "slotdef"
 * array. Note that one slot may correspond to multiple special methods and vice
 * versa. For example, tp_richcompare uses 6 methods __lt__, ..., __ge__ and
 * tp_as_number->nb_add uses __add__ and __radd__. In the other direction,
 * __add__ is used by the number and sequence protocols and __getitem__ by the
 * sequence and mapping protocols. This causes a lot of complications.
 *
 * In detail, update_one_slot() does the following:
 *
 * First of all, if the slot in question does not exist, return immediately.
 * This can happen for example if it's tp_as_number->nb_add but tp_as_number
 * is NULL.
 *
 * For the given slot, we loop over all the special methods with a name
 * corresponding to that slot (for example, for tp_descr_set, this would be
 * __set__ and __delete__) and we look up these names in the MRO of the type.
 * If we don't find any special method, the slot is set to NULL (regardless of
 * what was in the slot before).
 *
 * Suppose that we find exactly one special method. If it's a wrapper_descriptor
 * (i.e. a special method calling a slot, for example str.__repr__ which calls
 * the tp_repr for the 'str' class) with the correct name ("__repr__" for
 * tp_repr), for the right class, calling the right wrapper C function (like
 * wrap_unaryfunc for tp_repr), then the slot is set to the slot that the
 * wrapper_descriptor originally wrapped. For example, a class inheriting
 * from 'str' and not redefining __repr__ will have tp_repr set to the tp_repr
 * of 'str'.
 * In all other cases where the special method exists, the slot is set to a
 * wrapper calling the special method. There is one exception: if the special
 * method is a wrapper_descriptor with the correct name but the type has
 * precisely one slot set for that name and that slot is not the one that we
 * are updating, then NULL is put in the slot (this exception is the only place
 * in update_one_slot() where the *existing* slots matter).
 *
 * When there are multiple special methods for the same slot, the above is
 * applied for each special method. As long as the results agree, the common
 * resulting slot is applied. If the results disagree, then a wrapper for
 * the special methods is installed. This is always safe, but less efficient
 * because it uses method lookup instead of direct C calls.
 *
 * There are some further special cases for specific slots, like supporting
 * __hash__ = None for tp_hash and special code for tp_new.
 *
 * When done, return a pointer to the next slotdef with a different offset,
 * because that's convenient for fixup_slot_dispatchers(). This function never
 * sets an exception: if an internal error happens (unlikely), it's ignored. */
static pytype_slotdef *
update_one_slot(PyTypeObject *type, pytype_slotdef *p)
{}

/* In the type, update the slots whose slotdefs are gathered in the pp array.
   This is a callback for update_subclasses(). */
static int
update_slots_callback(PyTypeObject *type, void *data)
{}

/* Update the slots after assignment to a class (type) attribute. */
static int
update_slot(PyTypeObject *type, PyObject *name)
{}

/* Store the proper functions in the slot dispatches at class (type)
   definition time, based upon which operations the class overrides in its
   dict. */
static void
fixup_slot_dispatchers(PyTypeObject *type)
{}

static void
update_all_slots(PyTypeObject* type)
{}


PyObject *
_PyType_GetSlotWrapperNames(void)
{}


/* Call __set_name__ on all attributes (including descriptors)
  in a newly generated type */
static int
type_new_set_names(PyTypeObject *type)
{}


/* Call __init_subclass__ on the parent of a newly generated type */
static int
type_new_init_subclass(PyTypeObject *type, PyObject *kwds)
{}


/* recurse_down_subclasses() and update_subclasses() are mutually
   recursive functions to call a callback for all subclasses,
   but refraining from recursing into subclasses that define 'attr_name'. */

static int
update_subclasses(PyTypeObject *type, PyObject *attr_name,
                  update_callback callback, void *data)
{}

static int
recurse_down_subclasses(PyTypeObject *type, PyObject *attr_name,
                        update_callback callback, void *data)
{}

static int
slot_inherited(PyTypeObject *type, pytype_slotdef *slotdef, void **slot)
{}

/* This function is called by PyType_Ready() to populate the type's
   dictionary with method descriptors for function slots.  For each
   function slot (like tp_repr) that's defined in the type, one or more
   corresponding descriptors are added in the type's tp_dict dictionary
   under the appropriate name (like __repr__).  Some function slots
   cause more than one descriptor to be added (for example, the nb_add
   slot adds both __add__ and __radd__ descriptors) and some function
   slots compete for the same descriptor (for example both sq_item and
   mp_subscript generate a __getitem__ descriptor).

   In the latter case, the first slotdef entry encountered wins.  Since
   slotdef entries are sorted by the offset of the slot in the
   PyHeapTypeObject, this gives us some control over disambiguating
   between competing slots: the members of PyHeapTypeObject are listed
   from most general to least general, so the most general slot is
   preferred.  In particular, because as_mapping comes before as_sequence,
   for a type that defines both mp_subscript and sq_item, mp_subscript
   wins.

   This only adds new descriptors and doesn't overwrite entries in
   tp_dict that were previously defined.  The descriptors contain a
   reference to the C function they must call, so that it's safe if they
   are copied into a subtype's __dict__ and the subtype has a different
   C function in its slot -- calling the method defined by the
   descriptor will call the C function that was used to create it,
   rather than the C function present in the slot when it is called.
   (This is important because a subtype may have a C function in the
   slot that calls the method from the dictionary, and we want to avoid
   infinite recursion here.) */

static int
add_operators(PyTypeObject *type)
{}


int
PyType_Freeze(PyTypeObject *type)
{}


/* Cooperative 'super' */

superobject;

static PyMemberDef super_members[] =;

static void
super_dealloc(PyObject *self)
{}

static PyObject *
super_repr(PyObject *self)
{}

/* Do a super lookup without executing descriptors or falling back to getattr
on the super object itself.

May return NULL with or without an exception set, like PyDict_GetItemWithError. */
static PyObject *
_super_lookup_descr(PyTypeObject *su_type, PyTypeObject *su_obj_type, PyObject *name)
{}

// if `method` is non-NULL, we are looking for a method descriptor,
// and setting `*method = 1` means we found one.
static PyObject *
do_super_lookup(superobject *su, PyTypeObject *su_type, PyObject *su_obj,
                PyTypeObject *su_obj_type, PyObject *name, int *method)
{}

static PyObject *
super_getattro(PyObject *self, PyObject *name)
{}

static PyTypeObject *
supercheck(PyTypeObject *type, PyObject *obj)
{}

PyObject *
_PySuper_Lookup(PyTypeObject *su_type, PyObject *su_obj, PyObject *name, int *method)
{}

static PyObject *
super_descr_get(PyObject *self, PyObject *obj, PyObject *type)
{}

static int
super_init_without_args(_PyInterpreterFrame *cframe, PyTypeObject **type_p,
                        PyObject **obj_p)
{}

static int super_init_impl(PyObject *self, PyTypeObject *type, PyObject *obj);

static int
super_init(PyObject *self, PyObject *args, PyObject *kwds)
{}

static inline int
super_init_impl(PyObject *self, PyTypeObject *type, PyObject *obj) {}

PyDoc_STRVAR(super_doc,
"super() -> same as super(__class__, <first argument>)\n"
"super(type) -> unbound super object\n"
"super(type, obj) -> bound super object; requires isinstance(obj, type)\n"
"super(type, type2) -> bound super object; requires issubclass(type2, type)\n"
"Typical use to call a cooperative superclass method:\n"
"class C(B):\n"
"    def meth(self, arg):\n"
"        super().meth(arg)\n"
"This works for class methods too:\n"
"class C(B):\n"
"    @classmethod\n"
"    def cmeth(cls, arg):\n"
"        super().cmeth(arg)\n");

static int
super_traverse(PyObject *self, visitproc visit, void *arg)
{}

static PyObject *
super_vectorcall(PyObject *self, PyObject *const *args,
    size_t nargsf, PyObject *kwnames)
{}

PyTypeObject PySuper_Type =;