Home | History | Annotate | Download | only in clinic
      1 /*[clinic input]
      2 preserve
      3 [clinic start generated code]*/
      4 
      5 PyDoc_STRVAR(builtin_abs__doc__,
      6 "abs($module, x, /)\n"
      7 "--\n"
      8 "\n"
      9 "Return the absolute value of the argument.");
     10 
     11 #define BUILTIN_ABS_METHODDEF    \
     12     {"abs", (PyCFunction)builtin_abs, METH_O, builtin_abs__doc__},
     13 
     14 PyDoc_STRVAR(builtin_all__doc__,
     15 "all($module, iterable, /)\n"
     16 "--\n"
     17 "\n"
     18 "Return True if bool(x) is True for all values x in the iterable.\n"
     19 "\n"
     20 "If the iterable is empty, return True.");
     21 
     22 #define BUILTIN_ALL_METHODDEF    \
     23     {"all", (PyCFunction)builtin_all, METH_O, builtin_all__doc__},
     24 
     25 PyDoc_STRVAR(builtin_any__doc__,
     26 "any($module, iterable, /)\n"
     27 "--\n"
     28 "\n"
     29 "Return True if bool(x) is True for any x in the iterable.\n"
     30 "\n"
     31 "If the iterable is empty, return False.");
     32 
     33 #define BUILTIN_ANY_METHODDEF    \
     34     {"any", (PyCFunction)builtin_any, METH_O, builtin_any__doc__},
     35 
     36 PyDoc_STRVAR(builtin_ascii__doc__,
     37 "ascii($module, obj, /)\n"
     38 "--\n"
     39 "\n"
     40 "Return an ASCII-only representation of an object.\n"
     41 "\n"
     42 "As repr(), return a string containing a printable representation of an\n"
     43 "object, but escape the non-ASCII characters in the string returned by\n"
     44 "repr() using \\\\x, \\\\u or \\\\U escapes. This generates a string similar\n"
     45 "to that returned by repr() in Python 2.");
     46 
     47 #define BUILTIN_ASCII_METHODDEF    \
     48     {"ascii", (PyCFunction)builtin_ascii, METH_O, builtin_ascii__doc__},
     49 
     50 PyDoc_STRVAR(builtin_bin__doc__,
     51 "bin($module, number, /)\n"
     52 "--\n"
     53 "\n"
     54 "Return the binary representation of an integer.\n"
     55 "\n"
     56 "   >>> bin(2796202)\n"
     57 "   \'0b1010101010101010101010\'");
     58 
     59 #define BUILTIN_BIN_METHODDEF    \
     60     {"bin", (PyCFunction)builtin_bin, METH_O, builtin_bin__doc__},
     61 
     62 PyDoc_STRVAR(builtin_callable__doc__,
     63 "callable($module, obj, /)\n"
     64 "--\n"
     65 "\n"
     66 "Return whether the object is callable (i.e., some kind of function).\n"
     67 "\n"
     68 "Note that classes are callable, as are instances of classes with a\n"
     69 "__call__() method.");
     70 
     71 #define BUILTIN_CALLABLE_METHODDEF    \
     72     {"callable", (PyCFunction)builtin_callable, METH_O, builtin_callable__doc__},
     73 
     74 PyDoc_STRVAR(builtin_format__doc__,
     75 "format($module, value, format_spec=\'\', /)\n"
     76 "--\n"
     77 "\n"
     78 "Return value.__format__(format_spec)\n"
     79 "\n"
     80 "format_spec defaults to the empty string");
     81 
     82 #define BUILTIN_FORMAT_METHODDEF    \
     83     {"format", (PyCFunction)builtin_format, METH_VARARGS, builtin_format__doc__},
     84 
     85 static PyObject *
     86 builtin_format_impl(PyObject *module, PyObject *value, PyObject *format_spec);
     87 
     88 static PyObject *
     89 builtin_format(PyObject *module, PyObject *args)
     90 {
     91     PyObject *return_value = NULL;
     92     PyObject *value;
     93     PyObject *format_spec = NULL;
     94 
     95     if (!PyArg_ParseTuple(args, "O|U:format",
     96         &value, &format_spec)) {
     97         goto exit;
     98     }
     99     return_value = builtin_format_impl(module, value, format_spec);
    100 
    101 exit:
    102     return return_value;
    103 }
    104 
    105 PyDoc_STRVAR(builtin_chr__doc__,
    106 "chr($module, i, /)\n"
    107 "--\n"
    108 "\n"
    109 "Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff.");
    110 
    111 #define BUILTIN_CHR_METHODDEF    \
    112     {"chr", (PyCFunction)builtin_chr, METH_O, builtin_chr__doc__},
    113 
    114 static PyObject *
    115 builtin_chr_impl(PyObject *module, int i);
    116 
    117 static PyObject *
    118 builtin_chr(PyObject *module, PyObject *arg)
    119 {
    120     PyObject *return_value = NULL;
    121     int i;
    122 
    123     if (!PyArg_Parse(arg, "i:chr", &i)) {
    124         goto exit;
    125     }
    126     return_value = builtin_chr_impl(module, i);
    127 
    128 exit:
    129     return return_value;
    130 }
    131 
    132 PyDoc_STRVAR(builtin_compile__doc__,
    133 "compile($module, /, source, filename, mode, flags=0,\n"
    134 "        dont_inherit=False, optimize=-1)\n"
    135 "--\n"
    136 "\n"
    137 "Compile source into a code object that can be executed by exec() or eval().\n"
    138 "\n"
    139 "The source code may represent a Python module, statement or expression.\n"
    140 "The filename will be used for run-time error messages.\n"
    141 "The mode must be \'exec\' to compile a module, \'single\' to compile a\n"
    142 "single (interactive) statement, or \'eval\' to compile an expression.\n"
    143 "The flags argument, if present, controls which future statements influence\n"
    144 "the compilation of the code.\n"
    145 "The dont_inherit argument, if true, stops the compilation inheriting\n"
    146 "the effects of any future statements in effect in the code calling\n"
    147 "compile; if absent or false these statements do influence the compilation,\n"
    148 "in addition to any features explicitly specified.");
    149 
    150 #define BUILTIN_COMPILE_METHODDEF    \
    151     {"compile", (PyCFunction)builtin_compile, METH_FASTCALL, builtin_compile__doc__},
    152 
    153 static PyObject *
    154 builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
    155                      const char *mode, int flags, int dont_inherit,
    156                      int optimize);
    157 
    158 static PyObject *
    159 builtin_compile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    160 {
    161     PyObject *return_value = NULL;
    162     static const char * const _keywords[] = {"source", "filename", "mode", "flags", "dont_inherit", "optimize", NULL};
    163     static _PyArg_Parser _parser = {"OO&s|iii:compile", _keywords, 0};
    164     PyObject *source;
    165     PyObject *filename;
    166     const char *mode;
    167     int flags = 0;
    168     int dont_inherit = 0;
    169     int optimize = -1;
    170 
    171     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    172         &source, PyUnicode_FSDecoder, &filename, &mode, &flags, &dont_inherit, &optimize)) {
    173         goto exit;
    174     }
    175     return_value = builtin_compile_impl(module, source, filename, mode, flags, dont_inherit, optimize);
    176 
    177 exit:
    178     return return_value;
    179 }
    180 
    181 PyDoc_STRVAR(builtin_divmod__doc__,
    182 "divmod($module, x, y, /)\n"
    183 "--\n"
    184 "\n"
    185 "Return the tuple (x//y, x%y).  Invariant: div*y + mod == x.");
    186 
    187 #define BUILTIN_DIVMOD_METHODDEF    \
    188     {"divmod", (PyCFunction)builtin_divmod, METH_VARARGS, builtin_divmod__doc__},
    189 
    190 static PyObject *
    191 builtin_divmod_impl(PyObject *module, PyObject *x, PyObject *y);
    192 
    193 static PyObject *
    194 builtin_divmod(PyObject *module, PyObject *args)
    195 {
    196     PyObject *return_value = NULL;
    197     PyObject *x;
    198     PyObject *y;
    199 
    200     if (!PyArg_UnpackTuple(args, "divmod",
    201         2, 2,
    202         &x, &y)) {
    203         goto exit;
    204     }
    205     return_value = builtin_divmod_impl(module, x, y);
    206 
    207 exit:
    208     return return_value;
    209 }
    210 
    211 PyDoc_STRVAR(builtin_eval__doc__,
    212 "eval($module, source, globals=None, locals=None, /)\n"
    213 "--\n"
    214 "\n"
    215 "Evaluate the given source in the context of globals and locals.\n"
    216 "\n"
    217 "The source may be a string representing a Python expression\n"
    218 "or a code object as returned by compile().\n"
    219 "The globals must be a dictionary and locals can be any mapping,\n"
    220 "defaulting to the current globals and locals.\n"
    221 "If only globals is given, locals defaults to it.");
    222 
    223 #define BUILTIN_EVAL_METHODDEF    \
    224     {"eval", (PyCFunction)builtin_eval, METH_VARARGS, builtin_eval__doc__},
    225 
    226 static PyObject *
    227 builtin_eval_impl(PyObject *module, PyObject *source, PyObject *globals,
    228                   PyObject *locals);
    229 
    230 static PyObject *
    231 builtin_eval(PyObject *module, PyObject *args)
    232 {
    233     PyObject *return_value = NULL;
    234     PyObject *source;
    235     PyObject *globals = Py_None;
    236     PyObject *locals = Py_None;
    237 
    238     if (!PyArg_UnpackTuple(args, "eval",
    239         1, 3,
    240         &source, &globals, &locals)) {
    241         goto exit;
    242     }
    243     return_value = builtin_eval_impl(module, source, globals, locals);
    244 
    245 exit:
    246     return return_value;
    247 }
    248 
    249 PyDoc_STRVAR(builtin_exec__doc__,
    250 "exec($module, source, globals=None, locals=None, /)\n"
    251 "--\n"
    252 "\n"
    253 "Execute the given source in the context of globals and locals.\n"
    254 "\n"
    255 "The source may be a string representing one or more Python statements\n"
    256 "or a code object as returned by compile().\n"
    257 "The globals must be a dictionary and locals can be any mapping,\n"
    258 "defaulting to the current globals and locals.\n"
    259 "If only globals is given, locals defaults to it.");
    260 
    261 #define BUILTIN_EXEC_METHODDEF    \
    262     {"exec", (PyCFunction)builtin_exec, METH_VARARGS, builtin_exec__doc__},
    263 
    264 static PyObject *
    265 builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals,
    266                   PyObject *locals);
    267 
    268 static PyObject *
    269 builtin_exec(PyObject *module, PyObject *args)
    270 {
    271     PyObject *return_value = NULL;
    272     PyObject *source;
    273     PyObject *globals = Py_None;
    274     PyObject *locals = Py_None;
    275 
    276     if (!PyArg_UnpackTuple(args, "exec",
    277         1, 3,
    278         &source, &globals, &locals)) {
    279         goto exit;
    280     }
    281     return_value = builtin_exec_impl(module, source, globals, locals);
    282 
    283 exit:
    284     return return_value;
    285 }
    286 
    287 PyDoc_STRVAR(builtin_globals__doc__,
    288 "globals($module, /)\n"
    289 "--\n"
    290 "\n"
    291 "Return the dictionary containing the current scope\'s global variables.\n"
    292 "\n"
    293 "NOTE: Updates to this dictionary *will* affect name lookups in the current\n"
    294 "global scope and vice-versa.");
    295 
    296 #define BUILTIN_GLOBALS_METHODDEF    \
    297     {"globals", (PyCFunction)builtin_globals, METH_NOARGS, builtin_globals__doc__},
    298 
    299 static PyObject *
    300 builtin_globals_impl(PyObject *module);
    301 
    302 static PyObject *
    303 builtin_globals(PyObject *module, PyObject *Py_UNUSED(ignored))
    304 {
    305     return builtin_globals_impl(module);
    306 }
    307 
    308 PyDoc_STRVAR(builtin_hasattr__doc__,
    309 "hasattr($module, obj, name, /)\n"
    310 "--\n"
    311 "\n"
    312 "Return whether the object has an attribute with the given name.\n"
    313 "\n"
    314 "This is done by calling getattr(obj, name) and catching AttributeError.");
    315 
    316 #define BUILTIN_HASATTR_METHODDEF    \
    317     {"hasattr", (PyCFunction)builtin_hasattr, METH_VARARGS, builtin_hasattr__doc__},
    318 
    319 static PyObject *
    320 builtin_hasattr_impl(PyObject *module, PyObject *obj, PyObject *name);
    321 
    322 static PyObject *
    323 builtin_hasattr(PyObject *module, PyObject *args)
    324 {
    325     PyObject *return_value = NULL;
    326     PyObject *obj;
    327     PyObject *name;
    328 
    329     if (!PyArg_UnpackTuple(args, "hasattr",
    330         2, 2,
    331         &obj, &name)) {
    332         goto exit;
    333     }
    334     return_value = builtin_hasattr_impl(module, obj, name);
    335 
    336 exit:
    337     return return_value;
    338 }
    339 
    340 PyDoc_STRVAR(builtin_id__doc__,
    341 "id($module, obj, /)\n"
    342 "--\n"
    343 "\n"
    344 "Return the identity of an object.\n"
    345 "\n"
    346 "This is guaranteed to be unique among simultaneously existing objects.\n"
    347 "(CPython uses the object\'s memory address.)");
    348 
    349 #define BUILTIN_ID_METHODDEF    \
    350     {"id", (PyCFunction)builtin_id, METH_O, builtin_id__doc__},
    351 
    352 PyDoc_STRVAR(builtin_setattr__doc__,
    353 "setattr($module, obj, name, value, /)\n"
    354 "--\n"
    355 "\n"
    356 "Sets the named attribute on the given object to the specified value.\n"
    357 "\n"
    358 "setattr(x, \'y\', v) is equivalent to ``x.y = v\'\'");
    359 
    360 #define BUILTIN_SETATTR_METHODDEF    \
    361     {"setattr", (PyCFunction)builtin_setattr, METH_VARARGS, builtin_setattr__doc__},
    362 
    363 static PyObject *
    364 builtin_setattr_impl(PyObject *module, PyObject *obj, PyObject *name,
    365                      PyObject *value);
    366 
    367 static PyObject *
    368 builtin_setattr(PyObject *module, PyObject *args)
    369 {
    370     PyObject *return_value = NULL;
    371     PyObject *obj;
    372     PyObject *name;
    373     PyObject *value;
    374 
    375     if (!PyArg_UnpackTuple(args, "setattr",
    376         3, 3,
    377         &obj, &name, &value)) {
    378         goto exit;
    379     }
    380     return_value = builtin_setattr_impl(module, obj, name, value);
    381 
    382 exit:
    383     return return_value;
    384 }
    385 
    386 PyDoc_STRVAR(builtin_delattr__doc__,
    387 "delattr($module, obj, name, /)\n"
    388 "--\n"
    389 "\n"
    390 "Deletes the named attribute from the given object.\n"
    391 "\n"
    392 "delattr(x, \'y\') is equivalent to ``del x.y\'\'");
    393 
    394 #define BUILTIN_DELATTR_METHODDEF    \
    395     {"delattr", (PyCFunction)builtin_delattr, METH_VARARGS, builtin_delattr__doc__},
    396 
    397 static PyObject *
    398 builtin_delattr_impl(PyObject *module, PyObject *obj, PyObject *name);
    399 
    400 static PyObject *
    401 builtin_delattr(PyObject *module, PyObject *args)
    402 {
    403     PyObject *return_value = NULL;
    404     PyObject *obj;
    405     PyObject *name;
    406 
    407     if (!PyArg_UnpackTuple(args, "delattr",
    408         2, 2,
    409         &obj, &name)) {
    410         goto exit;
    411     }
    412     return_value = builtin_delattr_impl(module, obj, name);
    413 
    414 exit:
    415     return return_value;
    416 }
    417 
    418 PyDoc_STRVAR(builtin_hash__doc__,
    419 "hash($module, obj, /)\n"
    420 "--\n"
    421 "\n"
    422 "Return the hash value for the given object.\n"
    423 "\n"
    424 "Two objects that compare equal must also have the same hash value, but the\n"
    425 "reverse is not necessarily true.");
    426 
    427 #define BUILTIN_HASH_METHODDEF    \
    428     {"hash", (PyCFunction)builtin_hash, METH_O, builtin_hash__doc__},
    429 
    430 PyDoc_STRVAR(builtin_hex__doc__,
    431 "hex($module, number, /)\n"
    432 "--\n"
    433 "\n"
    434 "Return the hexadecimal representation of an integer.\n"
    435 "\n"
    436 "   >>> hex(12648430)\n"
    437 "   \'0xc0ffee\'");
    438 
    439 #define BUILTIN_HEX_METHODDEF    \
    440     {"hex", (PyCFunction)builtin_hex, METH_O, builtin_hex__doc__},
    441 
    442 PyDoc_STRVAR(builtin_len__doc__,
    443 "len($module, obj, /)\n"
    444 "--\n"
    445 "\n"
    446 "Return the number of items in a container.");
    447 
    448 #define BUILTIN_LEN_METHODDEF    \
    449     {"len", (PyCFunction)builtin_len, METH_O, builtin_len__doc__},
    450 
    451 PyDoc_STRVAR(builtin_locals__doc__,
    452 "locals($module, /)\n"
    453 "--\n"
    454 "\n"
    455 "Return a dictionary containing the current scope\'s local variables.\n"
    456 "\n"
    457 "NOTE: Whether or not updates to this dictionary will affect name lookups in\n"
    458 "the local scope and vice-versa is *implementation dependent* and not\n"
    459 "covered by any backwards compatibility guarantees.");
    460 
    461 #define BUILTIN_LOCALS_METHODDEF    \
    462     {"locals", (PyCFunction)builtin_locals, METH_NOARGS, builtin_locals__doc__},
    463 
    464 static PyObject *
    465 builtin_locals_impl(PyObject *module);
    466 
    467 static PyObject *
    468 builtin_locals(PyObject *module, PyObject *Py_UNUSED(ignored))
    469 {
    470     return builtin_locals_impl(module);
    471 }
    472 
    473 PyDoc_STRVAR(builtin_oct__doc__,
    474 "oct($module, number, /)\n"
    475 "--\n"
    476 "\n"
    477 "Return the octal representation of an integer.\n"
    478 "\n"
    479 "   >>> oct(342391)\n"
    480 "   \'0o1234567\'");
    481 
    482 #define BUILTIN_OCT_METHODDEF    \
    483     {"oct", (PyCFunction)builtin_oct, METH_O, builtin_oct__doc__},
    484 
    485 PyDoc_STRVAR(builtin_ord__doc__,
    486 "ord($module, c, /)\n"
    487 "--\n"
    488 "\n"
    489 "Return the Unicode code point for a one-character string.");
    490 
    491 #define BUILTIN_ORD_METHODDEF    \
    492     {"ord", (PyCFunction)builtin_ord, METH_O, builtin_ord__doc__},
    493 
    494 PyDoc_STRVAR(builtin_pow__doc__,
    495 "pow($module, x, y, z=None, /)\n"
    496 "--\n"
    497 "\n"
    498 "Equivalent to x**y (with two arguments) or x**y % z (with three arguments)\n"
    499 "\n"
    500 "Some types, such as ints, are able to use a more efficient algorithm when\n"
    501 "invoked using the three argument form.");
    502 
    503 #define BUILTIN_POW_METHODDEF    \
    504     {"pow", (PyCFunction)builtin_pow, METH_VARARGS, builtin_pow__doc__},
    505 
    506 static PyObject *
    507 builtin_pow_impl(PyObject *module, PyObject *x, PyObject *y, PyObject *z);
    508 
    509 static PyObject *
    510 builtin_pow(PyObject *module, PyObject *args)
    511 {
    512     PyObject *return_value = NULL;
    513     PyObject *x;
    514     PyObject *y;
    515     PyObject *z = Py_None;
    516 
    517     if (!PyArg_UnpackTuple(args, "pow",
    518         2, 3,
    519         &x, &y, &z)) {
    520         goto exit;
    521     }
    522     return_value = builtin_pow_impl(module, x, y, z);
    523 
    524 exit:
    525     return return_value;
    526 }
    527 
    528 PyDoc_STRVAR(builtin_input__doc__,
    529 "input($module, prompt=None, /)\n"
    530 "--\n"
    531 "\n"
    532 "Read a string from standard input.  The trailing newline is stripped.\n"
    533 "\n"
    534 "The prompt string, if given, is printed to standard output without a\n"
    535 "trailing newline before reading input.\n"
    536 "\n"
    537 "If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.\n"
    538 "On *nix systems, readline is used if available.");
    539 
    540 #define BUILTIN_INPUT_METHODDEF    \
    541     {"input", (PyCFunction)builtin_input, METH_VARARGS, builtin_input__doc__},
    542 
    543 static PyObject *
    544 builtin_input_impl(PyObject *module, PyObject *prompt);
    545 
    546 static PyObject *
    547 builtin_input(PyObject *module, PyObject *args)
    548 {
    549     PyObject *return_value = NULL;
    550     PyObject *prompt = NULL;
    551 
    552     if (!PyArg_UnpackTuple(args, "input",
    553         0, 1,
    554         &prompt)) {
    555         goto exit;
    556     }
    557     return_value = builtin_input_impl(module, prompt);
    558 
    559 exit:
    560     return return_value;
    561 }
    562 
    563 PyDoc_STRVAR(builtin_repr__doc__,
    564 "repr($module, obj, /)\n"
    565 "--\n"
    566 "\n"
    567 "Return the canonical string representation of the object.\n"
    568 "\n"
    569 "For many object types, including most builtins, eval(repr(obj)) == obj.");
    570 
    571 #define BUILTIN_REPR_METHODDEF    \
    572     {"repr", (PyCFunction)builtin_repr, METH_O, builtin_repr__doc__},
    573 
    574 PyDoc_STRVAR(builtin_sum__doc__,
    575 "sum($module, iterable, start=0, /)\n"
    576 "--\n"
    577 "\n"
    578 "Return the sum of a \'start\' value (default: 0) plus an iterable of numbers\n"
    579 "\n"
    580 "When the iterable is empty, return the start value.\n"
    581 "This function is intended specifically for use with numeric values and may\n"
    582 "reject non-numeric types.");
    583 
    584 #define BUILTIN_SUM_METHODDEF    \
    585     {"sum", (PyCFunction)builtin_sum, METH_VARARGS, builtin_sum__doc__},
    586 
    587 static PyObject *
    588 builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start);
    589 
    590 static PyObject *
    591 builtin_sum(PyObject *module, PyObject *args)
    592 {
    593     PyObject *return_value = NULL;
    594     PyObject *iterable;
    595     PyObject *start = NULL;
    596 
    597     if (!PyArg_UnpackTuple(args, "sum",
    598         1, 2,
    599         &iterable, &start)) {
    600         goto exit;
    601     }
    602     return_value = builtin_sum_impl(module, iterable, start);
    603 
    604 exit:
    605     return return_value;
    606 }
    607 
    608 PyDoc_STRVAR(builtin_isinstance__doc__,
    609 "isinstance($module, obj, class_or_tuple, /)\n"
    610 "--\n"
    611 "\n"
    612 "Return whether an object is an instance of a class or of a subclass thereof.\n"
    613 "\n"
    614 "A tuple, as in ``isinstance(x, (A, B, ...))``, may be given as the target to\n"
    615 "check against. This is equivalent to ``isinstance(x, A) or isinstance(x, B)\n"
    616 "or ...`` etc.");
    617 
    618 #define BUILTIN_ISINSTANCE_METHODDEF    \
    619     {"isinstance", (PyCFunction)builtin_isinstance, METH_VARARGS, builtin_isinstance__doc__},
    620 
    621 static PyObject *
    622 builtin_isinstance_impl(PyObject *module, PyObject *obj,
    623                         PyObject *class_or_tuple);
    624 
    625 static PyObject *
    626 builtin_isinstance(PyObject *module, PyObject *args)
    627 {
    628     PyObject *return_value = NULL;
    629     PyObject *obj;
    630     PyObject *class_or_tuple;
    631 
    632     if (!PyArg_UnpackTuple(args, "isinstance",
    633         2, 2,
    634         &obj, &class_or_tuple)) {
    635         goto exit;
    636     }
    637     return_value = builtin_isinstance_impl(module, obj, class_or_tuple);
    638 
    639 exit:
    640     return return_value;
    641 }
    642 
    643 PyDoc_STRVAR(builtin_issubclass__doc__,
    644 "issubclass($module, cls, class_or_tuple, /)\n"
    645 "--\n"
    646 "\n"
    647 "Return whether \'cls\' is a derived from another class or is the same class.\n"
    648 "\n"
    649 "A tuple, as in ``issubclass(x, (A, B, ...))``, may be given as the target to\n"
    650 "check against. This is equivalent to ``issubclass(x, A) or issubclass(x, B)\n"
    651 "or ...`` etc.");
    652 
    653 #define BUILTIN_ISSUBCLASS_METHODDEF    \
    654     {"issubclass", (PyCFunction)builtin_issubclass, METH_VARARGS, builtin_issubclass__doc__},
    655 
    656 static PyObject *
    657 builtin_issubclass_impl(PyObject *module, PyObject *cls,
    658                         PyObject *class_or_tuple);
    659 
    660 static PyObject *
    661 builtin_issubclass(PyObject *module, PyObject *args)
    662 {
    663     PyObject *return_value = NULL;
    664     PyObject *cls;
    665     PyObject *class_or_tuple;
    666 
    667     if (!PyArg_UnpackTuple(args, "issubclass",
    668         2, 2,
    669         &cls, &class_or_tuple)) {
    670         goto exit;
    671     }
    672     return_value = builtin_issubclass_impl(module, cls, class_or_tuple);
    673 
    674 exit:
    675     return return_value;
    676 }
    677 /*[clinic end generated code: output=63483deb75805f7c input=a9049054013a1b77]*/
    678