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