blob: fa327da0ffc352b6b3916ac911b18acdc381ec60 [file] [log] [blame]
Serhiy Storchaka1009bf12015-04-03 23:53:51 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_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
14PyDoc_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
25PyDoc_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
36PyDoc_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
50PyDoc_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
62PyDoc_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
74PyDoc_STRVAR(builtin_format__doc__,
75"format($module, value, format_spec=\'\', /)\n"
76"--\n"
77"\n"
78"Return value.__format__(format_spec)\n"
79"\n"
Amit Kumar2e6bb442017-05-29 06:32:26 +053080"format_spec defaults to the empty string.\n"
81"See the Format Specification Mini-Language section of help(\'FORMATTING\') for\n"
82"details.");
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030083
84#define BUILTIN_FORMAT_METHODDEF \
Victor Stinner259f0e42017-01-17 01:35:17 +010085 {"format", (PyCFunction)builtin_format, METH_FASTCALL, builtin_format__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030086
87static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030088builtin_format_impl(PyObject *module, PyObject *value, PyObject *format_spec);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030089
90static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +030091builtin_format(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030092{
93 PyObject *return_value = NULL;
94 PyObject *value;
95 PyObject *format_spec = NULL;
96
Sylvain74453812017-06-10 06:51:48 +020097 if (!_PyArg_ParseStack(args, nargs, "O|U:format",
98 &value, &format_spec)) {
Victor Stinner259f0e42017-01-17 01:35:17 +010099 goto exit;
100 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300101 return_value = builtin_format_impl(module, value, format_spec);
102
103exit:
104 return return_value;
105}
106
107PyDoc_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 \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300114 {"chr", (PyCFunction)builtin_chr, METH_O, builtin_chr__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300115
116static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300117builtin_chr_impl(PyObject *module, int i);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300118
119static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300120builtin_chr(PyObject *module, PyObject *arg)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300121{
122 PyObject *return_value = NULL;
123 int i;
124
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300125 if (!PyArg_Parse(arg, "i:chr", &i)) {
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300126 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300127 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300128 return_value = builtin_chr_impl(module, i);
129
130exit:
131 return return_value;
132}
133
134PyDoc_STRVAR(builtin_compile__doc__,
Serhiy Storchaka8b2e8b62015-05-30 11:30:39 +0300135"compile($module, /, source, filename, mode, flags=0,\n"
136" dont_inherit=False, optimize=-1)\n"
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300137"--\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"
Serhiy Storchaka8b2e8b62015-05-30 11:30:39 +0300147"The dont_inherit argument, if true, stops the compilation inheriting\n"
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300148"the effects of any future statements in effect in the code calling\n"
Serhiy Storchaka8b2e8b62015-05-30 11:30:39 +0300149"compile; if absent or false these statements do influence the compilation,\n"
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300150"in addition to any features explicitly specified.");
151
152#define BUILTIN_COMPILE_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300153 {"compile", (PyCFunction)builtin_compile, METH_FASTCALL|METH_KEYWORDS, builtin_compile__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300154
155static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300156builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
157 const char *mode, int flags, int dont_inherit,
158 int optimize);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300159
160static PyObject *
Victor Stinner37e4ef72016-09-09 20:00:13 -0700161builtin_compile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300162{
163 PyObject *return_value = NULL;
Serhiy Storchaka9171a8b2016-08-14 10:52:18 +0300164 static const char * const _keywords[] = {"source", "filename", "mode", "flags", "dont_inherit", "optimize", NULL};
165 static _PyArg_Parser _parser = {"OO&s|iii:compile", _keywords, 0};
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300166 PyObject *source;
167 PyObject *filename;
168 const char *mode;
169 int flags = 0;
170 int dont_inherit = 0;
171 int optimize = -1;
172
Victor Stinner3e1fad62017-01-17 01:29:01 +0100173 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300174 &source, PyUnicode_FSDecoder, &filename, &mode, &flags, &dont_inherit, &optimize)) {
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300175 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300176 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300177 return_value = builtin_compile_impl(module, source, filename, mode, flags, dont_inherit, optimize);
178
179exit:
180 return return_value;
181}
182
183PyDoc_STRVAR(builtin_divmod__doc__,
184"divmod($module, x, y, /)\n"
185"--\n"
186"\n"
Serhiy Storchakadf071732016-05-01 20:33:24 +0300187"Return the tuple (x//y, x%y). Invariant: div*y + mod == x.");
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300188
189#define BUILTIN_DIVMOD_METHODDEF \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100190 {"divmod", (PyCFunction)builtin_divmod, METH_FASTCALL, builtin_divmod__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300191
192static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300193builtin_divmod_impl(PyObject *module, PyObject *x, PyObject *y);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300194
195static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300196builtin_divmod(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300197{
198 PyObject *return_value = NULL;
199 PyObject *x;
200 PyObject *y;
201
Sylvain74453812017-06-10 06:51:48 +0200202 if (!_PyArg_UnpackStack(args, nargs, "divmod",
203 2, 2,
204 &x, &y)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100205 goto exit;
206 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300207 return_value = builtin_divmod_impl(module, x, y);
208
209exit:
210 return return_value;
211}
212
213PyDoc_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 \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100226 {"eval", (PyCFunction)builtin_eval, METH_FASTCALL, builtin_eval__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300227
228static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300229builtin_eval_impl(PyObject *module, PyObject *source, PyObject *globals,
Larry Hastings89964c42015-04-14 18:07:59 -0400230 PyObject *locals);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300231
232static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300233builtin_eval(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300234{
235 PyObject *return_value = NULL;
236 PyObject *source;
237 PyObject *globals = Py_None;
238 PyObject *locals = Py_None;
239
Sylvain74453812017-06-10 06:51:48 +0200240 if (!_PyArg_UnpackStack(args, nargs, "eval",
241 1, 3,
242 &source, &globals, &locals)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100243 goto exit;
244 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300245 return_value = builtin_eval_impl(module, source, globals, locals);
246
247exit:
248 return return_value;
249}
250
251PyDoc_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 \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100264 {"exec", (PyCFunction)builtin_exec, METH_FASTCALL, builtin_exec__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300265
266static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300267builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals,
Larry Hastings89964c42015-04-14 18:07:59 -0400268 PyObject *locals);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300269
270static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300271builtin_exec(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300272{
273 PyObject *return_value = NULL;
274 PyObject *source;
275 PyObject *globals = Py_None;
276 PyObject *locals = Py_None;
277
Sylvain74453812017-06-10 06:51:48 +0200278 if (!_PyArg_UnpackStack(args, nargs, "exec",
279 1, 3,
280 &source, &globals, &locals)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100281 goto exit;
282 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300283 return_value = builtin_exec_impl(module, source, globals, locals);
284
285exit:
286 return return_value;
287}
288
289PyDoc_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
301static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300302builtin_globals_impl(PyObject *module);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300303
304static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300305builtin_globals(PyObject *module, PyObject *Py_UNUSED(ignored))
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300306{
307 return builtin_globals_impl(module);
308}
309
310PyDoc_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 \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100319 {"hasattr", (PyCFunction)builtin_hasattr, METH_FASTCALL, builtin_hasattr__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300320
321static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300322builtin_hasattr_impl(PyObject *module, PyObject *obj, PyObject *name);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300323
324static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300325builtin_hasattr(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300326{
327 PyObject *return_value = NULL;
328 PyObject *obj;
329 PyObject *name;
330
Sylvain74453812017-06-10 06:51:48 +0200331 if (!_PyArg_UnpackStack(args, nargs, "hasattr",
332 2, 2,
333 &obj, &name)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100334 goto exit;
335 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300336 return_value = builtin_hasattr_impl(module, obj, name);
337
338exit:
339 return return_value;
340}
341
342PyDoc_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
354PyDoc_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 \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100363 {"setattr", (PyCFunction)builtin_setattr, METH_FASTCALL, builtin_setattr__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300364
365static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300366builtin_setattr_impl(PyObject *module, PyObject *obj, PyObject *name,
Larry Hastings89964c42015-04-14 18:07:59 -0400367 PyObject *value);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300368
369static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300370builtin_setattr(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300371{
372 PyObject *return_value = NULL;
373 PyObject *obj;
374 PyObject *name;
375 PyObject *value;
376
Sylvain74453812017-06-10 06:51:48 +0200377 if (!_PyArg_UnpackStack(args, nargs, "setattr",
378 3, 3,
379 &obj, &name, &value)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100380 goto exit;
381 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300382 return_value = builtin_setattr_impl(module, obj, name, value);
383
384exit:
385 return return_value;
386}
387
388PyDoc_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 \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100397 {"delattr", (PyCFunction)builtin_delattr, METH_FASTCALL, builtin_delattr__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300398
399static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300400builtin_delattr_impl(PyObject *module, PyObject *obj, PyObject *name);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300401
402static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300403builtin_delattr(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300404{
405 PyObject *return_value = NULL;
406 PyObject *obj;
407 PyObject *name;
408
Sylvain74453812017-06-10 06:51:48 +0200409 if (!_PyArg_UnpackStack(args, nargs, "delattr",
410 2, 2,
411 &obj, &name)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100412 goto exit;
413 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300414 return_value = builtin_delattr_impl(module, obj, name);
415
416exit:
417 return return_value;
418}
419
420PyDoc_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
432PyDoc_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
444PyDoc_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
453PyDoc_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
466static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300467builtin_locals_impl(PyObject *module);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300468
469static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300470builtin_locals(PyObject *module, PyObject *Py_UNUSED(ignored))
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300471{
472 return builtin_locals_impl(module);
473}
474
475PyDoc_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
487PyDoc_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
496PyDoc_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 \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100506 {"pow", (PyCFunction)builtin_pow, METH_FASTCALL, builtin_pow__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300507
508static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300509builtin_pow_impl(PyObject *module, PyObject *x, PyObject *y, PyObject *z);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300510
511static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300512builtin_pow(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300513{
514 PyObject *return_value = NULL;
515 PyObject *x;
516 PyObject *y;
517 PyObject *z = Py_None;
518
Sylvain74453812017-06-10 06:51:48 +0200519 if (!_PyArg_UnpackStack(args, nargs, "pow",
520 2, 3,
521 &x, &y, &z)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100522 goto exit;
523 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300524 return_value = builtin_pow_impl(module, x, y, z);
525
526exit:
527 return return_value;
528}
529
530PyDoc_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 \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100543 {"input", (PyCFunction)builtin_input, METH_FASTCALL, builtin_input__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300544
545static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300546builtin_input_impl(PyObject *module, PyObject *prompt);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300547
548static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300549builtin_input(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300550{
551 PyObject *return_value = NULL;
552 PyObject *prompt = NULL;
553
Sylvain74453812017-06-10 06:51:48 +0200554 if (!_PyArg_UnpackStack(args, nargs, "input",
555 0, 1,
556 &prompt)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100557 goto exit;
558 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300559 return_value = builtin_input_impl(module, prompt);
560
561exit:
562 return return_value;
563}
564
565PyDoc_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
576PyDoc_STRVAR(builtin_sum__doc__,
577"sum($module, iterable, start=0, /)\n"
578"--\n"
579"\n"
580"Return the sum of a \'start\' value (default: 0) plus an iterable of numbers\n"
581"\n"
582"When the iterable is empty, return the start value.\n"
583"This function is intended specifically for use with numeric values and may\n"
584"reject non-numeric types.");
585
586#define BUILTIN_SUM_METHODDEF \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100587 {"sum", (PyCFunction)builtin_sum, METH_FASTCALL, builtin_sum__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300588
589static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300590builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300591
592static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300593builtin_sum(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300594{
595 PyObject *return_value = NULL;
596 PyObject *iterable;
597 PyObject *start = NULL;
598
Sylvain74453812017-06-10 06:51:48 +0200599 if (!_PyArg_UnpackStack(args, nargs, "sum",
600 1, 2,
601 &iterable, &start)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100602 goto exit;
603 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300604 return_value = builtin_sum_impl(module, iterable, start);
605
606exit:
607 return return_value;
608}
609
610PyDoc_STRVAR(builtin_isinstance__doc__,
611"isinstance($module, obj, class_or_tuple, /)\n"
612"--\n"
613"\n"
614"Return whether an object is an instance of a class or of a subclass thereof.\n"
615"\n"
616"A tuple, as in ``isinstance(x, (A, B, ...))``, may be given as the target to\n"
617"check against. This is equivalent to ``isinstance(x, A) or isinstance(x, B)\n"
618"or ...`` etc.");
619
620#define BUILTIN_ISINSTANCE_METHODDEF \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100621 {"isinstance", (PyCFunction)builtin_isinstance, METH_FASTCALL, builtin_isinstance__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300622
623static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300624builtin_isinstance_impl(PyObject *module, PyObject *obj,
Larry Hastings89964c42015-04-14 18:07:59 -0400625 PyObject *class_or_tuple);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300626
627static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300628builtin_isinstance(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300629{
630 PyObject *return_value = NULL;
631 PyObject *obj;
632 PyObject *class_or_tuple;
633
Sylvain74453812017-06-10 06:51:48 +0200634 if (!_PyArg_UnpackStack(args, nargs, "isinstance",
635 2, 2,
636 &obj, &class_or_tuple)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100637 goto exit;
638 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300639 return_value = builtin_isinstance_impl(module, obj, class_or_tuple);
640
641exit:
642 return return_value;
643}
644
645PyDoc_STRVAR(builtin_issubclass__doc__,
646"issubclass($module, cls, class_or_tuple, /)\n"
647"--\n"
648"\n"
649"Return whether \'cls\' is a derived from another class or is the same class.\n"
650"\n"
651"A tuple, as in ``issubclass(x, (A, B, ...))``, may be given as the target to\n"
652"check against. This is equivalent to ``issubclass(x, A) or issubclass(x, B)\n"
653"or ...`` etc.");
654
655#define BUILTIN_ISSUBCLASS_METHODDEF \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100656 {"issubclass", (PyCFunction)builtin_issubclass, METH_FASTCALL, builtin_issubclass__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300657
658static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300659builtin_issubclass_impl(PyObject *module, PyObject *cls,
Larry Hastings89964c42015-04-14 18:07:59 -0400660 PyObject *class_or_tuple);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300661
662static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300663builtin_issubclass(PyObject *module, PyObject **args, Py_ssize_t nargs)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300664{
665 PyObject *return_value = NULL;
666 PyObject *cls;
667 PyObject *class_or_tuple;
668
Sylvain74453812017-06-10 06:51:48 +0200669 if (!_PyArg_UnpackStack(args, nargs, "issubclass",
670 2, 2,
671 &cls, &class_or_tuple)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100672 goto exit;
673 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300674 return_value = builtin_issubclass_impl(module, cls, class_or_tuple);
675
676exit:
677 return return_value;
678}
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300679/*[clinic end generated code: output=09752daa8cdd6ec7 input=a9049054013a1b77]*/