diff -r a824c40e8fc0 Modules/_codecsmodule.c --- a/Modules/_codecsmodule.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/_codecsmodule.c Sun Feb 22 11:52:48 2015 +0200 @@ -47,6 +47,7 @@ module _codecs [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=e1390e3da3cb9deb]*/ +#include "clinic/_codecsmodule.c.h" /* --- Registry ----------------------------------------------------------- */ @@ -153,37 +154,9 @@ codec_decode(PyObject *self, PyObject *a Purge the named codec from the internal codec lookup cache [clinic start generated code]*/ -PyDoc_STRVAR(_codecs__forget_codec__doc__, -"_forget_codec($module, encoding, /)\n" -"--\n" -"\n" -"Purge the named codec from the internal codec lookup cache"); - -#define _CODECS__FORGET_CODEC_METHODDEF \ - {"_forget_codec", (PyCFunction)_codecs__forget_codec, METH_VARARGS, _codecs__forget_codec__doc__}, - -static PyObject * -_codecs__forget_codec_impl(PyModuleDef *module, const char *encoding); - -static PyObject * -_codecs__forget_codec(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - const char *encoding; - - if (!PyArg_ParseTuple(args, - "s:_forget_codec", - &encoding)) - goto exit; - return_value = _codecs__forget_codec_impl(module, encoding); - -exit: - return return_value; -} - static PyObject * _codecs__forget_codec_impl(PyModuleDef *module, const char *encoding) -/*[clinic end generated code: output=a75e631591702a5c input=18d5d92d0e386c38]*/ +/*[clinic end generated code: output=b56a9b99d2d28080 input=18d5d92d0e386c38]*/ { if (_PyCodec_Forget(encoding) < 0) { return NULL; diff -r a824c40e8fc0 Modules/_cryptmodule.c --- a/Modules/_cryptmodule.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/_cryptmodule.c Sun Feb 22 11:52:48 2015 +0200 @@ -12,6 +12,7 @@ module crypt [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=c6252cf4f2f2ae81]*/ +#include "clinic/_cryptmodule.c.h" /*[clinic input] crypt.crypt @@ -29,43 +30,9 @@ results for a given *word*. [clinic start generated code]*/ -PyDoc_STRVAR(crypt_crypt__doc__, -"crypt($module, word, salt, /)\n" -"--\n" -"\n" -"Hash a *word* with the given *salt* and return the hashed password.\n" -"\n" -"*word* will usually be a user\'s password. *salt* (either a random 2 or 16\n" -"character string, possibly prefixed with $digit$ to indicate the method)\n" -"will be used to perturb the encryption algorithm and produce distinct\n" -"results for a given *word*."); - -#define CRYPT_CRYPT_METHODDEF \ - {"crypt", (PyCFunction)crypt_crypt, METH_VARARGS, crypt_crypt__doc__}, - -static PyObject * -crypt_crypt_impl(PyModuleDef *module, const char *word, const char *salt); - -static PyObject * -crypt_crypt(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - const char *word; - const char *salt; - - if (!PyArg_ParseTuple(args, - "ss:crypt", - &word, &salt)) - goto exit; - return_value = crypt_crypt_impl(module, word, salt); - -exit: - return return_value; -} - static PyObject * crypt_crypt_impl(PyModuleDef *module, const char *word, const char *salt) -/*[clinic end generated code: output=3eaacdf994a6ff23 input=4d93b6d0f41fbf58]*/ +/*[clinic end generated code: output=995ad1e854d83069 input=4d93b6d0f41fbf58]*/ { /* On some platforms (AtheOS) crypt returns NULL for an invalid salt. Return None in that case. XXX Maybe raise an exception? */ diff -r a824c40e8fc0 Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/_cursesmodule.c Sun Feb 22 11:52:48 2015 +0200 @@ -140,6 +140,8 @@ class curses.window "PyCursesWindowObjec [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=88c860abdbb50e0c]*/ +#include "clinic/_cursesmodule.c.h" + /* Definition of exception curses.error */ static PyObject *PyCursesError; @@ -583,75 +585,9 @@ By default, the character position and a current settings for the window object. [clinic start generated code]*/ -PyDoc_STRVAR(curses_window_addch__doc__, -"addch([y, x,] ch, [attr])\n" -"Paint character ch at (y, x) with attributes attr.\n" -"\n" -" y\n" -" Y-coordinate.\n" -" x\n" -" X-coordinate.\n" -" ch\n" -" Character to add.\n" -" attr\n" -" Attributes for the character.\n" -"\n" -"Paint character ch at (y, x) with attributes attr,\n" -"overwriting any character previously painted at that location.\n" -"By default, the character position and attributes are the\n" -"current settings for the window object."); - -#define CURSES_WINDOW_ADDCH_METHODDEF \ - {"addch", (PyCFunction)curses_window_addch, METH_VARARGS, curses_window_addch__doc__}, - -static PyObject * -curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int y, int x, PyObject *ch, int group_right_1, long attr); - -static PyObject * -curses_window_addch(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int group_left_1 = 0; - int y = 0; - int x = 0; - PyObject *ch; - int group_right_1 = 0; - long attr = 0; - - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:addch", &ch)) - goto exit; - break; - case 2: - if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr)) - goto exit; - group_right_1 = 1; - break; - case 3: - if (!PyArg_ParseTuple(args, "iiO:addch", &y, &x, &ch)) - goto exit; - group_left_1 = 1; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOl:addch", &y, &x, &ch, &attr)) - goto exit; - group_right_1 = 1; - group_left_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "curses.window.addch requires 1 to 4 arguments"); - goto exit; - } - return_value = curses_window_addch_impl(self, group_left_1, y, x, ch, group_right_1, attr); - -exit: - return return_value; -} - static PyObject * curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int y, int x, PyObject *ch, int group_right_1, long attr) -/*[clinic end generated code: output=d4b97cc287010c54 input=5a41efb34a2de338]*/ +/*[clinic end generated code: output=9fa34a5d80151f1a input=5a41efb34a2de338]*/ { PyCursesWindowObject *cwself = (PyCursesWindowObject *)self; int coordinates_group = group_left_1; diff -r a824c40e8fc0 Modules/_datetimemodule.c --- a/Modules/_datetimemodule.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/_datetimemodule.c Sun Feb 22 11:52:48 2015 +0200 @@ -22,6 +22,8 @@ class datetime.datetime "PyDateTime_Date [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=78142cb64b9e98bc]*/ +#include "clinic/_datetimemodule.c.h" + /* We require that C int be at least 32 bits, and use int virtually * everywhere. In just a few cases we use a temp long, where a Python * API returns a C long. In such cases, we have to ensure that the @@ -4122,43 +4124,9 @@ Returns new datetime object representing If no tz is specified, uses local timezone. [clinic start generated code]*/ -PyDoc_STRVAR(datetime_datetime_now__doc__, -"now($type, /, tz=None)\n" -"--\n" -"\n" -"Returns new datetime object representing current time local to tz.\n" -"\n" -" tz\n" -" Timezone object.\n" -"\n" -"If no tz is specified, uses local timezone."); - -#define DATETIME_DATETIME_NOW_METHODDEF \ - {"now", (PyCFunction)datetime_datetime_now, METH_VARARGS|METH_KEYWORDS|METH_CLASS, datetime_datetime_now__doc__}, - -static PyObject * -datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz); - -static PyObject * -datetime_datetime_now(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"tz", NULL}; - PyObject *tz = Py_None; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|O:now", _keywords, - &tz)) - goto exit; - return_value = datetime_datetime_now_impl(type, tz); - -exit: - return return_value; -} - static PyObject * datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz) -/*[clinic end generated code: output=583c5637e3c843fa input=80d09869c5267d00]*/ +/*[clinic end generated code: output=b3386e5345e2b47a input=80d09869c5267d00]*/ { PyObject *self; diff -r a824c40e8fc0 Modules/_dbmmodule.c --- a/Modules/_dbmmodule.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/_dbmmodule.c Sun Feb 22 11:52:48 2015 +0200 @@ -40,6 +40,8 @@ typedef struct { DBM *di_dbm; } dbmobject; +#include "clinic/_dbmmodule.c.h" + static PyTypeObject Dbmtype; #define is_dbmobject(v) (Py_TYPE(v) == &Dbmtype) @@ -277,39 +279,9 @@ dbm.dbm.get Return the value for key if present, otherwise default. [clinic start generated code]*/ -PyDoc_STRVAR(dbm_dbm_get__doc__, -"get($self, key, default=None, /)\n" -"--\n" -"\n" -"Return the value for key if present, otherwise default."); - -#define DBM_DBM_GET_METHODDEF \ - {"get", (PyCFunction)dbm_dbm_get, METH_VARARGS, dbm_dbm_get__doc__}, - -static PyObject * -dbm_dbm_get_impl(dbmobject *dp, const char *key, Py_ssize_clean_t key_length, PyObject *default_value); - -static PyObject * -dbm_dbm_get(dbmobject *dp, PyObject *args) -{ - PyObject *return_value = NULL; - const char *key; - Py_ssize_clean_t key_length; - PyObject *default_value = Py_None; - - if (!PyArg_ParseTuple(args, - "s#|O:get", - &key, &key_length, &default_value)) - goto exit; - return_value = dbm_dbm_get_impl(dp, key, key_length, default_value); - -exit: - return return_value; -} - static PyObject * dbm_dbm_get_impl(dbmobject *dp, const char *key, Py_ssize_clean_t key_length, PyObject *default_value) -/*[clinic end generated code: output=452ea11394e7e92d input=aecf5efd2f2b1a3b]*/ +/*[clinic end generated code: output=c2bdccaa734ad349 input=aecf5efd2f2b1a3b]*/ { datum dbm_key, val; @@ -449,47 +421,9 @@ Return a database object. [clinic start generated code]*/ -PyDoc_STRVAR(dbmopen__doc__, -"open($module, filename, flags=\'r\', mode=0o666, /)\n" -"--\n" -"\n" -"Return a database object.\n" -"\n" -" filename\n" -" The filename to open.\n" -" flags\n" -" How to open the file. \"r\" for reading, \"w\" for writing, etc.\n" -" mode\n" -" If creating a new file, the mode bits for the new file\n" -" (e.g. os.O_RDWR)."); - -#define DBMOPEN_METHODDEF \ - {"open", (PyCFunction)dbmopen, METH_VARARGS, dbmopen__doc__}, - -static PyObject * -dbmopen_impl(PyModuleDef *module, const char *filename, const char *flags, int mode); - -static PyObject * -dbmopen(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - const char *filename; - const char *flags = "r"; - int mode = 438; - - if (!PyArg_ParseTuple(args, - "s|si:open", - &filename, &flags, &mode)) - goto exit; - return_value = dbmopen_impl(module, filename, flags, mode); - -exit: - return return_value; -} - static PyObject * dbmopen_impl(PyModuleDef *module, const char *filename, const char *flags, int mode) -/*[clinic end generated code: output=9a7b725f9c4dcec2 input=6499ab0fab1333ac]*/ +/*[clinic end generated code: output=8b618fe06b92bf86 input=6499ab0fab1333ac]*/ { int iflags; diff -r a824c40e8fc0 Modules/_opcode.c --- a/Modules/_opcode.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/_opcode.c Sun Feb 22 11:52:48 2015 +0200 @@ -6,6 +6,8 @@ module _opcode [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=117442e66eb376e6]*/ +#include "clinic/_opcode.c.h" + /*[clinic input] _opcode.stack_effect -> int @@ -17,42 +19,9 @@ module _opcode Compute the stack effect of the opcode. [clinic start generated code]*/ -PyDoc_STRVAR(_opcode_stack_effect__doc__, -"stack_effect($module, opcode, oparg=None, /)\n" -"--\n" -"\n" -"Compute the stack effect of the opcode."); - -#define _OPCODE_STACK_EFFECT_METHODDEF \ - {"stack_effect", (PyCFunction)_opcode_stack_effect, METH_VARARGS, _opcode_stack_effect__doc__}, - -static int -_opcode_stack_effect_impl(PyModuleDef *module, int opcode, PyObject *oparg); - -static PyObject * -_opcode_stack_effect(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int opcode; - PyObject *oparg = Py_None; - int _return_value; - - if (!PyArg_ParseTuple(args, - "i|O:stack_effect", - &opcode, &oparg)) - goto exit; - _return_value = _opcode_stack_effect_impl(module, opcode, oparg); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromLong((long)_return_value); - -exit: - return return_value; -} - static int _opcode_stack_effect_impl(PyModuleDef *module, int opcode, PyObject *oparg) -/*[clinic end generated code: output=9e1133f8d587bc67 input=2d0a9ee53c0418f5]*/ +/*[clinic end generated code: output=1fcafd5596c6b050 input=2d0a9ee53c0418f5]*/ { int effect; int oparg_int = 0; diff -r a824c40e8fc0 Modules/_weakref.c --- a/Modules/_weakref.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/_weakref.c Sun Feb 22 11:52:48 2015 +0200 @@ -9,6 +9,8 @@ module _weakref [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=ffec73b85846596d]*/ +#include "clinic/_weakref.c.h" + /*[clinic input] _weakref.getweakrefcount -> Py_ssize_t @@ -19,36 +21,9 @@ module _weakref Return the number of weak references to 'object'. [clinic start generated code]*/ -PyDoc_STRVAR(_weakref_getweakrefcount__doc__, -"getweakrefcount($module, object, /)\n" -"--\n" -"\n" -"Return the number of weak references to \'object\'."); - -#define _WEAKREF_GETWEAKREFCOUNT_METHODDEF \ - {"getweakrefcount", (PyCFunction)_weakref_getweakrefcount, METH_O, _weakref_getweakrefcount__doc__}, - -static Py_ssize_t -_weakref_getweakrefcount_impl(PyModuleDef *module, PyObject *object); - -static PyObject * -_weakref_getweakrefcount(PyModuleDef *module, PyObject *object) -{ - PyObject *return_value = NULL; - Py_ssize_t _return_value; - - _return_value = _weakref_getweakrefcount_impl(module, object); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromSsize_t(_return_value); - -exit: - return return_value; -} - static Py_ssize_t _weakref_getweakrefcount_impl(PyModuleDef *module, PyObject *object) -/*[clinic end generated code: output=032eedbfd7d69e10 input=cedb69711b6a2507]*/ +/*[clinic end generated code: output=6a6ad0b98285e468 input=cedb69711b6a2507]*/ { PyWeakReference **list; diff -r a824c40e8fc0 Modules/clinic/_codecsmodule.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/_codecsmodule.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,32 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_codecs__forget_codec__doc__, +"_forget_codec($module, encoding, /)\n" +"--\n" +"\n" +"Purge the named codec from the internal codec lookup cache"); + +#define _CODECS__FORGET_CODEC_METHODDEF \ + {"_forget_codec", (PyCFunction)_codecs__forget_codec, METH_VARARGS, _codecs__forget_codec__doc__}, + +static PyObject * +_codecs__forget_codec_impl(PyModuleDef *module, const char *encoding); + +static PyObject * +_codecs__forget_codec(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + const char *encoding; + + if (!PyArg_ParseTuple(args, + "s:_forget_codec", + &encoding)) + goto exit; + return_value = _codecs__forget_codec_impl(module, encoding); + +exit: + return return_value; +} +/*[clinic end generated code: output=cdea83e21d76a900 input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/_cryptmodule.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/_cryptmodule.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,38 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(crypt_crypt__doc__, +"crypt($module, word, salt, /)\n" +"--\n" +"\n" +"Hash a *word* with the given *salt* and return the hashed password.\n" +"\n" +"*word* will usually be a user\'s password. *salt* (either a random 2 or 16\n" +"character string, possibly prefixed with $digit$ to indicate the method)\n" +"will be used to perturb the encryption algorithm and produce distinct\n" +"results for a given *word*."); + +#define CRYPT_CRYPT_METHODDEF \ + {"crypt", (PyCFunction)crypt_crypt, METH_VARARGS, crypt_crypt__doc__}, + +static PyObject * +crypt_crypt_impl(PyModuleDef *module, const char *word, const char *salt); + +static PyObject * +crypt_crypt(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + const char *word; + const char *salt; + + if (!PyArg_ParseTuple(args, + "ss:crypt", + &word, &salt)) + goto exit; + return_value = crypt_crypt_impl(module, word, salt); + +exit: + return return_value; +} +/*[clinic end generated code: output=b5b8d977189d19ea input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/_cursesmodule.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/_cursesmodule.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,70 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(curses_window_addch__doc__, +"addch([y, x,] ch, [attr])\n" +"Paint character ch at (y, x) with attributes attr.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" ch\n" +" Character to add.\n" +" attr\n" +" Attributes for the character.\n" +"\n" +"Paint character ch at (y, x) with attributes attr,\n" +"overwriting any character previously painted at that location.\n" +"By default, the character position and attributes are the\n" +"current settings for the window object."); + +#define CURSES_WINDOW_ADDCH_METHODDEF \ + {"addch", (PyCFunction)curses_window_addch, METH_VARARGS, curses_window_addch__doc__}, + +static PyObject * +curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int y, int x, PyObject *ch, int group_right_1, long attr); + +static PyObject * +curses_window_addch(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *ch; + int group_right_1 = 0; + long attr = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O:addch", &ch)) + goto exit; + break; + case 2: + if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr)) + goto exit; + group_right_1 = 1; + break; + case 3: + if (!PyArg_ParseTuple(args, "iiO:addch", &y, &x, &ch)) + goto exit; + group_left_1 = 1; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOl:addch", &y, &x, &ch, &attr)) + goto exit; + group_right_1 = 1; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "curses.window.addch requires 1 to 4 arguments"); + goto exit; + } + return_value = curses_window_addch_impl(self, group_left_1, y, x, ch, group_right_1, attr); + +exit: + return return_value; +} +/*[clinic end generated code: output=660ab0ae6d8fbdda input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/_datetimemodule.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/_datetimemodule.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,38 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(datetime_datetime_now__doc__, +"now($type, /, tz=None)\n" +"--\n" +"\n" +"Returns new datetime object representing current time local to tz.\n" +"\n" +" tz\n" +" Timezone object.\n" +"\n" +"If no tz is specified, uses local timezone."); + +#define DATETIME_DATETIME_NOW_METHODDEF \ + {"now", (PyCFunction)datetime_datetime_now, METH_VARARGS|METH_KEYWORDS|METH_CLASS, datetime_datetime_now__doc__}, + +static PyObject * +datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz); + +static PyObject * +datetime_datetime_now(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"tz", NULL}; + PyObject *tz = Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|O:now", _keywords, + &tz)) + goto exit; + return_value = datetime_datetime_now_impl(type, tz); + +exit: + return return_value; +} +/*[clinic end generated code: output=a5c51b96f10c462c input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/_dbmmodule.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/_dbmmodule.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,72 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(dbm_dbm_get__doc__, +"get($self, key, default=None, /)\n" +"--\n" +"\n" +"Return the value for key if present, otherwise default."); + +#define DBM_DBM_GET_METHODDEF \ + {"get", (PyCFunction)dbm_dbm_get, METH_VARARGS, dbm_dbm_get__doc__}, + +static PyObject * +dbm_dbm_get_impl(dbmobject *dp, const char *key, Py_ssize_clean_t key_length, PyObject *default_value); + +static PyObject * +dbm_dbm_get(dbmobject *dp, PyObject *args) +{ + PyObject *return_value = NULL; + const char *key; + Py_ssize_clean_t key_length; + PyObject *default_value = Py_None; + + if (!PyArg_ParseTuple(args, + "s#|O:get", + &key, &key_length, &default_value)) + goto exit; + return_value = dbm_dbm_get_impl(dp, key, key_length, default_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(dbmopen__doc__, +"open($module, filename, flags=\'r\', mode=0o666, /)\n" +"--\n" +"\n" +"Return a database object.\n" +"\n" +" filename\n" +" The filename to open.\n" +" flags\n" +" How to open the file. \"r\" for reading, \"w\" for writing, etc.\n" +" mode\n" +" If creating a new file, the mode bits for the new file\n" +" (e.g. os.O_RDWR)."); + +#define DBMOPEN_METHODDEF \ + {"open", (PyCFunction)dbmopen, METH_VARARGS, dbmopen__doc__}, + +static PyObject * +dbmopen_impl(PyModuleDef *module, const char *filename, const char *flags, int mode); + +static PyObject * +dbmopen(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + const char *filename; + const char *flags = "r"; + int mode = 438; + + if (!PyArg_ParseTuple(args, + "s|si:open", + &filename, &flags, &mode)) + goto exit; + return_value = dbmopen_impl(module, filename, flags, mode); + +exit: + return return_value; +} +/*[clinic end generated code: output=78d62d1aa3ddd13c input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/_opcode.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/_opcode.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,37 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_opcode_stack_effect__doc__, +"stack_effect($module, opcode, oparg=None, /)\n" +"--\n" +"\n" +"Compute the stack effect of the opcode."); + +#define _OPCODE_STACK_EFFECT_METHODDEF \ + {"stack_effect", (PyCFunction)_opcode_stack_effect, METH_VARARGS, _opcode_stack_effect__doc__}, + +static int +_opcode_stack_effect_impl(PyModuleDef *module, int opcode, PyObject *oparg); + +static PyObject * +_opcode_stack_effect(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int opcode; + PyObject *oparg = Py_None; + int _return_value; + + if (!PyArg_ParseTuple(args, + "i|O:stack_effect", + &opcode, &oparg)) + goto exit; + _return_value = _opcode_stack_effect_impl(module, opcode, oparg); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong((long)_return_value); + +exit: + return return_value; +} +/*[clinic end generated code: output=dbe45148bc21ecdf input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/_weakref.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/_weakref.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,31 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_weakref_getweakrefcount__doc__, +"getweakrefcount($module, object, /)\n" +"--\n" +"\n" +"Return the number of weak references to \'object\'."); + +#define _WEAKREF_GETWEAKREFCOUNT_METHODDEF \ + {"getweakrefcount", (PyCFunction)_weakref_getweakrefcount, METH_O, _weakref_getweakrefcount__doc__}, + +static Py_ssize_t +_weakref_getweakrefcount_impl(PyModuleDef *module, PyObject *object); + +static PyObject * +_weakref_getweakrefcount(PyModuleDef *module, PyObject *object) +{ + PyObject *return_value = NULL; + Py_ssize_t _return_value; + + _return_value = _weakref_getweakrefcount_impl(module, object); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromSsize_t(_return_value); + +exit: + return return_value; +} +/*[clinic end generated code: output=4da9aade63eed77f input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/md5module.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/md5module.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,96 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(MD5Type_copy__doc__, +"copy($self, /)\n" +"--\n" +"\n" +"Return a copy of the hash object."); + +#define MD5TYPE_COPY_METHODDEF \ + {"copy", (PyCFunction)MD5Type_copy, METH_NOARGS, MD5Type_copy__doc__}, + +static PyObject * +MD5Type_copy_impl(MD5object *self); + +static PyObject * +MD5Type_copy(MD5object *self, PyObject *Py_UNUSED(ignored)) +{ + return MD5Type_copy_impl(self); +} + +PyDoc_STRVAR(MD5Type_digest__doc__, +"digest($self, /)\n" +"--\n" +"\n" +"Return the digest value as a string of binary data."); + +#define MD5TYPE_DIGEST_METHODDEF \ + {"digest", (PyCFunction)MD5Type_digest, METH_NOARGS, MD5Type_digest__doc__}, + +static PyObject * +MD5Type_digest_impl(MD5object *self); + +static PyObject * +MD5Type_digest(MD5object *self, PyObject *Py_UNUSED(ignored)) +{ + return MD5Type_digest_impl(self); +} + +PyDoc_STRVAR(MD5Type_hexdigest__doc__, +"hexdigest($self, /)\n" +"--\n" +"\n" +"Return the digest value as a string of hexadecimal digits."); + +#define MD5TYPE_HEXDIGEST_METHODDEF \ + {"hexdigest", (PyCFunction)MD5Type_hexdigest, METH_NOARGS, MD5Type_hexdigest__doc__}, + +static PyObject * +MD5Type_hexdigest_impl(MD5object *self); + +static PyObject * +MD5Type_hexdigest(MD5object *self, PyObject *Py_UNUSED(ignored)) +{ + return MD5Type_hexdigest_impl(self); +} + +PyDoc_STRVAR(MD5Type_update__doc__, +"update($self, obj, /)\n" +"--\n" +"\n" +"Update this hash object\'s state with the provided string."); + +#define MD5TYPE_UPDATE_METHODDEF \ + {"update", (PyCFunction)MD5Type_update, METH_O, MD5Type_update__doc__}, + +PyDoc_STRVAR(_md5_md5__doc__, +"md5($module, /, string=b\'\')\n" +"--\n" +"\n" +"Return a new MD5 hash object; optionally initialized with a string."); + +#define _MD5_MD5_METHODDEF \ + {"md5", (PyCFunction)_md5_md5, METH_VARARGS|METH_KEYWORDS, _md5_md5__doc__}, + +static PyObject * +_md5_md5_impl(PyModuleDef *module, PyObject *string); + +static PyObject * +_md5_md5(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"string", NULL}; + PyObject *string = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|O:md5", _keywords, + &string)) + goto exit; + return_value = _md5_md5_impl(module, string); + +exit: + return return_value; +} +/*[clinic end generated code: output=f72618edfd35d984 input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/posixmodule.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/posixmodule.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,5862 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(os_stat__doc__, +"stat($module, /, path, *, dir_fd=None, follow_symlinks=True)\n" +"--\n" +"\n" +"Perform a stat system call on the given path.\n" +"\n" +" path\n" +" Path to be examined; can be string, bytes, or open-file-descriptor int.\n" +" dir_fd\n" +" If not None, it should be a file descriptor open to a directory,\n" +" and path should be a relative string; path will then be relative to\n" +" that directory.\n" +" follow_symlinks\n" +" If False, and the last element of the path is a symbolic link,\n" +" stat will examine the symbolic link itself instead of the file\n" +" the link points to.\n" +"\n" +"dir_fd and follow_symlinks may not be implemented\n" +" on your platform. If they are unavailable, using them will raise a\n" +" NotImplementedError.\n" +"\n" +"It\'s an error to use dir_fd or follow_symlinks when specifying path as\n" +" an open file descriptor."); + +#define OS_STAT_METHODDEF \ + {"stat", (PyCFunction)os_stat, METH_VARARGS|METH_KEYWORDS, os_stat__doc__}, + +static PyObject * +os_stat_impl(PyModuleDef *module, path_t *path, int dir_fd, int follow_symlinks); + +static PyObject * +os_stat(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "dir_fd", "follow_symlinks", NULL}; + path_t path = PATH_T_INITIALIZE("stat", "path", 0, 1); + int dir_fd = DEFAULT_DIR_FD; + int follow_symlinks = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&|$O&p:stat", _keywords, + path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) + goto exit; + return_value = os_stat_impl(module, &path, dir_fd, follow_symlinks); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +PyDoc_STRVAR(os_lstat__doc__, +"lstat($module, /, path, *, dir_fd=None)\n" +"--\n" +"\n" +"Perform a stat system call on the given path, without following symbolic links.\n" +"\n" +"Like stat(), but do not follow symbolic links.\n" +"Equivalent to stat(path, follow_symlinks=False)."); + +#define OS_LSTAT_METHODDEF \ + {"lstat", (PyCFunction)os_lstat, METH_VARARGS|METH_KEYWORDS, os_lstat__doc__}, + +static PyObject * +os_lstat_impl(PyModuleDef *module, path_t *path, int dir_fd); + +static PyObject * +os_lstat(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "dir_fd", NULL}; + path_t path = PATH_T_INITIALIZE("lstat", "path", 0, 0); + int dir_fd = DEFAULT_DIR_FD; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&|$O&:lstat", _keywords, + path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd)) + goto exit; + return_value = os_lstat_impl(module, &path, dir_fd); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +PyDoc_STRVAR(os_access__doc__, +"access($module, /, path, mode, *, dir_fd=None, effective_ids=False,\n" +" follow_symlinks=True)\n" +"--\n" +"\n" +"Use the real uid/gid to test for access to a path.\n" +"\n" +" path\n" +" Path to be tested; can be string, bytes, or open-file-descriptor int.\n" +" mode\n" +" Operating-system mode bitfield. Can be F_OK to test existence,\n" +" or the inclusive-OR of R_OK, W_OK, and X_OK.\n" +" dir_fd\n" +" If not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that\n" +" directory.\n" +" effective_ids\n" +" If True, access will use the effective uid/gid instead of\n" +" the real uid/gid.\n" +" follow_symlinks\n" +" If False, and the last element of the path is a symbolic link,\n" +" access will examine the symbolic link itself instead of the file\n" +" the link points to.\n" +"\n" +"dir_fd, effective_ids, and follow_symlinks may not be implemented\n" +" on your platform. If they are unavailable, using them will raise a\n" +" NotImplementedError.\n" +"\n" +"Note that most operations will use the effective uid/gid, therefore this\n" +" routine can be used in a suid/sgid environment to test if the invoking user\n" +" has the specified access to the path."); + +#define OS_ACCESS_METHODDEF \ + {"access", (PyCFunction)os_access, METH_VARARGS|METH_KEYWORDS, os_access__doc__}, + +static int +os_access_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd, int effective_ids, int follow_symlinks); + +static PyObject * +os_access(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL}; + path_t path = PATH_T_INITIALIZE("access", "path", 0, 1); + int mode; + int dir_fd = DEFAULT_DIR_FD; + int effective_ids = 0; + int follow_symlinks = 1; + int _return_value; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&i|$O&pp:access", _keywords, + path_converter, &path, &mode, FACCESSAT_DIR_FD_CONVERTER, &dir_fd, &effective_ids, &follow_symlinks)) + goto exit; + _return_value = os_access_impl(module, &path, mode, dir_fd, effective_ids, follow_symlinks); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyBool_FromLong((long)_return_value); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#if defined(HAVE_TTYNAME) + +PyDoc_STRVAR(os_ttyname__doc__, +"ttyname($module, fd, /)\n" +"--\n" +"\n" +"Return the name of the terminal device connected to \'fd\'.\n" +"\n" +" fd\n" +" Integer file descriptor handle."); + +#define OS_TTYNAME_METHODDEF \ + {"ttyname", (PyCFunction)os_ttyname, METH_VARARGS, os_ttyname__doc__}, + +static char * +os_ttyname_impl(PyModuleDef *module, int fd); + +static PyObject * +os_ttyname(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + char *_return_value; + + if (!PyArg_ParseTuple(args, + "i:ttyname", + &fd)) + goto exit; + _return_value = os_ttyname_impl(module, fd); + if (_return_value == NULL) + goto exit; + return_value = PyUnicode_DecodeFSDefault(_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_TTYNAME) */ + +#ifndef OS_TTYNAME_METHODDEF + #define OS_TTYNAME_METHODDEF +#endif /* !defined(OS_TTYNAME_METHODDEF) */ + +#if defined(HAVE_CTERMID) + +PyDoc_STRVAR(os_ctermid__doc__, +"ctermid($module, /)\n" +"--\n" +"\n" +"Return the name of the controlling terminal for this process."); + +#define OS_CTERMID_METHODDEF \ + {"ctermid", (PyCFunction)os_ctermid, METH_NOARGS, os_ctermid__doc__}, + +static PyObject * +os_ctermid_impl(PyModuleDef *module); + +static PyObject * +os_ctermid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_ctermid_impl(module); +} + +#endif /* defined(HAVE_CTERMID) */ + +#ifndef OS_CTERMID_METHODDEF + #define OS_CTERMID_METHODDEF +#endif /* !defined(OS_CTERMID_METHODDEF) */ + +PyDoc_STRVAR(os_chdir__doc__, +"chdir($module, /, path)\n" +"--\n" +"\n" +"Change the current working directory to the specified path.\n" +"\n" +"path may always be specified as a string.\n" +"On some platforms, path may also be specified as an open file descriptor.\n" +" If this functionality is unavailable, using it raises an exception."); + +#define OS_CHDIR_METHODDEF \ + {"chdir", (PyCFunction)os_chdir, METH_VARARGS|METH_KEYWORDS, os_chdir__doc__}, + +static PyObject * +os_chdir_impl(PyModuleDef *module, path_t *path); + +static PyObject * +os_chdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", NULL}; + path_t path = PATH_T_INITIALIZE("chdir", "path", 0, PATH_HAVE_FCHDIR); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&:chdir", _keywords, + path_converter, &path)) + goto exit; + return_value = os_chdir_impl(module, &path); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#if defined(HAVE_FCHDIR) + +PyDoc_STRVAR(os_fchdir__doc__, +"fchdir($module, /, fd)\n" +"--\n" +"\n" +"Change to the directory of the given file descriptor.\n" +"\n" +"fd must be opened on a directory, not a file.\n" +"Equivalent to os.chdir(fd)."); + +#define OS_FCHDIR_METHODDEF \ + {"fchdir", (PyCFunction)os_fchdir, METH_VARARGS|METH_KEYWORDS, os_fchdir__doc__}, + +static PyObject * +os_fchdir_impl(PyModuleDef *module, int fd); + +static PyObject * +os_fchdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"fd", NULL}; + int fd; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&:fchdir", _keywords, + fildes_converter, &fd)) + goto exit; + return_value = os_fchdir_impl(module, fd); + +exit: + return return_value; +} + +#endif /* defined(HAVE_FCHDIR) */ + +#ifndef OS_FCHDIR_METHODDEF + #define OS_FCHDIR_METHODDEF +#endif /* !defined(OS_FCHDIR_METHODDEF) */ + +PyDoc_STRVAR(os_chmod__doc__, +"chmod($module, /, path, mode, *, dir_fd=None, follow_symlinks=True)\n" +"--\n" +"\n" +"Change the access permissions of a file.\n" +"\n" +" path\n" +" Path to be modified. May always be specified as a str or bytes.\n" +" On some platforms, path may also be specified as an open file descriptor.\n" +" If this functionality is unavailable, using it raises an exception.\n" +" mode\n" +" Operating-system mode bitfield.\n" +" dir_fd\n" +" If not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that\n" +" directory.\n" +" follow_symlinks\n" +" If False, and the last element of the path is a symbolic link,\n" +" chmod will modify the symbolic link itself instead of the file\n" +" the link points to.\n" +"\n" +"It is an error to use dir_fd or follow_symlinks when specifying path as\n" +" an open file descriptor.\n" +"dir_fd and follow_symlinks may not be implemented on your platform.\n" +" If they are unavailable, using them will raise a NotImplementedError."); + +#define OS_CHMOD_METHODDEF \ + {"chmod", (PyCFunction)os_chmod, METH_VARARGS|METH_KEYWORDS, os_chmod__doc__}, + +static PyObject * +os_chmod_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd, int follow_symlinks); + +static PyObject * +os_chmod(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "mode", "dir_fd", "follow_symlinks", NULL}; + path_t path = PATH_T_INITIALIZE("chmod", "path", 0, PATH_HAVE_FCHMOD); + int mode; + int dir_fd = DEFAULT_DIR_FD; + int follow_symlinks = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&i|$O&p:chmod", _keywords, + path_converter, &path, &mode, FCHMODAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) + goto exit; + return_value = os_chmod_impl(module, &path, mode, dir_fd, follow_symlinks); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#if defined(HAVE_FCHMOD) + +PyDoc_STRVAR(os_fchmod__doc__, +"fchmod($module, /, fd, mode)\n" +"--\n" +"\n" +"Change the access permissions of the file given by file descriptor fd.\n" +"\n" +"Equivalent to os.chmod(fd, mode)."); + +#define OS_FCHMOD_METHODDEF \ + {"fchmod", (PyCFunction)os_fchmod, METH_VARARGS|METH_KEYWORDS, os_fchmod__doc__}, + +static PyObject * +os_fchmod_impl(PyModuleDef *module, int fd, int mode); + +static PyObject * +os_fchmod(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"fd", "mode", NULL}; + int fd; + int mode; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "ii:fchmod", _keywords, + &fd, &mode)) + goto exit; + return_value = os_fchmod_impl(module, fd, mode); + +exit: + return return_value; +} + +#endif /* defined(HAVE_FCHMOD) */ + +#ifndef OS_FCHMOD_METHODDEF + #define OS_FCHMOD_METHODDEF +#endif /* !defined(OS_FCHMOD_METHODDEF) */ + +#if defined(HAVE_LCHMOD) + +PyDoc_STRVAR(os_lchmod__doc__, +"lchmod($module, /, path, mode)\n" +"--\n" +"\n" +"Change the access permissions of a file, without following symbolic links.\n" +"\n" +"If path is a symlink, this affects the link itself rather than the target.\n" +"Equivalent to chmod(path, mode, follow_symlinks=False).\""); + +#define OS_LCHMOD_METHODDEF \ + {"lchmod", (PyCFunction)os_lchmod, METH_VARARGS|METH_KEYWORDS, os_lchmod__doc__}, + +static PyObject * +os_lchmod_impl(PyModuleDef *module, path_t *path, int mode); + +static PyObject * +os_lchmod(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "mode", NULL}; + path_t path = PATH_T_INITIALIZE("lchmod", "path", 0, 0); + int mode; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&i:lchmod", _keywords, + path_converter, &path, &mode)) + goto exit; + return_value = os_lchmod_impl(module, &path, mode); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(HAVE_LCHMOD) */ + +#ifndef OS_LCHMOD_METHODDEF + #define OS_LCHMOD_METHODDEF +#endif /* !defined(OS_LCHMOD_METHODDEF) */ + +#if defined(HAVE_CHFLAGS) + +PyDoc_STRVAR(os_chflags__doc__, +"chflags($module, /, path, flags, follow_symlinks=True)\n" +"--\n" +"\n" +"Set file flags.\n" +"\n" +"If follow_symlinks is False, and the last element of the path is a symbolic\n" +" link, chflags will change flags on the symbolic link itself instead of the\n" +" file the link points to.\n" +"follow_symlinks may not be implemented on your platform. If it is\n" +"unavailable, using it will raise a NotImplementedError."); + +#define OS_CHFLAGS_METHODDEF \ + {"chflags", (PyCFunction)os_chflags, METH_VARARGS|METH_KEYWORDS, os_chflags__doc__}, + +static PyObject * +os_chflags_impl(PyModuleDef *module, path_t *path, unsigned long flags, int follow_symlinks); + +static PyObject * +os_chflags(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "flags", "follow_symlinks", NULL}; + path_t path = PATH_T_INITIALIZE("chflags", "path", 0, 0); + unsigned long flags; + int follow_symlinks = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&k|p:chflags", _keywords, + path_converter, &path, &flags, &follow_symlinks)) + goto exit; + return_value = os_chflags_impl(module, &path, flags, follow_symlinks); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(HAVE_CHFLAGS) */ + +#ifndef OS_CHFLAGS_METHODDEF + #define OS_CHFLAGS_METHODDEF +#endif /* !defined(OS_CHFLAGS_METHODDEF) */ + +#if defined(HAVE_LCHFLAGS) + +PyDoc_STRVAR(os_lchflags__doc__, +"lchflags($module, /, path, flags)\n" +"--\n" +"\n" +"Set file flags.\n" +"\n" +"This function will not follow symbolic links.\n" +"Equivalent to chflags(path, flags, follow_symlinks=False)."); + +#define OS_LCHFLAGS_METHODDEF \ + {"lchflags", (PyCFunction)os_lchflags, METH_VARARGS|METH_KEYWORDS, os_lchflags__doc__}, + +static PyObject * +os_lchflags_impl(PyModuleDef *module, path_t *path, unsigned long flags); + +static PyObject * +os_lchflags(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "flags", NULL}; + path_t path = PATH_T_INITIALIZE("lchflags", "path", 0, 0); + unsigned long flags; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&k:lchflags", _keywords, + path_converter, &path, &flags)) + goto exit; + return_value = os_lchflags_impl(module, &path, flags); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(HAVE_LCHFLAGS) */ + +#ifndef OS_LCHFLAGS_METHODDEF + #define OS_LCHFLAGS_METHODDEF +#endif /* !defined(OS_LCHFLAGS_METHODDEF) */ + +#if defined(HAVE_CHROOT) + +PyDoc_STRVAR(os_chroot__doc__, +"chroot($module, /, path)\n" +"--\n" +"\n" +"Change root directory to path."); + +#define OS_CHROOT_METHODDEF \ + {"chroot", (PyCFunction)os_chroot, METH_VARARGS|METH_KEYWORDS, os_chroot__doc__}, + +static PyObject * +os_chroot_impl(PyModuleDef *module, path_t *path); + +static PyObject * +os_chroot(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", NULL}; + path_t path = PATH_T_INITIALIZE("chroot", "path", 0, 0); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&:chroot", _keywords, + path_converter, &path)) + goto exit; + return_value = os_chroot_impl(module, &path); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(HAVE_CHROOT) */ + +#ifndef OS_CHROOT_METHODDEF + #define OS_CHROOT_METHODDEF +#endif /* !defined(OS_CHROOT_METHODDEF) */ + +#if defined(HAVE_FSYNC) + +PyDoc_STRVAR(os_fsync__doc__, +"fsync($module, /, fd)\n" +"--\n" +"\n" +"Force write of fd to disk."); + +#define OS_FSYNC_METHODDEF \ + {"fsync", (PyCFunction)os_fsync, METH_VARARGS|METH_KEYWORDS, os_fsync__doc__}, + +static PyObject * +os_fsync_impl(PyModuleDef *module, int fd); + +static PyObject * +os_fsync(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"fd", NULL}; + int fd; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&:fsync", _keywords, + fildes_converter, &fd)) + goto exit; + return_value = os_fsync_impl(module, fd); + +exit: + return return_value; +} + +#endif /* defined(HAVE_FSYNC) */ + +#ifndef OS_FSYNC_METHODDEF + #define OS_FSYNC_METHODDEF +#endif /* !defined(OS_FSYNC_METHODDEF) */ + +#if defined(HAVE_SYNC) + +PyDoc_STRVAR(os_sync__doc__, +"sync($module, /)\n" +"--\n" +"\n" +"Force write of everything to disk."); + +#define OS_SYNC_METHODDEF \ + {"sync", (PyCFunction)os_sync, METH_NOARGS, os_sync__doc__}, + +static PyObject * +os_sync_impl(PyModuleDef *module); + +static PyObject * +os_sync(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_sync_impl(module); +} + +#endif /* defined(HAVE_SYNC) */ + +#ifndef OS_SYNC_METHODDEF + #define OS_SYNC_METHODDEF +#endif /* !defined(OS_SYNC_METHODDEF) */ + +#if defined(HAVE_FDATASYNC) + +PyDoc_STRVAR(os_fdatasync__doc__, +"fdatasync($module, /, fd)\n" +"--\n" +"\n" +"Force write of fd to disk without forcing update of metadata."); + +#define OS_FDATASYNC_METHODDEF \ + {"fdatasync", (PyCFunction)os_fdatasync, METH_VARARGS|METH_KEYWORDS, os_fdatasync__doc__}, + +static PyObject * +os_fdatasync_impl(PyModuleDef *module, int fd); + +static PyObject * +os_fdatasync(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"fd", NULL}; + int fd; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&:fdatasync", _keywords, + fildes_converter, &fd)) + goto exit; + return_value = os_fdatasync_impl(module, fd); + +exit: + return return_value; +} + +#endif /* defined(HAVE_FDATASYNC) */ + +#ifndef OS_FDATASYNC_METHODDEF + #define OS_FDATASYNC_METHODDEF +#endif /* !defined(OS_FDATASYNC_METHODDEF) */ + +#if defined(HAVE_CHOWN) + +PyDoc_STRVAR(os_chown__doc__, +"chown($module, /, path, uid, gid, *, dir_fd=None, follow_symlinks=True)\n" +"--\n" +"\n" +"Change the owner and group id of path to the numeric uid and gid.\\\n" +"\n" +" path\n" +" Path to be examined; can be string, bytes, or open-file-descriptor int.\n" +" dir_fd\n" +" If not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that\n" +" directory.\n" +" follow_symlinks\n" +" If False, and the last element of the path is a symbolic link,\n" +" stat will examine the symbolic link itself instead of the file\n" +" the link points to.\n" +"\n" +"path may always be specified as a string.\n" +"On some platforms, path may also be specified as an open file descriptor.\n" +" If this functionality is unavailable, using it raises an exception.\n" +"If dir_fd is not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that directory.\n" +"If follow_symlinks is False, and the last element of the path is a symbolic\n" +" link, chown will modify the symbolic link itself instead of the file the\n" +" link points to.\n" +"It is an error to use dir_fd or follow_symlinks when specifying path as\n" +" an open file descriptor.\n" +"dir_fd and follow_symlinks may not be implemented on your platform.\n" +" If they are unavailable, using them will raise a NotImplementedError."); + +#define OS_CHOWN_METHODDEF \ + {"chown", (PyCFunction)os_chown, METH_VARARGS|METH_KEYWORDS, os_chown__doc__}, + +static PyObject * +os_chown_impl(PyModuleDef *module, path_t *path, uid_t uid, gid_t gid, int dir_fd, int follow_symlinks); + +static PyObject * +os_chown(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "uid", "gid", "dir_fd", "follow_symlinks", NULL}; + path_t path = PATH_T_INITIALIZE("chown", "path", 0, PATH_HAVE_FCHOWN); + uid_t uid; + gid_t gid; + int dir_fd = DEFAULT_DIR_FD; + int follow_symlinks = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&O&O&|$O&p:chown", _keywords, + path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid, FCHOWNAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) + goto exit; + return_value = os_chown_impl(module, &path, uid, gid, dir_fd, follow_symlinks); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(HAVE_CHOWN) */ + +#ifndef OS_CHOWN_METHODDEF + #define OS_CHOWN_METHODDEF +#endif /* !defined(OS_CHOWN_METHODDEF) */ + +#if defined(HAVE_FCHOWN) + +PyDoc_STRVAR(os_fchown__doc__, +"fchown($module, /, fd, uid, gid)\n" +"--\n" +"\n" +"Change the owner and group id of the file specified by file descriptor.\n" +"\n" +"Equivalent to os.chown(fd, uid, gid)."); + +#define OS_FCHOWN_METHODDEF \ + {"fchown", (PyCFunction)os_fchown, METH_VARARGS|METH_KEYWORDS, os_fchown__doc__}, + +static PyObject * +os_fchown_impl(PyModuleDef *module, int fd, uid_t uid, gid_t gid); + +static PyObject * +os_fchown(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"fd", "uid", "gid", NULL}; + int fd; + uid_t uid; + gid_t gid; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "iO&O&:fchown", _keywords, + &fd, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid)) + goto exit; + return_value = os_fchown_impl(module, fd, uid, gid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_FCHOWN) */ + +#ifndef OS_FCHOWN_METHODDEF + #define OS_FCHOWN_METHODDEF +#endif /* !defined(OS_FCHOWN_METHODDEF) */ + +#if defined(HAVE_LCHOWN) + +PyDoc_STRVAR(os_lchown__doc__, +"lchown($module, /, path, uid, gid)\n" +"--\n" +"\n" +"Change the owner and group id of path to the numeric uid and gid.\n" +"\n" +"This function will not follow symbolic links.\n" +"Equivalent to os.chown(path, uid, gid, follow_symlinks=False)."); + +#define OS_LCHOWN_METHODDEF \ + {"lchown", (PyCFunction)os_lchown, METH_VARARGS|METH_KEYWORDS, os_lchown__doc__}, + +static PyObject * +os_lchown_impl(PyModuleDef *module, path_t *path, uid_t uid, gid_t gid); + +static PyObject * +os_lchown(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "uid", "gid", NULL}; + path_t path = PATH_T_INITIALIZE("lchown", "path", 0, 0); + uid_t uid; + gid_t gid; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&O&O&:lchown", _keywords, + path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid)) + goto exit; + return_value = os_lchown_impl(module, &path, uid, gid); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(HAVE_LCHOWN) */ + +#ifndef OS_LCHOWN_METHODDEF + #define OS_LCHOWN_METHODDEF +#endif /* !defined(OS_LCHOWN_METHODDEF) */ + +PyDoc_STRVAR(os_getcwd__doc__, +"getcwd($module, /)\n" +"--\n" +"\n" +"Return a unicode string representing the current working directory."); + +#define OS_GETCWD_METHODDEF \ + {"getcwd", (PyCFunction)os_getcwd, METH_NOARGS, os_getcwd__doc__}, + +static PyObject * +os_getcwd_impl(PyModuleDef *module); + +static PyObject * +os_getcwd(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getcwd_impl(module); +} + +PyDoc_STRVAR(os_getcwdb__doc__, +"getcwdb($module, /)\n" +"--\n" +"\n" +"Return a bytes string representing the current working directory."); + +#define OS_GETCWDB_METHODDEF \ + {"getcwdb", (PyCFunction)os_getcwdb, METH_NOARGS, os_getcwdb__doc__}, + +static PyObject * +os_getcwdb_impl(PyModuleDef *module); + +static PyObject * +os_getcwdb(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getcwdb_impl(module); +} + +#if defined(HAVE_LINK) + +PyDoc_STRVAR(os_link__doc__, +"link($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None,\n" +" follow_symlinks=True)\n" +"--\n" +"\n" +"Create a hard link to a file.\n" +"\n" +"If either src_dir_fd or dst_dir_fd is not None, it should be a file\n" +" descriptor open to a directory, and the respective path string (src or dst)\n" +" should be relative; the path will then be relative to that directory.\n" +"If follow_symlinks is False, and the last element of src is a symbolic\n" +" link, link will create a link to the symbolic link itself instead of the\n" +" file the link points to.\n" +"src_dir_fd, dst_dir_fd, and follow_symlinks may not be implemented on your\n" +" platform. If they are unavailable, using them will raise a\n" +" NotImplementedError."); + +#define OS_LINK_METHODDEF \ + {"link", (PyCFunction)os_link, METH_VARARGS|METH_KEYWORDS, os_link__doc__}, + +static PyObject * +os_link_impl(PyModuleDef *module, path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd, int follow_symlinks); + +static PyObject * +os_link(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", "follow_symlinks", NULL}; + path_t src = PATH_T_INITIALIZE("link", "src", 0, 0); + path_t dst = PATH_T_INITIALIZE("link", "dst", 0, 0); + int src_dir_fd = DEFAULT_DIR_FD; + int dst_dir_fd = DEFAULT_DIR_FD; + int follow_symlinks = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&O&|$O&O&p:link", _keywords, + path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd, &follow_symlinks)) + goto exit; + return_value = os_link_impl(module, &src, &dst, src_dir_fd, dst_dir_fd, follow_symlinks); + +exit: + /* Cleanup for src */ + path_cleanup(&src); + /* Cleanup for dst */ + path_cleanup(&dst); + + return return_value; +} + +#endif /* defined(HAVE_LINK) */ + +#ifndef OS_LINK_METHODDEF + #define OS_LINK_METHODDEF +#endif /* !defined(OS_LINK_METHODDEF) */ + +PyDoc_STRVAR(os_listdir__doc__, +"listdir($module, /, path=None)\n" +"--\n" +"\n" +"Return a list containing the names of the files in the directory.\n" +"\n" +"path can be specified as either str or bytes. If path is bytes,\n" +" the filenames returned will also be bytes; in all other circumstances\n" +" the filenames returned will be str.\n" +"If path is None, uses the path=\'.\'.\n" +"On some platforms, path may also be specified as an open file descriptor;\\\n" +" the file descriptor must refer to a directory.\n" +" If this functionality is unavailable, using it raises NotImplementedError.\n" +"\n" +"The list is in arbitrary order. It does not include the special\n" +"entries \'.\' and \'..\' even if they are present in the directory."); + +#define OS_LISTDIR_METHODDEF \ + {"listdir", (PyCFunction)os_listdir, METH_VARARGS|METH_KEYWORDS, os_listdir__doc__}, + +static PyObject * +os_listdir_impl(PyModuleDef *module, path_t *path); + +static PyObject * +os_listdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", NULL}; + path_t path = PATH_T_INITIALIZE("listdir", "path", 1, PATH_HAVE_FDOPENDIR); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|O&:listdir", _keywords, + path_converter, &path)) + goto exit; + return_value = os_listdir_impl(module, &path); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#if defined(MS_WINDOWS) + +PyDoc_STRVAR(os__getfinalpathname__doc__, +"_getfinalpathname($module, path, /)\n" +"--\n" +"\n" +"A helper function for samepath on windows."); + +#define OS__GETFINALPATHNAME_METHODDEF \ + {"_getfinalpathname", (PyCFunction)os__getfinalpathname, METH_VARARGS, os__getfinalpathname__doc__}, + +static PyObject * +os__getfinalpathname_impl(PyModuleDef *module, PyObject *path); + +static PyObject * +os__getfinalpathname(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *path; + + if (!PyArg_ParseTuple(args, + "U:_getfinalpathname", + &path)) + goto exit; + return_value = os__getfinalpathname_impl(module, path); + +exit: + return return_value; +} + +#endif /* defined(MS_WINDOWS) */ + +#ifndef OS__GETFINALPATHNAME_METHODDEF + #define OS__GETFINALPATHNAME_METHODDEF +#endif /* !defined(OS__GETFINALPATHNAME_METHODDEF) */ + +#if defined(MS_WINDOWS) + +PyDoc_STRVAR(os__getvolumepathname__doc__, +"_getvolumepathname($module, /, path)\n" +"--\n" +"\n" +"A helper function for ismount on Win32."); + +#define OS__GETVOLUMEPATHNAME_METHODDEF \ + {"_getvolumepathname", (PyCFunction)os__getvolumepathname, METH_VARARGS|METH_KEYWORDS, os__getvolumepathname__doc__}, + +static PyObject * +os__getvolumepathname_impl(PyModuleDef *module, PyObject *path); + +static PyObject * +os__getvolumepathname(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", NULL}; + PyObject *path; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "U:_getvolumepathname", _keywords, + &path)) + goto exit; + return_value = os__getvolumepathname_impl(module, path); + +exit: + return return_value; +} + +#endif /* defined(MS_WINDOWS) */ + +#ifndef OS__GETVOLUMEPATHNAME_METHODDEF + #define OS__GETVOLUMEPATHNAME_METHODDEF +#endif /* !defined(OS__GETVOLUMEPATHNAME_METHODDEF) */ + +PyDoc_STRVAR(os_mkdir__doc__, +"mkdir($module, /, path, mode=511, *, dir_fd=None)\n" +"--\n" +"\n" +"Create a directory.\n" +"\n" +"If dir_fd is not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that directory.\n" +"dir_fd may not be implemented on your platform.\n" +" If it is unavailable, using it will raise a NotImplementedError.\n" +"\n" +"The mode argument is ignored on Windows."); + +#define OS_MKDIR_METHODDEF \ + {"mkdir", (PyCFunction)os_mkdir, METH_VARARGS|METH_KEYWORDS, os_mkdir__doc__}, + +static PyObject * +os_mkdir_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd); + +static PyObject * +os_mkdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "mode", "dir_fd", NULL}; + path_t path = PATH_T_INITIALIZE("mkdir", "path", 0, 0); + int mode = 511; + int dir_fd = DEFAULT_DIR_FD; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&|i$O&:mkdir", _keywords, + path_converter, &path, &mode, MKDIRAT_DIR_FD_CONVERTER, &dir_fd)) + goto exit; + return_value = os_mkdir_impl(module, &path, mode, dir_fd); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#if defined(HAVE_NICE) + +PyDoc_STRVAR(os_nice__doc__, +"nice($module, increment, /)\n" +"--\n" +"\n" +"Add increment to the priority of process and return the new priority."); + +#define OS_NICE_METHODDEF \ + {"nice", (PyCFunction)os_nice, METH_VARARGS, os_nice__doc__}, + +static PyObject * +os_nice_impl(PyModuleDef *module, int increment); + +static PyObject * +os_nice(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int increment; + + if (!PyArg_ParseTuple(args, + "i:nice", + &increment)) + goto exit; + return_value = os_nice_impl(module, increment); + +exit: + return return_value; +} + +#endif /* defined(HAVE_NICE) */ + +#ifndef OS_NICE_METHODDEF + #define OS_NICE_METHODDEF +#endif /* !defined(OS_NICE_METHODDEF) */ + +#if defined(HAVE_GETPRIORITY) + +PyDoc_STRVAR(os_getpriority__doc__, +"getpriority($module, /, which, who)\n" +"--\n" +"\n" +"Return program scheduling priority."); + +#define OS_GETPRIORITY_METHODDEF \ + {"getpriority", (PyCFunction)os_getpriority, METH_VARARGS|METH_KEYWORDS, os_getpriority__doc__}, + +static PyObject * +os_getpriority_impl(PyModuleDef *module, int which, int who); + +static PyObject * +os_getpriority(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"which", "who", NULL}; + int which; + int who; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "ii:getpriority", _keywords, + &which, &who)) + goto exit; + return_value = os_getpriority_impl(module, which, who); + +exit: + return return_value; +} + +#endif /* defined(HAVE_GETPRIORITY) */ + +#ifndef OS_GETPRIORITY_METHODDEF + #define OS_GETPRIORITY_METHODDEF +#endif /* !defined(OS_GETPRIORITY_METHODDEF) */ + +#if defined(HAVE_SETPRIORITY) + +PyDoc_STRVAR(os_setpriority__doc__, +"setpriority($module, /, which, who, priority)\n" +"--\n" +"\n" +"Set program scheduling priority."); + +#define OS_SETPRIORITY_METHODDEF \ + {"setpriority", (PyCFunction)os_setpriority, METH_VARARGS|METH_KEYWORDS, os_setpriority__doc__}, + +static PyObject * +os_setpriority_impl(PyModuleDef *module, int which, int who, int priority); + +static PyObject * +os_setpriority(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"which", "who", "priority", NULL}; + int which; + int who; + int priority; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "iii:setpriority", _keywords, + &which, &who, &priority)) + goto exit; + return_value = os_setpriority_impl(module, which, who, priority); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SETPRIORITY) */ + +#ifndef OS_SETPRIORITY_METHODDEF + #define OS_SETPRIORITY_METHODDEF +#endif /* !defined(OS_SETPRIORITY_METHODDEF) */ + +PyDoc_STRVAR(os_rename__doc__, +"rename($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None)\n" +"--\n" +"\n" +"Rename a file or directory.\n" +"\n" +"If either src_dir_fd or dst_dir_fd is not None, it should be a file\n" +" descriptor open to a directory, and the respective path string (src or dst)\n" +" should be relative; the path will then be relative to that directory.\n" +"src_dir_fd and dst_dir_fd, may not be implemented on your platform.\n" +" If they are unavailable, using them will raise a NotImplementedError."); + +#define OS_RENAME_METHODDEF \ + {"rename", (PyCFunction)os_rename, METH_VARARGS|METH_KEYWORDS, os_rename__doc__}, + +static PyObject * +os_rename_impl(PyModuleDef *module, path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd); + +static PyObject * +os_rename(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; + path_t src = PATH_T_INITIALIZE("rename", "src", 0, 0); + path_t dst = PATH_T_INITIALIZE("rename", "dst", 0, 0); + int src_dir_fd = DEFAULT_DIR_FD; + int dst_dir_fd = DEFAULT_DIR_FD; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&O&|$O&O&:rename", _keywords, + path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd)) + goto exit; + return_value = os_rename_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); + +exit: + /* Cleanup for src */ + path_cleanup(&src); + /* Cleanup for dst */ + path_cleanup(&dst); + + return return_value; +} + +PyDoc_STRVAR(os_replace__doc__, +"replace($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None)\n" +"--\n" +"\n" +"Rename a file or directory, overwriting the destination.\n" +"\n" +"If either src_dir_fd or dst_dir_fd is not None, it should be a file\n" +" descriptor open to a directory, and the respective path string (src or dst)\n" +" should be relative; the path will then be relative to that directory.\n" +"src_dir_fd and dst_dir_fd, may not be implemented on your platform.\n" +" If they are unavailable, using them will raise a NotImplementedError.\""); + +#define OS_REPLACE_METHODDEF \ + {"replace", (PyCFunction)os_replace, METH_VARARGS|METH_KEYWORDS, os_replace__doc__}, + +static PyObject * +os_replace_impl(PyModuleDef *module, path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd); + +static PyObject * +os_replace(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; + path_t src = PATH_T_INITIALIZE("replace", "src", 0, 0); + path_t dst = PATH_T_INITIALIZE("replace", "dst", 0, 0); + int src_dir_fd = DEFAULT_DIR_FD; + int dst_dir_fd = DEFAULT_DIR_FD; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&O&|$O&O&:replace", _keywords, + path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd)) + goto exit; + return_value = os_replace_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); + +exit: + /* Cleanup for src */ + path_cleanup(&src); + /* Cleanup for dst */ + path_cleanup(&dst); + + return return_value; +} + +PyDoc_STRVAR(os_rmdir__doc__, +"rmdir($module, /, path, *, dir_fd=None)\n" +"--\n" +"\n" +"Remove a directory.\n" +"\n" +"If dir_fd is not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that directory.\n" +"dir_fd may not be implemented on your platform.\n" +" If it is unavailable, using it will raise a NotImplementedError."); + +#define OS_RMDIR_METHODDEF \ + {"rmdir", (PyCFunction)os_rmdir, METH_VARARGS|METH_KEYWORDS, os_rmdir__doc__}, + +static PyObject * +os_rmdir_impl(PyModuleDef *module, path_t *path, int dir_fd); + +static PyObject * +os_rmdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "dir_fd", NULL}; + path_t path = PATH_T_INITIALIZE("rmdir", "path", 0, 0); + int dir_fd = DEFAULT_DIR_FD; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&|$O&:rmdir", _keywords, + path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) + goto exit; + return_value = os_rmdir_impl(module, &path, dir_fd); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#if defined(HAVE_SYSTEM) && defined(MS_WINDOWS) + +PyDoc_STRVAR(os_system__doc__, +"system($module, /, command)\n" +"--\n" +"\n" +"Execute the command in a subshell."); + +#define OS_SYSTEM_METHODDEF \ + {"system", (PyCFunction)os_system, METH_VARARGS|METH_KEYWORDS, os_system__doc__}, + +static long +os_system_impl(PyModuleDef *module, Py_UNICODE *command); + +static PyObject * +os_system(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"command", NULL}; + Py_UNICODE *command; + long _return_value; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "u:system", _keywords, + &command)) + goto exit; + _return_value = os_system_impl(module, command); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong(_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SYSTEM) && defined(MS_WINDOWS) */ + +#ifndef OS_SYSTEM_METHODDEF + #define OS_SYSTEM_METHODDEF +#endif /* !defined(OS_SYSTEM_METHODDEF) */ + +#if defined(HAVE_SYSTEM) && !defined(MS_WINDOWS) + +PyDoc_STRVAR(os_system__doc__, +"system($module, /, command)\n" +"--\n" +"\n" +"Execute the command in a subshell."); + +#define OS_SYSTEM_METHODDEF \ + {"system", (PyCFunction)os_system, METH_VARARGS|METH_KEYWORDS, os_system__doc__}, + +static long +os_system_impl(PyModuleDef *module, PyObject *command); + +static PyObject * +os_system(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"command", NULL}; + PyObject *command = NULL; + long _return_value; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&:system", _keywords, + PyUnicode_FSConverter, &command)) + goto exit; + _return_value = os_system_impl(module, command); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong(_return_value); + +exit: + /* Cleanup for command */ + Py_XDECREF(command); + + return return_value; +} + +#endif /* defined(HAVE_SYSTEM) && !defined(MS_WINDOWS) */ + +#ifndef OS_SYSTEM_METHODDEF + #define OS_SYSTEM_METHODDEF +#endif /* !defined(OS_SYSTEM_METHODDEF) */ + +PyDoc_STRVAR(os_umask__doc__, +"umask($module, mask, /)\n" +"--\n" +"\n" +"Set the current numeric umask and return the previous umask."); + +#define OS_UMASK_METHODDEF \ + {"umask", (PyCFunction)os_umask, METH_VARARGS, os_umask__doc__}, + +static PyObject * +os_umask_impl(PyModuleDef *module, int mask); + +static PyObject * +os_umask(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int mask; + + if (!PyArg_ParseTuple(args, + "i:umask", + &mask)) + goto exit; + return_value = os_umask_impl(module, mask); + +exit: + return return_value; +} + +PyDoc_STRVAR(os_unlink__doc__, +"unlink($module, /, path, *, dir_fd=None)\n" +"--\n" +"\n" +"Remove a file (same as remove()).\n" +"\n" +"If dir_fd is not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that directory.\n" +"dir_fd may not be implemented on your platform.\n" +" If it is unavailable, using it will raise a NotImplementedError."); + +#define OS_UNLINK_METHODDEF \ + {"unlink", (PyCFunction)os_unlink, METH_VARARGS|METH_KEYWORDS, os_unlink__doc__}, + +static PyObject * +os_unlink_impl(PyModuleDef *module, path_t *path, int dir_fd); + +static PyObject * +os_unlink(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "dir_fd", NULL}; + path_t path = PATH_T_INITIALIZE("unlink", "path", 0, 0); + int dir_fd = DEFAULT_DIR_FD; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&|$O&:unlink", _keywords, + path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) + goto exit; + return_value = os_unlink_impl(module, &path, dir_fd); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +PyDoc_STRVAR(os_remove__doc__, +"remove($module, /, path, *, dir_fd=None)\n" +"--\n" +"\n" +"Remove a file (same as unlink()).\n" +"\n" +"If dir_fd is not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that directory.\n" +"dir_fd may not be implemented on your platform.\n" +" If it is unavailable, using it will raise a NotImplementedError."); + +#define OS_REMOVE_METHODDEF \ + {"remove", (PyCFunction)os_remove, METH_VARARGS|METH_KEYWORDS, os_remove__doc__}, + +static PyObject * +os_remove_impl(PyModuleDef *module, path_t *path, int dir_fd); + +static PyObject * +os_remove(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "dir_fd", NULL}; + path_t path = PATH_T_INITIALIZE("remove", "path", 0, 0); + int dir_fd = DEFAULT_DIR_FD; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&|$O&:remove", _keywords, + path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) + goto exit; + return_value = os_remove_impl(module, &path, dir_fd); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#if defined(HAVE_UNAME) + +PyDoc_STRVAR(os_uname__doc__, +"uname($module, /)\n" +"--\n" +"\n" +"Return an object identifying the current operating system.\n" +"\n" +"The object behaves like a named tuple with the following fields:\n" +" (sysname, nodename, release, version, machine)"); + +#define OS_UNAME_METHODDEF \ + {"uname", (PyCFunction)os_uname, METH_NOARGS, os_uname__doc__}, + +static PyObject * +os_uname_impl(PyModuleDef *module); + +static PyObject * +os_uname(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_uname_impl(module); +} + +#endif /* defined(HAVE_UNAME) */ + +#ifndef OS_UNAME_METHODDEF + #define OS_UNAME_METHODDEF +#endif /* !defined(OS_UNAME_METHODDEF) */ + +PyDoc_STRVAR(os_utime__doc__, +"utime($module, /, path, times=None, *, ns=None, dir_fd=None,\n" +" follow_symlinks=True)\n" +"--\n" +"\n" +"Set the access and modified time of path.\n" +"\n" +"path may always be specified as a string.\n" +"On some platforms, path may also be specified as an open file descriptor.\n" +" If this functionality is unavailable, using it raises an exception.\n" +"\n" +"If times is not None, it must be a tuple (atime, mtime);\n" +" atime and mtime should be expressed as float seconds since the epoch.\n" +"If ns is not None, it must be a tuple (atime_ns, mtime_ns);\n" +" atime_ns and mtime_ns should be expressed as integer nanoseconds\n" +" since the epoch.\n" +"If both times and ns are None, utime uses the current time.\n" +"Specifying tuples for both times and ns is an error.\n" +"\n" +"If dir_fd is not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that directory.\n" +"If follow_symlinks is False, and the last element of the path is a symbolic\n" +" link, utime will modify the symbolic link itself instead of the file the\n" +" link points to.\n" +"It is an error to use dir_fd or follow_symlinks when specifying path\n" +" as an open file descriptor.\n" +"dir_fd and follow_symlinks may not be available on your platform.\n" +" If they are unavailable, using them will raise a NotImplementedError."); + +#define OS_UTIME_METHODDEF \ + {"utime", (PyCFunction)os_utime, METH_VARARGS|METH_KEYWORDS, os_utime__doc__}, + +static PyObject * +os_utime_impl(PyModuleDef *module, path_t *path, PyObject *times, PyObject *ns, int dir_fd, int follow_symlinks); + +static PyObject * +os_utime(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "times", "ns", "dir_fd", "follow_symlinks", NULL}; + path_t path = PATH_T_INITIALIZE("utime", "path", 0, PATH_UTIME_HAVE_FD); + PyObject *times = NULL; + PyObject *ns = NULL; + int dir_fd = DEFAULT_DIR_FD; + int follow_symlinks = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&|O$OO&p:utime", _keywords, + path_converter, &path, ×, &ns, FUTIMENSAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) + goto exit; + return_value = os_utime_impl(module, &path, times, ns, dir_fd, follow_symlinks); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +PyDoc_STRVAR(os__exit__doc__, +"_exit($module, /, status)\n" +"--\n" +"\n" +"Exit to the system with specified status, without normal exit processing."); + +#define OS__EXIT_METHODDEF \ + {"_exit", (PyCFunction)os__exit, METH_VARARGS|METH_KEYWORDS, os__exit__doc__}, + +static PyObject * +os__exit_impl(PyModuleDef *module, int status); + +static PyObject * +os__exit(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"status", NULL}; + int status; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:_exit", _keywords, + &status)) + goto exit; + return_value = os__exit_impl(module, status); + +exit: + return return_value; +} + +#if defined(HAVE_EXECV) + +PyDoc_STRVAR(os_execv__doc__, +"execv($module, path, argv, /)\n" +"--\n" +"\n" +"Execute an executable path with arguments, replacing current process.\n" +"\n" +" path\n" +" Path of executable file.\n" +" argv\n" +" Tuple or list of strings."); + +#define OS_EXECV_METHODDEF \ + {"execv", (PyCFunction)os_execv, METH_VARARGS, os_execv__doc__}, + +static PyObject * +os_execv_impl(PyModuleDef *module, PyObject *path, PyObject *argv); + +static PyObject * +os_execv(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *path = NULL; + PyObject *argv; + + if (!PyArg_ParseTuple(args, + "O&O:execv", + PyUnicode_FSConverter, &path, &argv)) + goto exit; + return_value = os_execv_impl(module, path, argv); + +exit: + /* Cleanup for path */ + Py_XDECREF(path); + + return return_value; +} + +#endif /* defined(HAVE_EXECV) */ + +#ifndef OS_EXECV_METHODDEF + #define OS_EXECV_METHODDEF +#endif /* !defined(OS_EXECV_METHODDEF) */ + +#if defined(HAVE_EXECV) + +PyDoc_STRVAR(os_execve__doc__, +"execve($module, /, path, argv, env)\n" +"--\n" +"\n" +"Execute an executable path with arguments, replacing current process.\n" +"\n" +" path\n" +" Path of executable file.\n" +" argv\n" +" Tuple or list of strings.\n" +" env\n" +" Dictionary of strings mapping to strings."); + +#define OS_EXECVE_METHODDEF \ + {"execve", (PyCFunction)os_execve, METH_VARARGS|METH_KEYWORDS, os_execve__doc__}, + +static PyObject * +os_execve_impl(PyModuleDef *module, path_t *path, PyObject *argv, PyObject *env); + +static PyObject * +os_execve(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "argv", "env", NULL}; + path_t path = PATH_T_INITIALIZE("execve", "path", 0, PATH_HAVE_FEXECVE); + PyObject *argv; + PyObject *env; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&OO:execve", _keywords, + path_converter, &path, &argv, &env)) + goto exit; + return_value = os_execve_impl(module, &path, argv, env); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(HAVE_EXECV) */ + +#ifndef OS_EXECVE_METHODDEF + #define OS_EXECVE_METHODDEF +#endif /* !defined(OS_EXECVE_METHODDEF) */ + +#if defined(HAVE_SPAWNV) + +PyDoc_STRVAR(os_spawnv__doc__, +"spawnv($module, mode, path, argv, /)\n" +"--\n" +"\n" +"Execute the program specified by path in a new process.\n" +"\n" +" mode\n" +" Mode of process creation.\n" +" path\n" +" Path of executable file.\n" +" argv\n" +" Tuple or list of strings."); + +#define OS_SPAWNV_METHODDEF \ + {"spawnv", (PyCFunction)os_spawnv, METH_VARARGS, os_spawnv__doc__}, + +static PyObject * +os_spawnv_impl(PyModuleDef *module, int mode, PyObject *path, PyObject *argv); + +static PyObject * +os_spawnv(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int mode; + PyObject *path = NULL; + PyObject *argv; + + if (!PyArg_ParseTuple(args, + "iO&O:spawnv", + &mode, PyUnicode_FSConverter, &path, &argv)) + goto exit; + return_value = os_spawnv_impl(module, mode, path, argv); + +exit: + /* Cleanup for path */ + Py_XDECREF(path); + + return return_value; +} + +#endif /* defined(HAVE_SPAWNV) */ + +#ifndef OS_SPAWNV_METHODDEF + #define OS_SPAWNV_METHODDEF +#endif /* !defined(OS_SPAWNV_METHODDEF) */ + +#if defined(HAVE_SPAWNV) + +PyDoc_STRVAR(os_spawnve__doc__, +"spawnve($module, mode, path, argv, env, /)\n" +"--\n" +"\n" +"Execute the program specified by path in a new process.\n" +"\n" +" mode\n" +" Mode of process creation.\n" +" path\n" +" Path of executable file.\n" +" argv\n" +" Tuple or list of strings.\n" +" env\n" +" Dictionary of strings mapping to strings."); + +#define OS_SPAWNVE_METHODDEF \ + {"spawnve", (PyCFunction)os_spawnve, METH_VARARGS, os_spawnve__doc__}, + +static PyObject * +os_spawnve_impl(PyModuleDef *module, int mode, PyObject *path, PyObject *argv, PyObject *env); + +static PyObject * +os_spawnve(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int mode; + PyObject *path = NULL; + PyObject *argv; + PyObject *env; + + if (!PyArg_ParseTuple(args, + "iO&OO:spawnve", + &mode, PyUnicode_FSConverter, &path, &argv, &env)) + goto exit; + return_value = os_spawnve_impl(module, mode, path, argv, env); + +exit: + /* Cleanup for path */ + Py_XDECREF(path); + + return return_value; +} + +#endif /* defined(HAVE_SPAWNV) */ + +#ifndef OS_SPAWNVE_METHODDEF + #define OS_SPAWNVE_METHODDEF +#endif /* !defined(OS_SPAWNVE_METHODDEF) */ + +#if defined(HAVE_FORK1) + +PyDoc_STRVAR(os_fork1__doc__, +"fork1($module, /)\n" +"--\n" +"\n" +"Fork a child process with a single multiplexed (i.e., not bound) thread.\n" +"\n" +"Return 0 to child process and PID of child to parent process."); + +#define OS_FORK1_METHODDEF \ + {"fork1", (PyCFunction)os_fork1, METH_NOARGS, os_fork1__doc__}, + +static PyObject * +os_fork1_impl(PyModuleDef *module); + +static PyObject * +os_fork1(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_fork1_impl(module); +} + +#endif /* defined(HAVE_FORK1) */ + +#ifndef OS_FORK1_METHODDEF + #define OS_FORK1_METHODDEF +#endif /* !defined(OS_FORK1_METHODDEF) */ + +#if defined(HAVE_FORK) + +PyDoc_STRVAR(os_fork__doc__, +"fork($module, /)\n" +"--\n" +"\n" +"Fork a child process.\n" +"\n" +"Return 0 to child process and PID of child to parent process."); + +#define OS_FORK_METHODDEF \ + {"fork", (PyCFunction)os_fork, METH_NOARGS, os_fork__doc__}, + +static PyObject * +os_fork_impl(PyModuleDef *module); + +static PyObject * +os_fork(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_fork_impl(module); +} + +#endif /* defined(HAVE_FORK) */ + +#ifndef OS_FORK_METHODDEF + #define OS_FORK_METHODDEF +#endif /* !defined(OS_FORK_METHODDEF) */ + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) + +PyDoc_STRVAR(os_sched_get_priority_max__doc__, +"sched_get_priority_max($module, /, policy)\n" +"--\n" +"\n" +"Get the maximum scheduling priority for policy."); + +#define OS_SCHED_GET_PRIORITY_MAX_METHODDEF \ + {"sched_get_priority_max", (PyCFunction)os_sched_get_priority_max, METH_VARARGS|METH_KEYWORDS, os_sched_get_priority_max__doc__}, + +static PyObject * +os_sched_get_priority_max_impl(PyModuleDef *module, int policy); + +static PyObject * +os_sched_get_priority_max(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"policy", NULL}; + int policy; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:sched_get_priority_max", _keywords, + &policy)) + goto exit; + return_value = os_sched_get_priority_max_impl(module, policy); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) */ + +#ifndef OS_SCHED_GET_PRIORITY_MAX_METHODDEF + #define OS_SCHED_GET_PRIORITY_MAX_METHODDEF +#endif /* !defined(OS_SCHED_GET_PRIORITY_MAX_METHODDEF) */ + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) + +PyDoc_STRVAR(os_sched_get_priority_min__doc__, +"sched_get_priority_min($module, /, policy)\n" +"--\n" +"\n" +"Get the minimum scheduling priority for policy."); + +#define OS_SCHED_GET_PRIORITY_MIN_METHODDEF \ + {"sched_get_priority_min", (PyCFunction)os_sched_get_priority_min, METH_VARARGS|METH_KEYWORDS, os_sched_get_priority_min__doc__}, + +static PyObject * +os_sched_get_priority_min_impl(PyModuleDef *module, int policy); + +static PyObject * +os_sched_get_priority_min(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"policy", NULL}; + int policy; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:sched_get_priority_min", _keywords, + &policy)) + goto exit; + return_value = os_sched_get_priority_min_impl(module, policy); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) */ + +#ifndef OS_SCHED_GET_PRIORITY_MIN_METHODDEF + #define OS_SCHED_GET_PRIORITY_MIN_METHODDEF +#endif /* !defined(OS_SCHED_GET_PRIORITY_MIN_METHODDEF) */ + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) + +PyDoc_STRVAR(os_sched_getscheduler__doc__, +"sched_getscheduler($module, pid, /)\n" +"--\n" +"\n" +"Get the scheduling policy for the process identifiedy by pid.\n" +"\n" +"Passing 0 for pid returns the scheduling policy for the calling process."); + +#define OS_SCHED_GETSCHEDULER_METHODDEF \ + {"sched_getscheduler", (PyCFunction)os_sched_getscheduler, METH_VARARGS, os_sched_getscheduler__doc__}, + +static PyObject * +os_sched_getscheduler_impl(PyModuleDef *module, pid_t pid); + +static PyObject * +os_sched_getscheduler(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pid; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_PID ":sched_getscheduler", + &pid)) + goto exit; + return_value = os_sched_getscheduler_impl(module, pid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) */ + +#ifndef OS_SCHED_GETSCHEDULER_METHODDEF + #define OS_SCHED_GETSCHEDULER_METHODDEF +#endif /* !defined(OS_SCHED_GETSCHEDULER_METHODDEF) */ + +#if defined(HAVE_SCHED_H) && (defined(HAVE_SCHED_SETSCHEDULER) || defined(HAVE_SCHED_SETPARAM)) + +PyDoc_STRVAR(os_sched_param__doc__, +"sched_param(sched_priority)\n" +"--\n" +"\n" +"Current has only one field: sched_priority\");\n" +"\n" +" sched_priority\n" +" A scheduling parameter."); + +static PyObject * +os_sched_param_impl(PyTypeObject *type, PyObject *sched_priority); + +static PyObject * +os_sched_param(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"sched_priority", NULL}; + PyObject *sched_priority; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O:sched_param", _keywords, + &sched_priority)) + goto exit; + return_value = os_sched_param_impl(type, sched_priority); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SCHED_H) && (defined(HAVE_SCHED_SETSCHEDULER) || defined(HAVE_SCHED_SETPARAM)) */ + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) + +PyDoc_STRVAR(os_sched_setscheduler__doc__, +"sched_setscheduler($module, pid, policy, param, /)\n" +"--\n" +"\n" +"Set the scheduling policy for the process identified by pid.\n" +"\n" +"If pid is 0, the calling process is changed.\n" +"param is an instance of sched_param."); + +#define OS_SCHED_SETSCHEDULER_METHODDEF \ + {"sched_setscheduler", (PyCFunction)os_sched_setscheduler, METH_VARARGS, os_sched_setscheduler__doc__}, + +static PyObject * +os_sched_setscheduler_impl(PyModuleDef *module, pid_t pid, int policy, struct sched_param *param); + +static PyObject * +os_sched_setscheduler(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pid; + int policy; + struct sched_param param; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_PID "iO&:sched_setscheduler", + &pid, &policy, convert_sched_param, ¶m)) + goto exit; + return_value = os_sched_setscheduler_impl(module, pid, policy, ¶m); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) */ + +#ifndef OS_SCHED_SETSCHEDULER_METHODDEF + #define OS_SCHED_SETSCHEDULER_METHODDEF +#endif /* !defined(OS_SCHED_SETSCHEDULER_METHODDEF) */ + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) + +PyDoc_STRVAR(os_sched_getparam__doc__, +"sched_getparam($module, pid, /)\n" +"--\n" +"\n" +"Returns scheduling parameters for the process identified by pid.\n" +"\n" +"If pid is 0, returns parameters for the calling process.\n" +"Return value is an instance of sched_param."); + +#define OS_SCHED_GETPARAM_METHODDEF \ + {"sched_getparam", (PyCFunction)os_sched_getparam, METH_VARARGS, os_sched_getparam__doc__}, + +static PyObject * +os_sched_getparam_impl(PyModuleDef *module, pid_t pid); + +static PyObject * +os_sched_getparam(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pid; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_PID ":sched_getparam", + &pid)) + goto exit; + return_value = os_sched_getparam_impl(module, pid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) */ + +#ifndef OS_SCHED_GETPARAM_METHODDEF + #define OS_SCHED_GETPARAM_METHODDEF +#endif /* !defined(OS_SCHED_GETPARAM_METHODDEF) */ + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) + +PyDoc_STRVAR(os_sched_setparam__doc__, +"sched_setparam($module, pid, param, /)\n" +"--\n" +"\n" +"Set scheduling parameters for the process identified by pid.\n" +"\n" +"If pid is 0, sets parameters for the calling process.\n" +"param should be an instance of sched_param."); + +#define OS_SCHED_SETPARAM_METHODDEF \ + {"sched_setparam", (PyCFunction)os_sched_setparam, METH_VARARGS, os_sched_setparam__doc__}, + +static PyObject * +os_sched_setparam_impl(PyModuleDef *module, pid_t pid, struct sched_param *param); + +static PyObject * +os_sched_setparam(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pid; + struct sched_param param; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_PID "O&:sched_setparam", + &pid, convert_sched_param, ¶m)) + goto exit; + return_value = os_sched_setparam_impl(module, pid, ¶m); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) */ + +#ifndef OS_SCHED_SETPARAM_METHODDEF + #define OS_SCHED_SETPARAM_METHODDEF +#endif /* !defined(OS_SCHED_SETPARAM_METHODDEF) */ + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_RR_GET_INTERVAL) + +PyDoc_STRVAR(os_sched_rr_get_interval__doc__, +"sched_rr_get_interval($module, pid, /)\n" +"--\n" +"\n" +"Return the round-robin quantum for the process identified by pid, in seconds.\n" +"\n" +"Value returned is a float."); + +#define OS_SCHED_RR_GET_INTERVAL_METHODDEF \ + {"sched_rr_get_interval", (PyCFunction)os_sched_rr_get_interval, METH_VARARGS, os_sched_rr_get_interval__doc__}, + +static double +os_sched_rr_get_interval_impl(PyModuleDef *module, pid_t pid); + +static PyObject * +os_sched_rr_get_interval(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pid; + double _return_value; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_PID ":sched_rr_get_interval", + &pid)) + goto exit; + _return_value = os_sched_rr_get_interval_impl(module, pid); + if ((_return_value == -1.0) && PyErr_Occurred()) + goto exit; + return_value = PyFloat_FromDouble(_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_RR_GET_INTERVAL) */ + +#ifndef OS_SCHED_RR_GET_INTERVAL_METHODDEF + #define OS_SCHED_RR_GET_INTERVAL_METHODDEF +#endif /* !defined(OS_SCHED_RR_GET_INTERVAL_METHODDEF) */ + +#if defined(HAVE_SCHED_H) + +PyDoc_STRVAR(os_sched_yield__doc__, +"sched_yield($module, /)\n" +"--\n" +"\n" +"Voluntarily relinquish the CPU."); + +#define OS_SCHED_YIELD_METHODDEF \ + {"sched_yield", (PyCFunction)os_sched_yield, METH_NOARGS, os_sched_yield__doc__}, + +static PyObject * +os_sched_yield_impl(PyModuleDef *module); + +static PyObject * +os_sched_yield(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_sched_yield_impl(module); +} + +#endif /* defined(HAVE_SCHED_H) */ + +#ifndef OS_SCHED_YIELD_METHODDEF + #define OS_SCHED_YIELD_METHODDEF +#endif /* !defined(OS_SCHED_YIELD_METHODDEF) */ + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) + +PyDoc_STRVAR(os_sched_setaffinity__doc__, +"sched_setaffinity($module, pid, mask, /)\n" +"--\n" +"\n" +"Set the CPU affinity of the process identified by pid to mask.\n" +"\n" +"mask should be an iterable of integers identifying CPUs."); + +#define OS_SCHED_SETAFFINITY_METHODDEF \ + {"sched_setaffinity", (PyCFunction)os_sched_setaffinity, METH_VARARGS, os_sched_setaffinity__doc__}, + +static PyObject * +os_sched_setaffinity_impl(PyModuleDef *module, pid_t pid, PyObject *mask); + +static PyObject * +os_sched_setaffinity(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pid; + PyObject *mask; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_PID "O:sched_setaffinity", + &pid, &mask)) + goto exit; + return_value = os_sched_setaffinity_impl(module, pid, mask); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) */ + +#ifndef OS_SCHED_SETAFFINITY_METHODDEF + #define OS_SCHED_SETAFFINITY_METHODDEF +#endif /* !defined(OS_SCHED_SETAFFINITY_METHODDEF) */ + +#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) + +PyDoc_STRVAR(os_sched_getaffinity__doc__, +"sched_getaffinity($module, pid, /)\n" +"--\n" +"\n" +"Return the affinity of the process identified by pid.\n" +"\n" +"The affinity is returned as a set of CPU identifiers."); + +#define OS_SCHED_GETAFFINITY_METHODDEF \ + {"sched_getaffinity", (PyCFunction)os_sched_getaffinity, METH_VARARGS, os_sched_getaffinity__doc__}, + +static PyObject * +os_sched_getaffinity_impl(PyModuleDef *module, pid_t pid); + +static PyObject * +os_sched_getaffinity(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pid; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_PID ":sched_getaffinity", + &pid)) + goto exit; + return_value = os_sched_getaffinity_impl(module, pid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) */ + +#ifndef OS_SCHED_GETAFFINITY_METHODDEF + #define OS_SCHED_GETAFFINITY_METHODDEF +#endif /* !defined(OS_SCHED_GETAFFINITY_METHODDEF) */ + +#if (defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)) + +PyDoc_STRVAR(os_openpty__doc__, +"openpty($module, /)\n" +"--\n" +"\n" +"Open a pseudo-terminal.\n" +"\n" +"Return a tuple of (master_fd, slave_fd) containing open file descriptors\n" +"for both the master and slave ends."); + +#define OS_OPENPTY_METHODDEF \ + {"openpty", (PyCFunction)os_openpty, METH_NOARGS, os_openpty__doc__}, + +static PyObject * +os_openpty_impl(PyModuleDef *module); + +static PyObject * +os_openpty(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_openpty_impl(module); +} + +#endif /* (defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)) */ + +#ifndef OS_OPENPTY_METHODDEF + #define OS_OPENPTY_METHODDEF +#endif /* !defined(OS_OPENPTY_METHODDEF) */ + +#if defined(HAVE_FORKPTY) + +PyDoc_STRVAR(os_forkpty__doc__, +"forkpty($module, /)\n" +"--\n" +"\n" +"Fork a new process with a new pseudo-terminal as controlling tty.\n" +"\n" +"Returns a tuple of (pid, master_fd).\n" +"Like fork(), return pid of 0 to the child process,\n" +"and pid of child to the parent process.\n" +"To both, return fd of newly opened pseudo-terminal."); + +#define OS_FORKPTY_METHODDEF \ + {"forkpty", (PyCFunction)os_forkpty, METH_NOARGS, os_forkpty__doc__}, + +static PyObject * +os_forkpty_impl(PyModuleDef *module); + +static PyObject * +os_forkpty(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_forkpty_impl(module); +} + +#endif /* defined(HAVE_FORKPTY) */ + +#ifndef OS_FORKPTY_METHODDEF + #define OS_FORKPTY_METHODDEF +#endif /* !defined(OS_FORKPTY_METHODDEF) */ + +#if defined(HAVE_GETEGID) + +PyDoc_STRVAR(os_getegid__doc__, +"getegid($module, /)\n" +"--\n" +"\n" +"Return the current process\'s effective group id."); + +#define OS_GETEGID_METHODDEF \ + {"getegid", (PyCFunction)os_getegid, METH_NOARGS, os_getegid__doc__}, + +static PyObject * +os_getegid_impl(PyModuleDef *module); + +static PyObject * +os_getegid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getegid_impl(module); +} + +#endif /* defined(HAVE_GETEGID) */ + +#ifndef OS_GETEGID_METHODDEF + #define OS_GETEGID_METHODDEF +#endif /* !defined(OS_GETEGID_METHODDEF) */ + +#if defined(HAVE_GETEUID) + +PyDoc_STRVAR(os_geteuid__doc__, +"geteuid($module, /)\n" +"--\n" +"\n" +"Return the current process\'s effective user id."); + +#define OS_GETEUID_METHODDEF \ + {"geteuid", (PyCFunction)os_geteuid, METH_NOARGS, os_geteuid__doc__}, + +static PyObject * +os_geteuid_impl(PyModuleDef *module); + +static PyObject * +os_geteuid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_geteuid_impl(module); +} + +#endif /* defined(HAVE_GETEUID) */ + +#ifndef OS_GETEUID_METHODDEF + #define OS_GETEUID_METHODDEF +#endif /* !defined(OS_GETEUID_METHODDEF) */ + +#if defined(HAVE_GETGID) + +PyDoc_STRVAR(os_getgid__doc__, +"getgid($module, /)\n" +"--\n" +"\n" +"Return the current process\'s group id."); + +#define OS_GETGID_METHODDEF \ + {"getgid", (PyCFunction)os_getgid, METH_NOARGS, os_getgid__doc__}, + +static PyObject * +os_getgid_impl(PyModuleDef *module); + +static PyObject * +os_getgid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getgid_impl(module); +} + +#endif /* defined(HAVE_GETGID) */ + +#ifndef OS_GETGID_METHODDEF + #define OS_GETGID_METHODDEF +#endif /* !defined(OS_GETGID_METHODDEF) */ + +PyDoc_STRVAR(os_getpid__doc__, +"getpid($module, /)\n" +"--\n" +"\n" +"Return the current process id."); + +#define OS_GETPID_METHODDEF \ + {"getpid", (PyCFunction)os_getpid, METH_NOARGS, os_getpid__doc__}, + +static PyObject * +os_getpid_impl(PyModuleDef *module); + +static PyObject * +os_getpid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getpid_impl(module); +} + +#if defined(HAVE_GETGROUPS) + +PyDoc_STRVAR(os_getgroups__doc__, +"getgroups($module, /)\n" +"--\n" +"\n" +"Return list of supplemental group IDs for the process."); + +#define OS_GETGROUPS_METHODDEF \ + {"getgroups", (PyCFunction)os_getgroups, METH_NOARGS, os_getgroups__doc__}, + +static PyObject * +os_getgroups_impl(PyModuleDef *module); + +static PyObject * +os_getgroups(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getgroups_impl(module); +} + +#endif /* defined(HAVE_GETGROUPS) */ + +#ifndef OS_GETGROUPS_METHODDEF + #define OS_GETGROUPS_METHODDEF +#endif /* !defined(OS_GETGROUPS_METHODDEF) */ + +#if defined(HAVE_GETPGID) + +PyDoc_STRVAR(os_getpgid__doc__, +"getpgid($module, /, pid)\n" +"--\n" +"\n" +"Call the system call getpgid(), and return the result."); + +#define OS_GETPGID_METHODDEF \ + {"getpgid", (PyCFunction)os_getpgid, METH_VARARGS|METH_KEYWORDS, os_getpgid__doc__}, + +static PyObject * +os_getpgid_impl(PyModuleDef *module, pid_t pid); + +static PyObject * +os_getpgid(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"pid", NULL}; + pid_t pid; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "" _Py_PARSE_PID ":getpgid", _keywords, + &pid)) + goto exit; + return_value = os_getpgid_impl(module, pid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_GETPGID) */ + +#ifndef OS_GETPGID_METHODDEF + #define OS_GETPGID_METHODDEF +#endif /* !defined(OS_GETPGID_METHODDEF) */ + +#if defined(HAVE_GETPGRP) + +PyDoc_STRVAR(os_getpgrp__doc__, +"getpgrp($module, /)\n" +"--\n" +"\n" +"Return the current process group id."); + +#define OS_GETPGRP_METHODDEF \ + {"getpgrp", (PyCFunction)os_getpgrp, METH_NOARGS, os_getpgrp__doc__}, + +static PyObject * +os_getpgrp_impl(PyModuleDef *module); + +static PyObject * +os_getpgrp(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getpgrp_impl(module); +} + +#endif /* defined(HAVE_GETPGRP) */ + +#ifndef OS_GETPGRP_METHODDEF + #define OS_GETPGRP_METHODDEF +#endif /* !defined(OS_GETPGRP_METHODDEF) */ + +#if defined(HAVE_SETPGRP) + +PyDoc_STRVAR(os_setpgrp__doc__, +"setpgrp($module, /)\n" +"--\n" +"\n" +"Make the current process the leader of its process group."); + +#define OS_SETPGRP_METHODDEF \ + {"setpgrp", (PyCFunction)os_setpgrp, METH_NOARGS, os_setpgrp__doc__}, + +static PyObject * +os_setpgrp_impl(PyModuleDef *module); + +static PyObject * +os_setpgrp(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_setpgrp_impl(module); +} + +#endif /* defined(HAVE_SETPGRP) */ + +#ifndef OS_SETPGRP_METHODDEF + #define OS_SETPGRP_METHODDEF +#endif /* !defined(OS_SETPGRP_METHODDEF) */ + +#if defined(HAVE_GETPPID) + +PyDoc_STRVAR(os_getppid__doc__, +"getppid($module, /)\n" +"--\n" +"\n" +"Return the parent\'s process id.\n" +"\n" +"If the parent process has already exited, Windows machines will still\n" +"return its id; others systems will return the id of the \'init\' process (1)."); + +#define OS_GETPPID_METHODDEF \ + {"getppid", (PyCFunction)os_getppid, METH_NOARGS, os_getppid__doc__}, + +static PyObject * +os_getppid_impl(PyModuleDef *module); + +static PyObject * +os_getppid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getppid_impl(module); +} + +#endif /* defined(HAVE_GETPPID) */ + +#ifndef OS_GETPPID_METHODDEF + #define OS_GETPPID_METHODDEF +#endif /* !defined(OS_GETPPID_METHODDEF) */ + +#if defined(HAVE_GETLOGIN) + +PyDoc_STRVAR(os_getlogin__doc__, +"getlogin($module, /)\n" +"--\n" +"\n" +"Return the actual login name."); + +#define OS_GETLOGIN_METHODDEF \ + {"getlogin", (PyCFunction)os_getlogin, METH_NOARGS, os_getlogin__doc__}, + +static PyObject * +os_getlogin_impl(PyModuleDef *module); + +static PyObject * +os_getlogin(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getlogin_impl(module); +} + +#endif /* defined(HAVE_GETLOGIN) */ + +#ifndef OS_GETLOGIN_METHODDEF + #define OS_GETLOGIN_METHODDEF +#endif /* !defined(OS_GETLOGIN_METHODDEF) */ + +#if defined(HAVE_GETUID) + +PyDoc_STRVAR(os_getuid__doc__, +"getuid($module, /)\n" +"--\n" +"\n" +"Return the current process\'s user id."); + +#define OS_GETUID_METHODDEF \ + {"getuid", (PyCFunction)os_getuid, METH_NOARGS, os_getuid__doc__}, + +static PyObject * +os_getuid_impl(PyModuleDef *module); + +static PyObject * +os_getuid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getuid_impl(module); +} + +#endif /* defined(HAVE_GETUID) */ + +#ifndef OS_GETUID_METHODDEF + #define OS_GETUID_METHODDEF +#endif /* !defined(OS_GETUID_METHODDEF) */ + +#if defined(HAVE_KILL) + +PyDoc_STRVAR(os_kill__doc__, +"kill($module, pid, signal, /)\n" +"--\n" +"\n" +"Kill a process with a signal."); + +#define OS_KILL_METHODDEF \ + {"kill", (PyCFunction)os_kill, METH_VARARGS, os_kill__doc__}, + +static PyObject * +os_kill_impl(PyModuleDef *module, pid_t pid, Py_ssize_t signal); + +static PyObject * +os_kill(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pid; + Py_ssize_t signal; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_PID "n:kill", + &pid, &signal)) + goto exit; + return_value = os_kill_impl(module, pid, signal); + +exit: + return return_value; +} + +#endif /* defined(HAVE_KILL) */ + +#ifndef OS_KILL_METHODDEF + #define OS_KILL_METHODDEF +#endif /* !defined(OS_KILL_METHODDEF) */ + +#if defined(HAVE_KILLPG) + +PyDoc_STRVAR(os_killpg__doc__, +"killpg($module, pgid, signal, /)\n" +"--\n" +"\n" +"Kill a process group with a signal."); + +#define OS_KILLPG_METHODDEF \ + {"killpg", (PyCFunction)os_killpg, METH_VARARGS, os_killpg__doc__}, + +static PyObject * +os_killpg_impl(PyModuleDef *module, pid_t pgid, int signal); + +static PyObject * +os_killpg(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pgid; + int signal; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_PID "i:killpg", + &pgid, &signal)) + goto exit; + return_value = os_killpg_impl(module, pgid, signal); + +exit: + return return_value; +} + +#endif /* defined(HAVE_KILLPG) */ + +#ifndef OS_KILLPG_METHODDEF + #define OS_KILLPG_METHODDEF +#endif /* !defined(OS_KILLPG_METHODDEF) */ + +#if defined(HAVE_PLOCK) + +PyDoc_STRVAR(os_plock__doc__, +"plock($module, op, /)\n" +"--\n" +"\n" +"Lock program segments into memory.\");"); + +#define OS_PLOCK_METHODDEF \ + {"plock", (PyCFunction)os_plock, METH_VARARGS, os_plock__doc__}, + +static PyObject * +os_plock_impl(PyModuleDef *module, int op); + +static PyObject * +os_plock(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int op; + + if (!PyArg_ParseTuple(args, + "i:plock", + &op)) + goto exit; + return_value = os_plock_impl(module, op); + +exit: + return return_value; +} + +#endif /* defined(HAVE_PLOCK) */ + +#ifndef OS_PLOCK_METHODDEF + #define OS_PLOCK_METHODDEF +#endif /* !defined(OS_PLOCK_METHODDEF) */ + +#if defined(HAVE_SETUID) + +PyDoc_STRVAR(os_setuid__doc__, +"setuid($module, uid, /)\n" +"--\n" +"\n" +"Set the current process\'s user id."); + +#define OS_SETUID_METHODDEF \ + {"setuid", (PyCFunction)os_setuid, METH_VARARGS, os_setuid__doc__}, + +static PyObject * +os_setuid_impl(PyModuleDef *module, uid_t uid); + +static PyObject * +os_setuid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + uid_t uid; + + if (!PyArg_ParseTuple(args, + "O&:setuid", + _Py_Uid_Converter, &uid)) + goto exit; + return_value = os_setuid_impl(module, uid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SETUID) */ + +#ifndef OS_SETUID_METHODDEF + #define OS_SETUID_METHODDEF +#endif /* !defined(OS_SETUID_METHODDEF) */ + +#if defined(HAVE_SETEUID) + +PyDoc_STRVAR(os_seteuid__doc__, +"seteuid($module, euid, /)\n" +"--\n" +"\n" +"Set the current process\'s effective user id."); + +#define OS_SETEUID_METHODDEF \ + {"seteuid", (PyCFunction)os_seteuid, METH_VARARGS, os_seteuid__doc__}, + +static PyObject * +os_seteuid_impl(PyModuleDef *module, uid_t euid); + +static PyObject * +os_seteuid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + uid_t euid; + + if (!PyArg_ParseTuple(args, + "O&:seteuid", + _Py_Uid_Converter, &euid)) + goto exit; + return_value = os_seteuid_impl(module, euid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SETEUID) */ + +#ifndef OS_SETEUID_METHODDEF + #define OS_SETEUID_METHODDEF +#endif /* !defined(OS_SETEUID_METHODDEF) */ + +#if defined(HAVE_SETEGID) + +PyDoc_STRVAR(os_setegid__doc__, +"setegid($module, egid, /)\n" +"--\n" +"\n" +"Set the current process\'s effective group id."); + +#define OS_SETEGID_METHODDEF \ + {"setegid", (PyCFunction)os_setegid, METH_VARARGS, os_setegid__doc__}, + +static PyObject * +os_setegid_impl(PyModuleDef *module, gid_t egid); + +static PyObject * +os_setegid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + gid_t egid; + + if (!PyArg_ParseTuple(args, + "O&:setegid", + _Py_Gid_Converter, &egid)) + goto exit; + return_value = os_setegid_impl(module, egid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SETEGID) */ + +#ifndef OS_SETEGID_METHODDEF + #define OS_SETEGID_METHODDEF +#endif /* !defined(OS_SETEGID_METHODDEF) */ + +#if defined(HAVE_SETREUID) + +PyDoc_STRVAR(os_setreuid__doc__, +"setreuid($module, ruid, euid, /)\n" +"--\n" +"\n" +"Set the current process\'s real and effective user ids."); + +#define OS_SETREUID_METHODDEF \ + {"setreuid", (PyCFunction)os_setreuid, METH_VARARGS, os_setreuid__doc__}, + +static PyObject * +os_setreuid_impl(PyModuleDef *module, uid_t ruid, uid_t euid); + +static PyObject * +os_setreuid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + uid_t ruid; + uid_t euid; + + if (!PyArg_ParseTuple(args, + "O&O&:setreuid", + _Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid)) + goto exit; + return_value = os_setreuid_impl(module, ruid, euid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SETREUID) */ + +#ifndef OS_SETREUID_METHODDEF + #define OS_SETREUID_METHODDEF +#endif /* !defined(OS_SETREUID_METHODDEF) */ + +#if defined(HAVE_SETREGID) + +PyDoc_STRVAR(os_setregid__doc__, +"setregid($module, rgid, egid, /)\n" +"--\n" +"\n" +"Set the current process\'s real and effective group ids."); + +#define OS_SETREGID_METHODDEF \ + {"setregid", (PyCFunction)os_setregid, METH_VARARGS, os_setregid__doc__}, + +static PyObject * +os_setregid_impl(PyModuleDef *module, gid_t rgid, gid_t egid); + +static PyObject * +os_setregid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + gid_t rgid; + gid_t egid; + + if (!PyArg_ParseTuple(args, + "O&O&:setregid", + _Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid)) + goto exit; + return_value = os_setregid_impl(module, rgid, egid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SETREGID) */ + +#ifndef OS_SETREGID_METHODDEF + #define OS_SETREGID_METHODDEF +#endif /* !defined(OS_SETREGID_METHODDEF) */ + +#if defined(HAVE_SETGID) + +PyDoc_STRVAR(os_setgid__doc__, +"setgid($module, gid, /)\n" +"--\n" +"\n" +"Set the current process\'s group id."); + +#define OS_SETGID_METHODDEF \ + {"setgid", (PyCFunction)os_setgid, METH_VARARGS, os_setgid__doc__}, + +static PyObject * +os_setgid_impl(PyModuleDef *module, gid_t gid); + +static PyObject * +os_setgid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + gid_t gid; + + if (!PyArg_ParseTuple(args, + "O&:setgid", + _Py_Gid_Converter, &gid)) + goto exit; + return_value = os_setgid_impl(module, gid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SETGID) */ + +#ifndef OS_SETGID_METHODDEF + #define OS_SETGID_METHODDEF +#endif /* !defined(OS_SETGID_METHODDEF) */ + +#if defined(HAVE_SETGROUPS) + +PyDoc_STRVAR(os_setgroups__doc__, +"setgroups($module, groups, /)\n" +"--\n" +"\n" +"Set the groups of the current process to list."); + +#define OS_SETGROUPS_METHODDEF \ + {"setgroups", (PyCFunction)os_setgroups, METH_O, os_setgroups__doc__}, + +#endif /* defined(HAVE_SETGROUPS) */ + +#ifndef OS_SETGROUPS_METHODDEF + #define OS_SETGROUPS_METHODDEF +#endif /* !defined(OS_SETGROUPS_METHODDEF) */ + +#if defined(HAVE_WAIT3) + +PyDoc_STRVAR(os_wait3__doc__, +"wait3($module, /, options)\n" +"--\n" +"\n" +"Wait for completion of a child process.\n" +"\n" +"Returns a tuple of information about the child process:\n" +" (pid, status, rusage)"); + +#define OS_WAIT3_METHODDEF \ + {"wait3", (PyCFunction)os_wait3, METH_VARARGS|METH_KEYWORDS, os_wait3__doc__}, + +static PyObject * +os_wait3_impl(PyModuleDef *module, int options); + +static PyObject * +os_wait3(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"options", NULL}; + int options; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:wait3", _keywords, + &options)) + goto exit; + return_value = os_wait3_impl(module, options); + +exit: + return return_value; +} + +#endif /* defined(HAVE_WAIT3) */ + +#ifndef OS_WAIT3_METHODDEF + #define OS_WAIT3_METHODDEF +#endif /* !defined(OS_WAIT3_METHODDEF) */ + +#if defined(HAVE_WAIT4) + +PyDoc_STRVAR(os_wait4__doc__, +"wait4($module, /, pid, options)\n" +"--\n" +"\n" +"Wait for completion of a specific child process.\n" +"\n" +"Returns a tuple of information about the child process:\n" +" (pid, status, rusage)"); + +#define OS_WAIT4_METHODDEF \ + {"wait4", (PyCFunction)os_wait4, METH_VARARGS|METH_KEYWORDS, os_wait4__doc__}, + +static PyObject * +os_wait4_impl(PyModuleDef *module, pid_t pid, int options); + +static PyObject * +os_wait4(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"pid", "options", NULL}; + pid_t pid; + int options; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "" _Py_PARSE_PID "i:wait4", _keywords, + &pid, &options)) + goto exit; + return_value = os_wait4_impl(module, pid, options); + +exit: + return return_value; +} + +#endif /* defined(HAVE_WAIT4) */ + +#ifndef OS_WAIT4_METHODDEF + #define OS_WAIT4_METHODDEF +#endif /* !defined(OS_WAIT4_METHODDEF) */ + +#if (defined(HAVE_WAITID) && !defined(__APPLE__)) + +PyDoc_STRVAR(os_waitid__doc__, +"waitid($module, idtype, id, options, /)\n" +"--\n" +"\n" +"Returns the result of waiting for a process or processes.\n" +"\n" +" idtype\n" +" Must be one of be P_PID, P_PGID or P_ALL.\n" +" id\n" +" The id to wait on.\n" +" options\n" +" Constructed from the ORing of one or more of WEXITED, WSTOPPED\n" +" or WCONTINUED and additionally may be ORed with WNOHANG or WNOWAIT.\n" +"\n" +"Returns either waitid_result or None if WNOHANG is specified and there are\n" +"no children in a waitable state."); + +#define OS_WAITID_METHODDEF \ + {"waitid", (PyCFunction)os_waitid, METH_VARARGS, os_waitid__doc__}, + +static PyObject * +os_waitid_impl(PyModuleDef *module, idtype_t idtype, id_t id, int options); + +static PyObject * +os_waitid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + idtype_t idtype; + id_t id; + int options; + + if (!PyArg_ParseTuple(args, + "i" _Py_PARSE_PID "i:waitid", + &idtype, &id, &options)) + goto exit; + return_value = os_waitid_impl(module, idtype, id, options); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_WAITID) && !defined(__APPLE__)) */ + +#ifndef OS_WAITID_METHODDEF + #define OS_WAITID_METHODDEF +#endif /* !defined(OS_WAITID_METHODDEF) */ + +#if defined(HAVE_WAITPID) + +PyDoc_STRVAR(os_waitpid__doc__, +"waitpid($module, pid, options, /)\n" +"--\n" +"\n" +"Wait for completion of a given child process.\n" +"\n" +"Returns a tuple of information regarding the child process:\n" +" (pid, status)\n" +"\n" +"The options argument is ignored on Windows."); + +#define OS_WAITPID_METHODDEF \ + {"waitpid", (PyCFunction)os_waitpid, METH_VARARGS, os_waitpid__doc__}, + +static PyObject * +os_waitpid_impl(PyModuleDef *module, pid_t pid, int options); + +static PyObject * +os_waitpid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pid; + int options; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_PID "i:waitpid", + &pid, &options)) + goto exit; + return_value = os_waitpid_impl(module, pid, options); + +exit: + return return_value; +} + +#endif /* defined(HAVE_WAITPID) */ + +#ifndef OS_WAITPID_METHODDEF + #define OS_WAITPID_METHODDEF +#endif /* !defined(OS_WAITPID_METHODDEF) */ + +#if defined(HAVE_CWAIT) + +PyDoc_STRVAR(os_waitpid__doc__, +"waitpid($module, pid, options, /)\n" +"--\n" +"\n" +"Wait for completion of a given process.\n" +"\n" +"Returns a tuple of information regarding the process:\n" +" (pid, status << 8)\n" +"\n" +"The options argument is ignored on Windows."); + +#define OS_WAITPID_METHODDEF \ + {"waitpid", (PyCFunction)os_waitpid, METH_VARARGS, os_waitpid__doc__}, + +static PyObject * +os_waitpid_impl(PyModuleDef *module, Py_intptr_t pid, int options); + +static PyObject * +os_waitpid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + Py_intptr_t pid; + int options; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_INTPTR "i:waitpid", + &pid, &options)) + goto exit; + return_value = os_waitpid_impl(module, pid, options); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CWAIT) */ + +#ifndef OS_WAITPID_METHODDEF + #define OS_WAITPID_METHODDEF +#endif /* !defined(OS_WAITPID_METHODDEF) */ + +#if defined(HAVE_WAIT) + +PyDoc_STRVAR(os_wait__doc__, +"wait($module, /)\n" +"--\n" +"\n" +"Wait for completion of a child process.\n" +"\n" +"Returns a tuple of information about the child process:\n" +" (pid, status)"); + +#define OS_WAIT_METHODDEF \ + {"wait", (PyCFunction)os_wait, METH_NOARGS, os_wait__doc__}, + +static PyObject * +os_wait_impl(PyModuleDef *module); + +static PyObject * +os_wait(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_wait_impl(module); +} + +#endif /* defined(HAVE_WAIT) */ + +#ifndef OS_WAIT_METHODDEF + #define OS_WAIT_METHODDEF +#endif /* !defined(OS_WAIT_METHODDEF) */ + +#if defined(HAVE_SYMLINK) + +PyDoc_STRVAR(os_symlink__doc__, +"symlink($module, /, src, dst, target_is_directory=False, *, dir_fd=None)\n" +"--\n" +"\n" +"Create a symbolic link pointing to src named dst.\n" +"\n" +"target_is_directory is required on Windows if the target is to be\n" +" interpreted as a directory. (On Windows, symlink requires\n" +" Windows 6.0 or greater, and raises a NotImplementedError otherwise.)\n" +" target_is_directory is ignored on non-Windows platforms.\n" +"\n" +"If dir_fd is not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that directory.\n" +"dir_fd may not be implemented on your platform.\n" +" If it is unavailable, using it will raise a NotImplementedError."); + +#define OS_SYMLINK_METHODDEF \ + {"symlink", (PyCFunction)os_symlink, METH_VARARGS|METH_KEYWORDS, os_symlink__doc__}, + +static PyObject * +os_symlink_impl(PyModuleDef *module, path_t *src, path_t *dst, int target_is_directory, int dir_fd); + +static PyObject * +os_symlink(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"src", "dst", "target_is_directory", "dir_fd", NULL}; + path_t src = PATH_T_INITIALIZE("symlink", "src", 0, 0); + path_t dst = PATH_T_INITIALIZE("symlink", "dst", 0, 0); + int target_is_directory = 0; + int dir_fd = DEFAULT_DIR_FD; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&O&|p$O&:symlink", _keywords, + path_converter, &src, path_converter, &dst, &target_is_directory, SYMLINKAT_DIR_FD_CONVERTER, &dir_fd)) + goto exit; + return_value = os_symlink_impl(module, &src, &dst, target_is_directory, dir_fd); + +exit: + /* Cleanup for src */ + path_cleanup(&src); + /* Cleanup for dst */ + path_cleanup(&dst); + + return return_value; +} + +#endif /* defined(HAVE_SYMLINK) */ + +#ifndef OS_SYMLINK_METHODDEF + #define OS_SYMLINK_METHODDEF +#endif /* !defined(OS_SYMLINK_METHODDEF) */ + +#if defined(HAVE_TIMES) + +PyDoc_STRVAR(os_times__doc__, +"times($module, /)\n" +"--\n" +"\n" +"Return a collection containing process timing information.\n" +"\n" +"The object returned behaves like a named tuple with these fields:\n" +" (utime, stime, cutime, cstime, elapsed_time)\n" +"All fields are floating point numbers."); + +#define OS_TIMES_METHODDEF \ + {"times", (PyCFunction)os_times, METH_NOARGS, os_times__doc__}, + +static PyObject * +os_times_impl(PyModuleDef *module); + +static PyObject * +os_times(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_times_impl(module); +} + +#endif /* defined(HAVE_TIMES) */ + +#ifndef OS_TIMES_METHODDEF + #define OS_TIMES_METHODDEF +#endif /* !defined(OS_TIMES_METHODDEF) */ + +#if defined(HAVE_GETSID) + +PyDoc_STRVAR(os_getsid__doc__, +"getsid($module, pid, /)\n" +"--\n" +"\n" +"Call the system call getsid(pid) and return the result."); + +#define OS_GETSID_METHODDEF \ + {"getsid", (PyCFunction)os_getsid, METH_VARARGS, os_getsid__doc__}, + +static PyObject * +os_getsid_impl(PyModuleDef *module, pid_t pid); + +static PyObject * +os_getsid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pid; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_PID ":getsid", + &pid)) + goto exit; + return_value = os_getsid_impl(module, pid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_GETSID) */ + +#ifndef OS_GETSID_METHODDEF + #define OS_GETSID_METHODDEF +#endif /* !defined(OS_GETSID_METHODDEF) */ + +#if defined(HAVE_SETSID) + +PyDoc_STRVAR(os_setsid__doc__, +"setsid($module, /)\n" +"--\n" +"\n" +"Call the system call setsid()."); + +#define OS_SETSID_METHODDEF \ + {"setsid", (PyCFunction)os_setsid, METH_NOARGS, os_setsid__doc__}, + +static PyObject * +os_setsid_impl(PyModuleDef *module); + +static PyObject * +os_setsid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_setsid_impl(module); +} + +#endif /* defined(HAVE_SETSID) */ + +#ifndef OS_SETSID_METHODDEF + #define OS_SETSID_METHODDEF +#endif /* !defined(OS_SETSID_METHODDEF) */ + +#if defined(HAVE_SETPGID) + +PyDoc_STRVAR(os_setpgid__doc__, +"setpgid($module, pid, pgrp, /)\n" +"--\n" +"\n" +"Call the system call setpgid(pid, pgrp)."); + +#define OS_SETPGID_METHODDEF \ + {"setpgid", (PyCFunction)os_setpgid, METH_VARARGS, os_setpgid__doc__}, + +static PyObject * +os_setpgid_impl(PyModuleDef *module, pid_t pid, pid_t pgrp); + +static PyObject * +os_setpgid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pid; + pid_t pgrp; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_PID "" _Py_PARSE_PID ":setpgid", + &pid, &pgrp)) + goto exit; + return_value = os_setpgid_impl(module, pid, pgrp); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SETPGID) */ + +#ifndef OS_SETPGID_METHODDEF + #define OS_SETPGID_METHODDEF +#endif /* !defined(OS_SETPGID_METHODDEF) */ + +#if defined(HAVE_TCGETPGRP) + +PyDoc_STRVAR(os_tcgetpgrp__doc__, +"tcgetpgrp($module, fd, /)\n" +"--\n" +"\n" +"Return the process group associated with the terminal specified by fd."); + +#define OS_TCGETPGRP_METHODDEF \ + {"tcgetpgrp", (PyCFunction)os_tcgetpgrp, METH_VARARGS, os_tcgetpgrp__doc__}, + +static PyObject * +os_tcgetpgrp_impl(PyModuleDef *module, int fd); + +static PyObject * +os_tcgetpgrp(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + + if (!PyArg_ParseTuple(args, + "i:tcgetpgrp", + &fd)) + goto exit; + return_value = os_tcgetpgrp_impl(module, fd); + +exit: + return return_value; +} + +#endif /* defined(HAVE_TCGETPGRP) */ + +#ifndef OS_TCGETPGRP_METHODDEF + #define OS_TCGETPGRP_METHODDEF +#endif /* !defined(OS_TCGETPGRP_METHODDEF) */ + +#if defined(HAVE_TCSETPGRP) + +PyDoc_STRVAR(os_tcsetpgrp__doc__, +"tcsetpgrp($module, fd, pgid, /)\n" +"--\n" +"\n" +"Set the process group associated with the terminal specified by fd."); + +#define OS_TCSETPGRP_METHODDEF \ + {"tcsetpgrp", (PyCFunction)os_tcsetpgrp, METH_VARARGS, os_tcsetpgrp__doc__}, + +static PyObject * +os_tcsetpgrp_impl(PyModuleDef *module, int fd, pid_t pgid); + +static PyObject * +os_tcsetpgrp(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + pid_t pgid; + + if (!PyArg_ParseTuple(args, + "i" _Py_PARSE_PID ":tcsetpgrp", + &fd, &pgid)) + goto exit; + return_value = os_tcsetpgrp_impl(module, fd, pgid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_TCSETPGRP) */ + +#ifndef OS_TCSETPGRP_METHODDEF + #define OS_TCSETPGRP_METHODDEF +#endif /* !defined(OS_TCSETPGRP_METHODDEF) */ + +PyDoc_STRVAR(os_open__doc__, +"open($module, /, path, flags, mode=511, *, dir_fd=None)\n" +"--\n" +"\n" +"Open a file for low level IO. Returns a file descriptor (integer).\n" +"\n" +"If dir_fd is not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that directory.\n" +"dir_fd may not be implemented on your platform.\n" +" If it is unavailable, using it will raise a NotImplementedError."); + +#define OS_OPEN_METHODDEF \ + {"open", (PyCFunction)os_open, METH_VARARGS|METH_KEYWORDS, os_open__doc__}, + +static int +os_open_impl(PyModuleDef *module, path_t *path, int flags, int mode, int dir_fd); + +static PyObject * +os_open(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "flags", "mode", "dir_fd", NULL}; + path_t path = PATH_T_INITIALIZE("open", "path", 0, 0); + int flags; + int mode = 511; + int dir_fd = DEFAULT_DIR_FD; + int _return_value; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&i|i$O&:open", _keywords, + path_converter, &path, &flags, &mode, OPENAT_DIR_FD_CONVERTER, &dir_fd)) + goto exit; + _return_value = os_open_impl(module, &path, flags, mode, dir_fd); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong((long)_return_value); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +PyDoc_STRVAR(os_close__doc__, +"close($module, /, fd)\n" +"--\n" +"\n" +"Close a file descriptor."); + +#define OS_CLOSE_METHODDEF \ + {"close", (PyCFunction)os_close, METH_VARARGS|METH_KEYWORDS, os_close__doc__}, + +static PyObject * +os_close_impl(PyModuleDef *module, int fd); + +static PyObject * +os_close(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"fd", NULL}; + int fd; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:close", _keywords, + &fd)) + goto exit; + return_value = os_close_impl(module, fd); + +exit: + return return_value; +} + +PyDoc_STRVAR(os_closerange__doc__, +"closerange($module, fd_low, fd_high, /)\n" +"--\n" +"\n" +"Closes all file descriptors in [fd_low, fd_high), ignoring errors."); + +#define OS_CLOSERANGE_METHODDEF \ + {"closerange", (PyCFunction)os_closerange, METH_VARARGS, os_closerange__doc__}, + +static PyObject * +os_closerange_impl(PyModuleDef *module, int fd_low, int fd_high); + +static PyObject * +os_closerange(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd_low; + int fd_high; + + if (!PyArg_ParseTuple(args, + "ii:closerange", + &fd_low, &fd_high)) + goto exit; + return_value = os_closerange_impl(module, fd_low, fd_high); + +exit: + return return_value; +} + +PyDoc_STRVAR(os_dup__doc__, +"dup($module, fd, /)\n" +"--\n" +"\n" +"Return a duplicate of a file descriptor."); + +#define OS_DUP_METHODDEF \ + {"dup", (PyCFunction)os_dup, METH_VARARGS, os_dup__doc__}, + +static int +os_dup_impl(PyModuleDef *module, int fd); + +static PyObject * +os_dup(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + int _return_value; + + if (!PyArg_ParseTuple(args, + "i:dup", + &fd)) + goto exit; + _return_value = os_dup_impl(module, fd); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong((long)_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(os_dup2__doc__, +"dup2($module, /, fd, fd2, inheritable=True)\n" +"--\n" +"\n" +"Duplicate file descriptor."); + +#define OS_DUP2_METHODDEF \ + {"dup2", (PyCFunction)os_dup2, METH_VARARGS|METH_KEYWORDS, os_dup2__doc__}, + +static PyObject * +os_dup2_impl(PyModuleDef *module, int fd, int fd2, int inheritable); + +static PyObject * +os_dup2(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"fd", "fd2", "inheritable", NULL}; + int fd; + int fd2; + int inheritable = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "ii|p:dup2", _keywords, + &fd, &fd2, &inheritable)) + goto exit; + return_value = os_dup2_impl(module, fd, fd2, inheritable); + +exit: + return return_value; +} + +#if defined(HAVE_LOCKF) + +PyDoc_STRVAR(os_lockf__doc__, +"lockf($module, fd, command, length, /)\n" +"--\n" +"\n" +"Apply, test or remove a POSIX lock on an open file descriptor.\n" +"\n" +" fd\n" +" An open file descriptor.\n" +" command\n" +" One of F_LOCK, F_TLOCK, F_ULOCK or F_TEST.\n" +" length\n" +" The number of bytes to lock, starting at the current position."); + +#define OS_LOCKF_METHODDEF \ + {"lockf", (PyCFunction)os_lockf, METH_VARARGS, os_lockf__doc__}, + +static PyObject * +os_lockf_impl(PyModuleDef *module, int fd, int command, Py_off_t length); + +static PyObject * +os_lockf(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + int command; + Py_off_t length; + + if (!PyArg_ParseTuple(args, + "iiO&:lockf", + &fd, &command, Py_off_t_converter, &length)) + goto exit; + return_value = os_lockf_impl(module, fd, command, length); + +exit: + return return_value; +} + +#endif /* defined(HAVE_LOCKF) */ + +#ifndef OS_LOCKF_METHODDEF + #define OS_LOCKF_METHODDEF +#endif /* !defined(OS_LOCKF_METHODDEF) */ + +PyDoc_STRVAR(os_lseek__doc__, +"lseek($module, fd, position, how, /)\n" +"--\n" +"\n" +"Set the position of a file descriptor. Return the new position.\n" +"\n" +"Return the new cursor position in number of bytes\n" +"relative to the beginning of the file."); + +#define OS_LSEEK_METHODDEF \ + {"lseek", (PyCFunction)os_lseek, METH_VARARGS, os_lseek__doc__}, + +static Py_off_t +os_lseek_impl(PyModuleDef *module, int fd, Py_off_t position, int how); + +static PyObject * +os_lseek(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + Py_off_t position; + int how; + Py_off_t _return_value; + + if (!PyArg_ParseTuple(args, + "iO&i:lseek", + &fd, Py_off_t_converter, &position, &how)) + goto exit; + _return_value = os_lseek_impl(module, fd, position, how); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromPy_off_t(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(os_read__doc__, +"read($module, fd, length, /)\n" +"--\n" +"\n" +"Read from a file descriptor. Returns a bytes object."); + +#define OS_READ_METHODDEF \ + {"read", (PyCFunction)os_read, METH_VARARGS, os_read__doc__}, + +static PyObject * +os_read_impl(PyModuleDef *module, int fd, Py_ssize_t length); + +static PyObject * +os_read(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + Py_ssize_t length; + + if (!PyArg_ParseTuple(args, + "in:read", + &fd, &length)) + goto exit; + return_value = os_read_impl(module, fd, length); + +exit: + return return_value; +} + +#if defined(HAVE_READV) + +PyDoc_STRVAR(os_readv__doc__, +"readv($module, fd, buffers, /)\n" +"--\n" +"\n" +"Read from a file descriptor fd into an iterable of buffers.\n" +"\n" +"The buffers should be mutable buffers accepting bytes.\n" +"readv will transfer data into each buffer until it is full\n" +"and then move on to the next buffer in the sequence to hold\n" +"the rest of the data.\n" +"\n" +"readv returns the total number of bytes read,\n" +"which may be less than the total capacity of all the buffers."); + +#define OS_READV_METHODDEF \ + {"readv", (PyCFunction)os_readv, METH_VARARGS, os_readv__doc__}, + +static Py_ssize_t +os_readv_impl(PyModuleDef *module, int fd, PyObject *buffers); + +static PyObject * +os_readv(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + PyObject *buffers; + Py_ssize_t _return_value; + + if (!PyArg_ParseTuple(args, + "iO:readv", + &fd, &buffers)) + goto exit; + _return_value = os_readv_impl(module, fd, buffers); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromSsize_t(_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_READV) */ + +#ifndef OS_READV_METHODDEF + #define OS_READV_METHODDEF +#endif /* !defined(OS_READV_METHODDEF) */ + +#if defined(HAVE_PREAD) + +PyDoc_STRVAR(os_pread__doc__, +"pread($module, fd, length, offset, /)\n" +"--\n" +"\n" +"Read a number of bytes from a file descriptor starting at a particular offset.\n" +"\n" +"Read length bytes from file descriptor fd, starting at offset bytes from\n" +"the beginning of the file. The file offset remains unchanged."); + +#define OS_PREAD_METHODDEF \ + {"pread", (PyCFunction)os_pread, METH_VARARGS, os_pread__doc__}, + +static PyObject * +os_pread_impl(PyModuleDef *module, int fd, int length, Py_off_t offset); + +static PyObject * +os_pread(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + int length; + Py_off_t offset; + + if (!PyArg_ParseTuple(args, + "iiO&:pread", + &fd, &length, Py_off_t_converter, &offset)) + goto exit; + return_value = os_pread_impl(module, fd, length, offset); + +exit: + return return_value; +} + +#endif /* defined(HAVE_PREAD) */ + +#ifndef OS_PREAD_METHODDEF + #define OS_PREAD_METHODDEF +#endif /* !defined(OS_PREAD_METHODDEF) */ + +PyDoc_STRVAR(os_write__doc__, +"write($module, fd, data, /)\n" +"--\n" +"\n" +"Write a bytes object to a file descriptor."); + +#define OS_WRITE_METHODDEF \ + {"write", (PyCFunction)os_write, METH_VARARGS, os_write__doc__}, + +static Py_ssize_t +os_write_impl(PyModuleDef *module, int fd, Py_buffer *data); + +static PyObject * +os_write(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + Py_buffer data = {NULL, NULL}; + Py_ssize_t _return_value; + + if (!PyArg_ParseTuple(args, + "iy*:write", + &fd, &data)) + goto exit; + _return_value = os_write_impl(module, fd, &data); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromSsize_t(_return_value); + +exit: + /* Cleanup for data */ + if (data.obj) + PyBuffer_Release(&data); + + return return_value; +} + +PyDoc_STRVAR(os_fstat__doc__, +"fstat($module, /, fd)\n" +"--\n" +"\n" +"Perform a stat system call on the given file descriptor.\n" +"\n" +"Like stat(), but for an open file descriptor.\n" +"Equivalent to os.stat(fd)."); + +#define OS_FSTAT_METHODDEF \ + {"fstat", (PyCFunction)os_fstat, METH_VARARGS|METH_KEYWORDS, os_fstat__doc__}, + +static PyObject * +os_fstat_impl(PyModuleDef *module, int fd); + +static PyObject * +os_fstat(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"fd", NULL}; + int fd; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:fstat", _keywords, + &fd)) + goto exit; + return_value = os_fstat_impl(module, fd); + +exit: + return return_value; +} + +PyDoc_STRVAR(os_isatty__doc__, +"isatty($module, fd, /)\n" +"--\n" +"\n" +"Return True if the fd is connected to a terminal.\n" +"\n" +"Return True if the file descriptor is an open file descriptor\n" +"connected to the slave end of a terminal."); + +#define OS_ISATTY_METHODDEF \ + {"isatty", (PyCFunction)os_isatty, METH_VARARGS, os_isatty__doc__}, + +static int +os_isatty_impl(PyModuleDef *module, int fd); + +static PyObject * +os_isatty(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + int _return_value; + + if (!PyArg_ParseTuple(args, + "i:isatty", + &fd)) + goto exit; + _return_value = os_isatty_impl(module, fd); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +#if defined(HAVE_PIPE) + +PyDoc_STRVAR(os_pipe__doc__, +"pipe($module, /)\n" +"--\n" +"\n" +"Create a pipe.\n" +"\n" +"Returns a tuple of two file descriptors:\n" +" (read_fd, write_fd)"); + +#define OS_PIPE_METHODDEF \ + {"pipe", (PyCFunction)os_pipe, METH_NOARGS, os_pipe__doc__}, + +static PyObject * +os_pipe_impl(PyModuleDef *module); + +static PyObject * +os_pipe(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_pipe_impl(module); +} + +#endif /* defined(HAVE_PIPE) */ + +#ifndef OS_PIPE_METHODDEF + #define OS_PIPE_METHODDEF +#endif /* !defined(OS_PIPE_METHODDEF) */ + +#if defined(HAVE_PIPE2) + +PyDoc_STRVAR(os_pipe2__doc__, +"pipe2($module, flags, /)\n" +"--\n" +"\n" +"Create a pipe with flags set atomically.\n" +"\n" +"Returns a tuple of two file descriptors:\n" +" (read_fd, write_fd)\n" +"\n" +"flags can be constructed by ORing together one or more of these values:\n" +"O_NONBLOCK, O_CLOEXEC."); + +#define OS_PIPE2_METHODDEF \ + {"pipe2", (PyCFunction)os_pipe2, METH_VARARGS, os_pipe2__doc__}, + +static PyObject * +os_pipe2_impl(PyModuleDef *module, int flags); + +static PyObject * +os_pipe2(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int flags; + + if (!PyArg_ParseTuple(args, + "i:pipe2", + &flags)) + goto exit; + return_value = os_pipe2_impl(module, flags); + +exit: + return return_value; +} + +#endif /* defined(HAVE_PIPE2) */ + +#ifndef OS_PIPE2_METHODDEF + #define OS_PIPE2_METHODDEF +#endif /* !defined(OS_PIPE2_METHODDEF) */ + +#if defined(HAVE_WRITEV) + +PyDoc_STRVAR(os_writev__doc__, +"writev($module, fd, buffers, /)\n" +"--\n" +"\n" +"Iterate over buffers, and write the contents of each to a file descriptor.\n" +"\n" +"Returns the total number of bytes written.\n" +"buffers must be a sequence of bytes-like objects."); + +#define OS_WRITEV_METHODDEF \ + {"writev", (PyCFunction)os_writev, METH_VARARGS, os_writev__doc__}, + +static Py_ssize_t +os_writev_impl(PyModuleDef *module, int fd, PyObject *buffers); + +static PyObject * +os_writev(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + PyObject *buffers; + Py_ssize_t _return_value; + + if (!PyArg_ParseTuple(args, + "iO:writev", + &fd, &buffers)) + goto exit; + _return_value = os_writev_impl(module, fd, buffers); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromSsize_t(_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_WRITEV) */ + +#ifndef OS_WRITEV_METHODDEF + #define OS_WRITEV_METHODDEF +#endif /* !defined(OS_WRITEV_METHODDEF) */ + +#if defined(HAVE_PWRITE) + +PyDoc_STRVAR(os_pwrite__doc__, +"pwrite($module, fd, buffer, offset, /)\n" +"--\n" +"\n" +"Write bytes to a file descriptor starting at a particular offset.\n" +"\n" +"Write buffer to fd, starting at offset bytes from the beginning of\n" +"the file. Returns the number of bytes writte. Does not change the\n" +"current file offset."); + +#define OS_PWRITE_METHODDEF \ + {"pwrite", (PyCFunction)os_pwrite, METH_VARARGS, os_pwrite__doc__}, + +static Py_ssize_t +os_pwrite_impl(PyModuleDef *module, int fd, Py_buffer *buffer, Py_off_t offset); + +static PyObject * +os_pwrite(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + Py_buffer buffer = {NULL, NULL}; + Py_off_t offset; + Py_ssize_t _return_value; + + if (!PyArg_ParseTuple(args, + "iy*O&:pwrite", + &fd, &buffer, Py_off_t_converter, &offset)) + goto exit; + _return_value = os_pwrite_impl(module, fd, &buffer, offset); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromSsize_t(_return_value); + +exit: + /* Cleanup for buffer */ + if (buffer.obj) + PyBuffer_Release(&buffer); + + return return_value; +} + +#endif /* defined(HAVE_PWRITE) */ + +#ifndef OS_PWRITE_METHODDEF + #define OS_PWRITE_METHODDEF +#endif /* !defined(OS_PWRITE_METHODDEF) */ + +#if defined(HAVE_MKFIFO) + +PyDoc_STRVAR(os_mkfifo__doc__, +"mkfifo($module, /, path, mode=438, *, dir_fd=None)\n" +"--\n" +"\n" +"Create a \"fifo\" (a POSIX named pipe).\n" +"\n" +"If dir_fd is not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that directory.\n" +"dir_fd may not be implemented on your platform.\n" +" If it is unavailable, using it will raise a NotImplementedError."); + +#define OS_MKFIFO_METHODDEF \ + {"mkfifo", (PyCFunction)os_mkfifo, METH_VARARGS|METH_KEYWORDS, os_mkfifo__doc__}, + +static PyObject * +os_mkfifo_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd); + +static PyObject * +os_mkfifo(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "mode", "dir_fd", NULL}; + path_t path = PATH_T_INITIALIZE("mkfifo", "path", 0, 0); + int mode = 438; + int dir_fd = DEFAULT_DIR_FD; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&|i$O&:mkfifo", _keywords, + path_converter, &path, &mode, MKFIFOAT_DIR_FD_CONVERTER, &dir_fd)) + goto exit; + return_value = os_mkfifo_impl(module, &path, mode, dir_fd); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(HAVE_MKFIFO) */ + +#ifndef OS_MKFIFO_METHODDEF + #define OS_MKFIFO_METHODDEF +#endif /* !defined(OS_MKFIFO_METHODDEF) */ + +#if (defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV)) + +PyDoc_STRVAR(os_mknod__doc__, +"mknod($module, /, path, mode=384, device=0, *, dir_fd=None)\n" +"--\n" +"\n" +"Create a node in the file system.\n" +"\n" +"Create a node in the file system (file, device special file or named pipe)\n" +"at path. mode specifies both the permissions to use and the\n" +"type of node to be created, being combined (bitwise OR) with one of\n" +"S_IFREG, S_IFCHR, S_IFBLK, and S_IFIFO. If S_IFCHR or S_IFBLK is set on mode,\n" +"device defines the newly created device special file (probably using\n" +"os.makedev()). Otherwise device is ignored.\n" +"\n" +"If dir_fd is not None, it should be a file descriptor open to a directory,\n" +" and path should be relative; path will then be relative to that directory.\n" +"dir_fd may not be implemented on your platform.\n" +" If it is unavailable, using it will raise a NotImplementedError."); + +#define OS_MKNOD_METHODDEF \ + {"mknod", (PyCFunction)os_mknod, METH_VARARGS|METH_KEYWORDS, os_mknod__doc__}, + +static PyObject * +os_mknod_impl(PyModuleDef *module, path_t *path, int mode, dev_t device, int dir_fd); + +static PyObject * +os_mknod(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "mode", "device", "dir_fd", NULL}; + path_t path = PATH_T_INITIALIZE("mknod", "path", 0, 0); + int mode = 384; + dev_t device = 0; + int dir_fd = DEFAULT_DIR_FD; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&|iO&$O&:mknod", _keywords, + path_converter, &path, &mode, _Py_Dev_Converter, &device, MKNODAT_DIR_FD_CONVERTER, &dir_fd)) + goto exit; + return_value = os_mknod_impl(module, &path, mode, device, dir_fd); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* (defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV)) */ + +#ifndef OS_MKNOD_METHODDEF + #define OS_MKNOD_METHODDEF +#endif /* !defined(OS_MKNOD_METHODDEF) */ + +#if defined(HAVE_DEVICE_MACROS) + +PyDoc_STRVAR(os_major__doc__, +"major($module, device, /)\n" +"--\n" +"\n" +"Extracts a device major number from a raw device number."); + +#define OS_MAJOR_METHODDEF \ + {"major", (PyCFunction)os_major, METH_VARARGS, os_major__doc__}, + +static unsigned int +os_major_impl(PyModuleDef *module, dev_t device); + +static PyObject * +os_major(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + dev_t device; + unsigned int _return_value; + + if (!PyArg_ParseTuple(args, + "O&:major", + _Py_Dev_Converter, &device)) + goto exit; + _return_value = os_major_impl(module, device); + if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromUnsignedLong((unsigned long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_DEVICE_MACROS) */ + +#ifndef OS_MAJOR_METHODDEF + #define OS_MAJOR_METHODDEF +#endif /* !defined(OS_MAJOR_METHODDEF) */ + +#if defined(HAVE_DEVICE_MACROS) + +PyDoc_STRVAR(os_minor__doc__, +"minor($module, device, /)\n" +"--\n" +"\n" +"Extracts a device minor number from a raw device number."); + +#define OS_MINOR_METHODDEF \ + {"minor", (PyCFunction)os_minor, METH_VARARGS, os_minor__doc__}, + +static unsigned int +os_minor_impl(PyModuleDef *module, dev_t device); + +static PyObject * +os_minor(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + dev_t device; + unsigned int _return_value; + + if (!PyArg_ParseTuple(args, + "O&:minor", + _Py_Dev_Converter, &device)) + goto exit; + _return_value = os_minor_impl(module, device); + if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromUnsignedLong((unsigned long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_DEVICE_MACROS) */ + +#ifndef OS_MINOR_METHODDEF + #define OS_MINOR_METHODDEF +#endif /* !defined(OS_MINOR_METHODDEF) */ + +#if defined(HAVE_DEVICE_MACROS) + +PyDoc_STRVAR(os_makedev__doc__, +"makedev($module, major, minor, /)\n" +"--\n" +"\n" +"Composes a raw device number from the major and minor device numbers."); + +#define OS_MAKEDEV_METHODDEF \ + {"makedev", (PyCFunction)os_makedev, METH_VARARGS, os_makedev__doc__}, + +static dev_t +os_makedev_impl(PyModuleDef *module, int major, int minor); + +static PyObject * +os_makedev(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int major; + int minor; + dev_t _return_value; + + if (!PyArg_ParseTuple(args, + "ii:makedev", + &major, &minor)) + goto exit; + _return_value = os_makedev_impl(module, major, minor); + if ((_return_value == (dev_t)-1) && PyErr_Occurred()) + goto exit; + return_value = _PyLong_FromDev(_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_DEVICE_MACROS) */ + +#ifndef OS_MAKEDEV_METHODDEF + #define OS_MAKEDEV_METHODDEF +#endif /* !defined(OS_MAKEDEV_METHODDEF) */ + +#if defined(HAVE_FTRUNCATE) + +PyDoc_STRVAR(os_ftruncate__doc__, +"ftruncate($module, fd, length, /)\n" +"--\n" +"\n" +"Truncate a file, specified by file descriptor, to a specific length."); + +#define OS_FTRUNCATE_METHODDEF \ + {"ftruncate", (PyCFunction)os_ftruncate, METH_VARARGS, os_ftruncate__doc__}, + +static PyObject * +os_ftruncate_impl(PyModuleDef *module, int fd, Py_off_t length); + +static PyObject * +os_ftruncate(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + Py_off_t length; + + if (!PyArg_ParseTuple(args, + "iO&:ftruncate", + &fd, Py_off_t_converter, &length)) + goto exit; + return_value = os_ftruncate_impl(module, fd, length); + +exit: + return return_value; +} + +#endif /* defined(HAVE_FTRUNCATE) */ + +#ifndef OS_FTRUNCATE_METHODDEF + #define OS_FTRUNCATE_METHODDEF +#endif /* !defined(OS_FTRUNCATE_METHODDEF) */ + +#if defined(HAVE_TRUNCATE) + +PyDoc_STRVAR(os_truncate__doc__, +"truncate($module, /, path, length)\n" +"--\n" +"\n" +"Truncate a file, specified by path, to a specific length.\n" +"\n" +"On some platforms, path may also be specified as an open file descriptor.\n" +" If this functionality is unavailable, using it raises an exception."); + +#define OS_TRUNCATE_METHODDEF \ + {"truncate", (PyCFunction)os_truncate, METH_VARARGS|METH_KEYWORDS, os_truncate__doc__}, + +static PyObject * +os_truncate_impl(PyModuleDef *module, path_t *path, Py_off_t length); + +static PyObject * +os_truncate(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "length", NULL}; + path_t path = PATH_T_INITIALIZE("truncate", "path", 0, PATH_HAVE_FTRUNCATE); + Py_off_t length; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&O&:truncate", _keywords, + path_converter, &path, Py_off_t_converter, &length)) + goto exit; + return_value = os_truncate_impl(module, &path, length); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(HAVE_TRUNCATE) */ + +#ifndef OS_TRUNCATE_METHODDEF + #define OS_TRUNCATE_METHODDEF +#endif /* !defined(OS_TRUNCATE_METHODDEF) */ + +#if (defined(HAVE_POSIX_FALLOCATE) && !defined(POSIX_FADVISE_AIX_BUG)) + +PyDoc_STRVAR(os_posix_fallocate__doc__, +"posix_fallocate($module, fd, offset, length, /)\n" +"--\n" +"\n" +"Ensure a file has allocated at least a particular number of bytes on disk.\n" +"\n" +"Ensure that the file specified by fd encompasses a range of bytes\n" +"starting at offset bytes from the beginning and continuing for length bytes."); + +#define OS_POSIX_FALLOCATE_METHODDEF \ + {"posix_fallocate", (PyCFunction)os_posix_fallocate, METH_VARARGS, os_posix_fallocate__doc__}, + +static PyObject * +os_posix_fallocate_impl(PyModuleDef *module, int fd, Py_off_t offset, Py_off_t length); + +static PyObject * +os_posix_fallocate(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + Py_off_t offset; + Py_off_t length; + + if (!PyArg_ParseTuple(args, + "iO&O&:posix_fallocate", + &fd, Py_off_t_converter, &offset, Py_off_t_converter, &length)) + goto exit; + return_value = os_posix_fallocate_impl(module, fd, offset, length); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_POSIX_FALLOCATE) && !defined(POSIX_FADVISE_AIX_BUG)) */ + +#ifndef OS_POSIX_FALLOCATE_METHODDEF + #define OS_POSIX_FALLOCATE_METHODDEF +#endif /* !defined(OS_POSIX_FALLOCATE_METHODDEF) */ + +#if (defined(HAVE_POSIX_FADVISE) && !defined(POSIX_FADVISE_AIX_BUG)) + +PyDoc_STRVAR(os_posix_fadvise__doc__, +"posix_fadvise($module, fd, offset, length, advice, /)\n" +"--\n" +"\n" +"Announce an intention to access data in a specific pattern.\n" +"\n" +"Announce an intention to access data in a specific pattern, thus allowing\n" +"the kernel to make optimizations.\n" +"The advice applies to the region of the file specified by fd starting at\n" +"offset and continuing for length bytes.\n" +"advice is one of POSIX_FADV_NORMAL, POSIX_FADV_SEQUENTIAL,\n" +"POSIX_FADV_RANDOM, POSIX_FADV_NOREUSE, POSIX_FADV_WILLNEED, or\n" +"POSIX_FADV_DONTNEED."); + +#define OS_POSIX_FADVISE_METHODDEF \ + {"posix_fadvise", (PyCFunction)os_posix_fadvise, METH_VARARGS, os_posix_fadvise__doc__}, + +static PyObject * +os_posix_fadvise_impl(PyModuleDef *module, int fd, Py_off_t offset, Py_off_t length, int advice); + +static PyObject * +os_posix_fadvise(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + Py_off_t offset; + Py_off_t length; + int advice; + + if (!PyArg_ParseTuple(args, + "iO&O&i:posix_fadvise", + &fd, Py_off_t_converter, &offset, Py_off_t_converter, &length, &advice)) + goto exit; + return_value = os_posix_fadvise_impl(module, fd, offset, length, advice); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_POSIX_FADVISE) && !defined(POSIX_FADVISE_AIX_BUG)) */ + +#ifndef OS_POSIX_FADVISE_METHODDEF + #define OS_POSIX_FADVISE_METHODDEF +#endif /* !defined(OS_POSIX_FADVISE_METHODDEF) */ + +#if defined(HAVE_PUTENV) && defined(MS_WINDOWS) + +PyDoc_STRVAR(os_putenv__doc__, +"putenv($module, name, value, /)\n" +"--\n" +"\n" +"Change or add an environment variable."); + +#define OS_PUTENV_METHODDEF \ + {"putenv", (PyCFunction)os_putenv, METH_VARARGS, os_putenv__doc__}, + +static PyObject * +os_putenv_impl(PyModuleDef *module, PyObject *name, PyObject *value); + +static PyObject * +os_putenv(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *name; + PyObject *value; + + if (!PyArg_ParseTuple(args, + "UU:putenv", + &name, &value)) + goto exit; + return_value = os_putenv_impl(module, name, value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_PUTENV) && defined(MS_WINDOWS) */ + +#ifndef OS_PUTENV_METHODDEF + #define OS_PUTENV_METHODDEF +#endif /* !defined(OS_PUTENV_METHODDEF) */ + +#if defined(HAVE_PUTENV) && !defined(MS_WINDOWS) + +PyDoc_STRVAR(os_putenv__doc__, +"putenv($module, name, value, /)\n" +"--\n" +"\n" +"Change or add an environment variable."); + +#define OS_PUTENV_METHODDEF \ + {"putenv", (PyCFunction)os_putenv, METH_VARARGS, os_putenv__doc__}, + +static PyObject * +os_putenv_impl(PyModuleDef *module, PyObject *name, PyObject *value); + +static PyObject * +os_putenv(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *name = NULL; + PyObject *value = NULL; + + if (!PyArg_ParseTuple(args, + "O&O&:putenv", + PyUnicode_FSConverter, &name, PyUnicode_FSConverter, &value)) + goto exit; + return_value = os_putenv_impl(module, name, value); + +exit: + /* Cleanup for name */ + Py_XDECREF(name); + /* Cleanup for value */ + Py_XDECREF(value); + + return return_value; +} + +#endif /* defined(HAVE_PUTENV) && !defined(MS_WINDOWS) */ + +#ifndef OS_PUTENV_METHODDEF + #define OS_PUTENV_METHODDEF +#endif /* !defined(OS_PUTENV_METHODDEF) */ + +#if defined(HAVE_UNSETENV) + +PyDoc_STRVAR(os_unsetenv__doc__, +"unsetenv($module, name, /)\n" +"--\n" +"\n" +"Delete an environment variable."); + +#define OS_UNSETENV_METHODDEF \ + {"unsetenv", (PyCFunction)os_unsetenv, METH_VARARGS, os_unsetenv__doc__}, + +static PyObject * +os_unsetenv_impl(PyModuleDef *module, PyObject *name); + +static PyObject * +os_unsetenv(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *name = NULL; + + if (!PyArg_ParseTuple(args, + "O&:unsetenv", + PyUnicode_FSConverter, &name)) + goto exit; + return_value = os_unsetenv_impl(module, name); + +exit: + /* Cleanup for name */ + Py_XDECREF(name); + + return return_value; +} + +#endif /* defined(HAVE_UNSETENV) */ + +#ifndef OS_UNSETENV_METHODDEF + #define OS_UNSETENV_METHODDEF +#endif /* !defined(OS_UNSETENV_METHODDEF) */ + +PyDoc_STRVAR(os_strerror__doc__, +"strerror($module, code, /)\n" +"--\n" +"\n" +"Translate an error code to a message string."); + +#define OS_STRERROR_METHODDEF \ + {"strerror", (PyCFunction)os_strerror, METH_VARARGS, os_strerror__doc__}, + +static PyObject * +os_strerror_impl(PyModuleDef *module, int code); + +static PyObject * +os_strerror(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int code; + + if (!PyArg_ParseTuple(args, + "i:strerror", + &code)) + goto exit; + return_value = os_strerror_impl(module, code); + +exit: + return return_value; +} + +#if defined(HAVE_SYS_WAIT_H) && defined(WCOREDUMP) + +PyDoc_STRVAR(os_WCOREDUMP__doc__, +"WCOREDUMP($module, status, /)\n" +"--\n" +"\n" +"Return True if the process returning status was dumped to a core file."); + +#define OS_WCOREDUMP_METHODDEF \ + {"WCOREDUMP", (PyCFunction)os_WCOREDUMP, METH_VARARGS, os_WCOREDUMP__doc__}, + +static int +os_WCOREDUMP_impl(PyModuleDef *module, int status); + +static PyObject * +os_WCOREDUMP(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int status; + int _return_value; + + if (!PyArg_ParseTuple(args, + "i:WCOREDUMP", + &status)) + goto exit; + _return_value = os_WCOREDUMP_impl(module, status); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SYS_WAIT_H) && defined(WCOREDUMP) */ + +#ifndef OS_WCOREDUMP_METHODDEF + #define OS_WCOREDUMP_METHODDEF +#endif /* !defined(OS_WCOREDUMP_METHODDEF) */ + +#if defined(HAVE_SYS_WAIT_H) && defined(WIFCONTINUED) + +PyDoc_STRVAR(os_WIFCONTINUED__doc__, +"WIFCONTINUED($module, /, status)\n" +"--\n" +"\n" +"Return True if a particular process was continued from a job control stop.\n" +"\n" +"Return True if the process returning status was continued from a\n" +"job control stop."); + +#define OS_WIFCONTINUED_METHODDEF \ + {"WIFCONTINUED", (PyCFunction)os_WIFCONTINUED, METH_VARARGS|METH_KEYWORDS, os_WIFCONTINUED__doc__}, + +static int +os_WIFCONTINUED_impl(PyModuleDef *module, int status); + +static PyObject * +os_WIFCONTINUED(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"status", NULL}; + int status; + int _return_value; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:WIFCONTINUED", _keywords, + &status)) + goto exit; + _return_value = os_WIFCONTINUED_impl(module, status); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFCONTINUED) */ + +#ifndef OS_WIFCONTINUED_METHODDEF + #define OS_WIFCONTINUED_METHODDEF +#endif /* !defined(OS_WIFCONTINUED_METHODDEF) */ + +#if defined(HAVE_SYS_WAIT_H) && defined(WIFSTOPPED) + +PyDoc_STRVAR(os_WIFSTOPPED__doc__, +"WIFSTOPPED($module, /, status)\n" +"--\n" +"\n" +"Return True if the process returning status was stopped."); + +#define OS_WIFSTOPPED_METHODDEF \ + {"WIFSTOPPED", (PyCFunction)os_WIFSTOPPED, METH_VARARGS|METH_KEYWORDS, os_WIFSTOPPED__doc__}, + +static int +os_WIFSTOPPED_impl(PyModuleDef *module, int status); + +static PyObject * +os_WIFSTOPPED(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"status", NULL}; + int status; + int _return_value; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:WIFSTOPPED", _keywords, + &status)) + goto exit; + _return_value = os_WIFSTOPPED_impl(module, status); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFSTOPPED) */ + +#ifndef OS_WIFSTOPPED_METHODDEF + #define OS_WIFSTOPPED_METHODDEF +#endif /* !defined(OS_WIFSTOPPED_METHODDEF) */ + +#if defined(HAVE_SYS_WAIT_H) && defined(WIFSIGNALED) + +PyDoc_STRVAR(os_WIFSIGNALED__doc__, +"WIFSIGNALED($module, /, status)\n" +"--\n" +"\n" +"Return True if the process returning status was terminated by a signal."); + +#define OS_WIFSIGNALED_METHODDEF \ + {"WIFSIGNALED", (PyCFunction)os_WIFSIGNALED, METH_VARARGS|METH_KEYWORDS, os_WIFSIGNALED__doc__}, + +static int +os_WIFSIGNALED_impl(PyModuleDef *module, int status); + +static PyObject * +os_WIFSIGNALED(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"status", NULL}; + int status; + int _return_value; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:WIFSIGNALED", _keywords, + &status)) + goto exit; + _return_value = os_WIFSIGNALED_impl(module, status); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFSIGNALED) */ + +#ifndef OS_WIFSIGNALED_METHODDEF + #define OS_WIFSIGNALED_METHODDEF +#endif /* !defined(OS_WIFSIGNALED_METHODDEF) */ + +#if defined(HAVE_SYS_WAIT_H) && defined(WIFEXITED) + +PyDoc_STRVAR(os_WIFEXITED__doc__, +"WIFEXITED($module, /, status)\n" +"--\n" +"\n" +"Return True if the process returning status exited via the exit() system call."); + +#define OS_WIFEXITED_METHODDEF \ + {"WIFEXITED", (PyCFunction)os_WIFEXITED, METH_VARARGS|METH_KEYWORDS, os_WIFEXITED__doc__}, + +static int +os_WIFEXITED_impl(PyModuleDef *module, int status); + +static PyObject * +os_WIFEXITED(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"status", NULL}; + int status; + int _return_value; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:WIFEXITED", _keywords, + &status)) + goto exit; + _return_value = os_WIFEXITED_impl(module, status); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFEXITED) */ + +#ifndef OS_WIFEXITED_METHODDEF + #define OS_WIFEXITED_METHODDEF +#endif /* !defined(OS_WIFEXITED_METHODDEF) */ + +#if defined(HAVE_SYS_WAIT_H) && defined(WEXITSTATUS) + +PyDoc_STRVAR(os_WEXITSTATUS__doc__, +"WEXITSTATUS($module, /, status)\n" +"--\n" +"\n" +"Return the process return code from status."); + +#define OS_WEXITSTATUS_METHODDEF \ + {"WEXITSTATUS", (PyCFunction)os_WEXITSTATUS, METH_VARARGS|METH_KEYWORDS, os_WEXITSTATUS__doc__}, + +static int +os_WEXITSTATUS_impl(PyModuleDef *module, int status); + +static PyObject * +os_WEXITSTATUS(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"status", NULL}; + int status; + int _return_value; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:WEXITSTATUS", _keywords, + &status)) + goto exit; + _return_value = os_WEXITSTATUS_impl(module, status); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SYS_WAIT_H) && defined(WEXITSTATUS) */ + +#ifndef OS_WEXITSTATUS_METHODDEF + #define OS_WEXITSTATUS_METHODDEF +#endif /* !defined(OS_WEXITSTATUS_METHODDEF) */ + +#if defined(HAVE_SYS_WAIT_H) && defined(WTERMSIG) + +PyDoc_STRVAR(os_WTERMSIG__doc__, +"WTERMSIG($module, /, status)\n" +"--\n" +"\n" +"Return the signal that terminated the process that provided the status value."); + +#define OS_WTERMSIG_METHODDEF \ + {"WTERMSIG", (PyCFunction)os_WTERMSIG, METH_VARARGS|METH_KEYWORDS, os_WTERMSIG__doc__}, + +static int +os_WTERMSIG_impl(PyModuleDef *module, int status); + +static PyObject * +os_WTERMSIG(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"status", NULL}; + int status; + int _return_value; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:WTERMSIG", _keywords, + &status)) + goto exit; + _return_value = os_WTERMSIG_impl(module, status); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SYS_WAIT_H) && defined(WTERMSIG) */ + +#ifndef OS_WTERMSIG_METHODDEF + #define OS_WTERMSIG_METHODDEF +#endif /* !defined(OS_WTERMSIG_METHODDEF) */ + +#if defined(HAVE_SYS_WAIT_H) && defined(WSTOPSIG) + +PyDoc_STRVAR(os_WSTOPSIG__doc__, +"WSTOPSIG($module, /, status)\n" +"--\n" +"\n" +"Return the signal that stopped the process that provided the status value."); + +#define OS_WSTOPSIG_METHODDEF \ + {"WSTOPSIG", (PyCFunction)os_WSTOPSIG, METH_VARARGS|METH_KEYWORDS, os_WSTOPSIG__doc__}, + +static int +os_WSTOPSIG_impl(PyModuleDef *module, int status); + +static PyObject * +os_WSTOPSIG(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"status", NULL}; + int status; + int _return_value; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:WSTOPSIG", _keywords, + &status)) + goto exit; + _return_value = os_WSTOPSIG_impl(module, status); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SYS_WAIT_H) && defined(WSTOPSIG) */ + +#ifndef OS_WSTOPSIG_METHODDEF + #define OS_WSTOPSIG_METHODDEF +#endif /* !defined(OS_WSTOPSIG_METHODDEF) */ + +#if (defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H)) + +PyDoc_STRVAR(os_fstatvfs__doc__, +"fstatvfs($module, fd, /)\n" +"--\n" +"\n" +"Perform an fstatvfs system call on the given fd.\n" +"\n" +"Equivalent to statvfs(fd)."); + +#define OS_FSTATVFS_METHODDEF \ + {"fstatvfs", (PyCFunction)os_fstatvfs, METH_VARARGS, os_fstatvfs__doc__}, + +static PyObject * +os_fstatvfs_impl(PyModuleDef *module, int fd); + +static PyObject * +os_fstatvfs(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + + if (!PyArg_ParseTuple(args, + "i:fstatvfs", + &fd)) + goto exit; + return_value = os_fstatvfs_impl(module, fd); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H)) */ + +#ifndef OS_FSTATVFS_METHODDEF + #define OS_FSTATVFS_METHODDEF +#endif /* !defined(OS_FSTATVFS_METHODDEF) */ + +#if (defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H)) + +PyDoc_STRVAR(os_statvfs__doc__, +"statvfs($module, /, path)\n" +"--\n" +"\n" +"Perform a statvfs system call on the given path.\n" +"\n" +"path may always be specified as a string.\n" +"On some platforms, path may also be specified as an open file descriptor.\n" +" If this functionality is unavailable, using it raises an exception."); + +#define OS_STATVFS_METHODDEF \ + {"statvfs", (PyCFunction)os_statvfs, METH_VARARGS|METH_KEYWORDS, os_statvfs__doc__}, + +static PyObject * +os_statvfs_impl(PyModuleDef *module, path_t *path); + +static PyObject * +os_statvfs(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", NULL}; + path_t path = PATH_T_INITIALIZE("statvfs", "path", 0, PATH_HAVE_FSTATVFS); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&:statvfs", _keywords, + path_converter, &path)) + goto exit; + return_value = os_statvfs_impl(module, &path); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* (defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H)) */ + +#ifndef OS_STATVFS_METHODDEF + #define OS_STATVFS_METHODDEF +#endif /* !defined(OS_STATVFS_METHODDEF) */ + +#if defined(MS_WINDOWS) + +PyDoc_STRVAR(os__getdiskusage__doc__, +"_getdiskusage($module, /, path)\n" +"--\n" +"\n" +"Return disk usage statistics about the given path as a (total, free) tuple."); + +#define OS__GETDISKUSAGE_METHODDEF \ + {"_getdiskusage", (PyCFunction)os__getdiskusage, METH_VARARGS|METH_KEYWORDS, os__getdiskusage__doc__}, + +static PyObject * +os__getdiskusage_impl(PyModuleDef *module, Py_UNICODE *path); + +static PyObject * +os__getdiskusage(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", NULL}; + Py_UNICODE *path; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "u:_getdiskusage", _keywords, + &path)) + goto exit; + return_value = os__getdiskusage_impl(module, path); + +exit: + return return_value; +} + +#endif /* defined(MS_WINDOWS) */ + +#ifndef OS__GETDISKUSAGE_METHODDEF + #define OS__GETDISKUSAGE_METHODDEF +#endif /* !defined(OS__GETDISKUSAGE_METHODDEF) */ + +#if defined(HAVE_FPATHCONF) + +PyDoc_STRVAR(os_fpathconf__doc__, +"fpathconf($module, fd, name, /)\n" +"--\n" +"\n" +"Return the configuration limit name for the file descriptor fd.\n" +"\n" +"If there is no limit, return -1."); + +#define OS_FPATHCONF_METHODDEF \ + {"fpathconf", (PyCFunction)os_fpathconf, METH_VARARGS, os_fpathconf__doc__}, + +static long +os_fpathconf_impl(PyModuleDef *module, int fd, int name); + +static PyObject * +os_fpathconf(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + int name; + long _return_value; + + if (!PyArg_ParseTuple(args, + "iO&:fpathconf", + &fd, conv_path_confname, &name)) + goto exit; + _return_value = os_fpathconf_impl(module, fd, name); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong(_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_FPATHCONF) */ + +#ifndef OS_FPATHCONF_METHODDEF + #define OS_FPATHCONF_METHODDEF +#endif /* !defined(OS_FPATHCONF_METHODDEF) */ + +#if defined(HAVE_PATHCONF) + +PyDoc_STRVAR(os_pathconf__doc__, +"pathconf($module, /, path, name)\n" +"--\n" +"\n" +"Return the configuration limit name for the file or directory path.\n" +"\n" +"If there is no limit, return -1.\n" +"On some platforms, path may also be specified as an open file descriptor.\n" +" If this functionality is unavailable, using it raises an exception."); + +#define OS_PATHCONF_METHODDEF \ + {"pathconf", (PyCFunction)os_pathconf, METH_VARARGS|METH_KEYWORDS, os_pathconf__doc__}, + +static long +os_pathconf_impl(PyModuleDef *module, path_t *path, int name); + +static PyObject * +os_pathconf(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "name", NULL}; + path_t path = PATH_T_INITIALIZE("pathconf", "path", 0, PATH_HAVE_FPATHCONF); + int name; + long _return_value; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&O&:pathconf", _keywords, + path_converter, &path, conv_path_confname, &name)) + goto exit; + _return_value = os_pathconf_impl(module, &path, name); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong(_return_value); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(HAVE_PATHCONF) */ + +#ifndef OS_PATHCONF_METHODDEF + #define OS_PATHCONF_METHODDEF +#endif /* !defined(OS_PATHCONF_METHODDEF) */ + +#if defined(HAVE_CONFSTR) + +PyDoc_STRVAR(os_confstr__doc__, +"confstr($module, name, /)\n" +"--\n" +"\n" +"Return a string-valued system configuration variable."); + +#define OS_CONFSTR_METHODDEF \ + {"confstr", (PyCFunction)os_confstr, METH_VARARGS, os_confstr__doc__}, + +static PyObject * +os_confstr_impl(PyModuleDef *module, int name); + +static PyObject * +os_confstr(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int name; + + if (!PyArg_ParseTuple(args, + "O&:confstr", + conv_confstr_confname, &name)) + goto exit; + return_value = os_confstr_impl(module, name); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CONFSTR) */ + +#ifndef OS_CONFSTR_METHODDEF + #define OS_CONFSTR_METHODDEF +#endif /* !defined(OS_CONFSTR_METHODDEF) */ + +#if defined(HAVE_SYSCONF) + +PyDoc_STRVAR(os_sysconf__doc__, +"sysconf($module, name, /)\n" +"--\n" +"\n" +"Return an integer-valued system configuration variable."); + +#define OS_SYSCONF_METHODDEF \ + {"sysconf", (PyCFunction)os_sysconf, METH_VARARGS, os_sysconf__doc__}, + +static long +os_sysconf_impl(PyModuleDef *module, int name); + +static PyObject * +os_sysconf(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int name; + long _return_value; + + if (!PyArg_ParseTuple(args, + "O&:sysconf", + conv_sysconf_confname, &name)) + goto exit; + _return_value = os_sysconf_impl(module, name); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong(_return_value); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SYSCONF) */ + +#ifndef OS_SYSCONF_METHODDEF + #define OS_SYSCONF_METHODDEF +#endif /* !defined(OS_SYSCONF_METHODDEF) */ + +PyDoc_STRVAR(os_abort__doc__, +"abort($module, /)\n" +"--\n" +"\n" +"Abort the interpreter immediately.\n" +"\n" +"This function \'dumps core\' or otherwise fails in the hardest way possible\n" +"on the hosting operating system. This function never returns."); + +#define OS_ABORT_METHODDEF \ + {"abort", (PyCFunction)os_abort, METH_NOARGS, os_abort__doc__}, + +static PyObject * +os_abort_impl(PyModuleDef *module); + +static PyObject * +os_abort(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_abort_impl(module); +} + +#if defined(HAVE_GETLOADAVG) + +PyDoc_STRVAR(os_getloadavg__doc__, +"getloadavg($module, /)\n" +"--\n" +"\n" +"Return average recent system load information.\n" +"\n" +"Return the number of processes in the system run queue averaged over\n" +"the last 1, 5, and 15 minutes as a tuple of three floats.\n" +"Raises OSError if the load average was unobtainable."); + +#define OS_GETLOADAVG_METHODDEF \ + {"getloadavg", (PyCFunction)os_getloadavg, METH_NOARGS, os_getloadavg__doc__}, + +static PyObject * +os_getloadavg_impl(PyModuleDef *module); + +static PyObject * +os_getloadavg(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getloadavg_impl(module); +} + +#endif /* defined(HAVE_GETLOADAVG) */ + +#ifndef OS_GETLOADAVG_METHODDEF + #define OS_GETLOADAVG_METHODDEF +#endif /* !defined(OS_GETLOADAVG_METHODDEF) */ + +PyDoc_STRVAR(os_device_encoding__doc__, +"device_encoding($module, /, fd)\n" +"--\n" +"\n" +"Return a string describing the encoding of a terminal\'s file descriptor.\n" +"\n" +"The file descriptor must be attached to a terminal.\n" +"If the device is not a terminal, return None."); + +#define OS_DEVICE_ENCODING_METHODDEF \ + {"device_encoding", (PyCFunction)os_device_encoding, METH_VARARGS|METH_KEYWORDS, os_device_encoding__doc__}, + +static PyObject * +os_device_encoding_impl(PyModuleDef *module, int fd); + +static PyObject * +os_device_encoding(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"fd", NULL}; + int fd; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:device_encoding", _keywords, + &fd)) + goto exit; + return_value = os_device_encoding_impl(module, fd); + +exit: + return return_value; +} + +#if defined(HAVE_SETRESUID) + +PyDoc_STRVAR(os_setresuid__doc__, +"setresuid($module, ruid, euid, suid, /)\n" +"--\n" +"\n" +"Set the current process\'s real, effective, and saved user ids."); + +#define OS_SETRESUID_METHODDEF \ + {"setresuid", (PyCFunction)os_setresuid, METH_VARARGS, os_setresuid__doc__}, + +static PyObject * +os_setresuid_impl(PyModuleDef *module, uid_t ruid, uid_t euid, uid_t suid); + +static PyObject * +os_setresuid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + uid_t ruid; + uid_t euid; + uid_t suid; + + if (!PyArg_ParseTuple(args, + "O&O&O&:setresuid", + _Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid, _Py_Uid_Converter, &suid)) + goto exit; + return_value = os_setresuid_impl(module, ruid, euid, suid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SETRESUID) */ + +#ifndef OS_SETRESUID_METHODDEF + #define OS_SETRESUID_METHODDEF +#endif /* !defined(OS_SETRESUID_METHODDEF) */ + +#if defined(HAVE_SETRESGID) + +PyDoc_STRVAR(os_setresgid__doc__, +"setresgid($module, rgid, egid, sgid, /)\n" +"--\n" +"\n" +"Set the current process\'s real, effective, and saved group ids."); + +#define OS_SETRESGID_METHODDEF \ + {"setresgid", (PyCFunction)os_setresgid, METH_VARARGS, os_setresgid__doc__}, + +static PyObject * +os_setresgid_impl(PyModuleDef *module, gid_t rgid, gid_t egid, gid_t sgid); + +static PyObject * +os_setresgid(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + gid_t rgid; + gid_t egid; + gid_t sgid; + + if (!PyArg_ParseTuple(args, + "O&O&O&:setresgid", + _Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid, _Py_Gid_Converter, &sgid)) + goto exit; + return_value = os_setresgid_impl(module, rgid, egid, sgid); + +exit: + return return_value; +} + +#endif /* defined(HAVE_SETRESGID) */ + +#ifndef OS_SETRESGID_METHODDEF + #define OS_SETRESGID_METHODDEF +#endif /* !defined(OS_SETRESGID_METHODDEF) */ + +#if defined(HAVE_GETRESUID) + +PyDoc_STRVAR(os_getresuid__doc__, +"getresuid($module, /)\n" +"--\n" +"\n" +"Return a tuple of the current process\'s real, effective, and saved user ids."); + +#define OS_GETRESUID_METHODDEF \ + {"getresuid", (PyCFunction)os_getresuid, METH_NOARGS, os_getresuid__doc__}, + +static PyObject * +os_getresuid_impl(PyModuleDef *module); + +static PyObject * +os_getresuid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getresuid_impl(module); +} + +#endif /* defined(HAVE_GETRESUID) */ + +#ifndef OS_GETRESUID_METHODDEF + #define OS_GETRESUID_METHODDEF +#endif /* !defined(OS_GETRESUID_METHODDEF) */ + +#if defined(HAVE_GETRESGID) + +PyDoc_STRVAR(os_getresgid__doc__, +"getresgid($module, /)\n" +"--\n" +"\n" +"Return a tuple of the current process\'s real, effective, and saved group ids."); + +#define OS_GETRESGID_METHODDEF \ + {"getresgid", (PyCFunction)os_getresgid, METH_NOARGS, os_getresgid__doc__}, + +static PyObject * +os_getresgid_impl(PyModuleDef *module); + +static PyObject * +os_getresgid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_getresgid_impl(module); +} + +#endif /* defined(HAVE_GETRESGID) */ + +#ifndef OS_GETRESGID_METHODDEF + #define OS_GETRESGID_METHODDEF +#endif /* !defined(OS_GETRESGID_METHODDEF) */ + +#if defined(USE_XATTRS) + +PyDoc_STRVAR(os_getxattr__doc__, +"getxattr($module, /, path, attribute, *, follow_symlinks=True)\n" +"--\n" +"\n" +"Return the value of extended attribute attribute on path.\n" +"\n" +"path may be either a string or an open file descriptor.\n" +"If follow_symlinks is False, and the last element of the path is a symbolic\n" +" link, getxattr will examine the symbolic link itself instead of the file\n" +" the link points to."); + +#define OS_GETXATTR_METHODDEF \ + {"getxattr", (PyCFunction)os_getxattr, METH_VARARGS|METH_KEYWORDS, os_getxattr__doc__}, + +static PyObject * +os_getxattr_impl(PyModuleDef *module, path_t *path, path_t *attribute, int follow_symlinks); + +static PyObject * +os_getxattr(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "attribute", "follow_symlinks", NULL}; + path_t path = PATH_T_INITIALIZE("getxattr", "path", 0, 1); + path_t attribute = PATH_T_INITIALIZE("getxattr", "attribute", 0, 0); + int follow_symlinks = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&O&|$p:getxattr", _keywords, + path_converter, &path, path_converter, &attribute, &follow_symlinks)) + goto exit; + return_value = os_getxattr_impl(module, &path, &attribute, follow_symlinks); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + /* Cleanup for attribute */ + path_cleanup(&attribute); + + return return_value; +} + +#endif /* defined(USE_XATTRS) */ + +#ifndef OS_GETXATTR_METHODDEF + #define OS_GETXATTR_METHODDEF +#endif /* !defined(OS_GETXATTR_METHODDEF) */ + +#if defined(USE_XATTRS) + +PyDoc_STRVAR(os_setxattr__doc__, +"setxattr($module, /, path, attribute, value, flags=0, *,\n" +" follow_symlinks=True)\n" +"--\n" +"\n" +"Set extended attribute attribute on path to value.\n" +"\n" +"path may be either a string or an open file descriptor.\n" +"If follow_symlinks is False, and the last element of the path is a symbolic\n" +" link, setxattr will modify the symbolic link itself instead of the file\n" +" the link points to."); + +#define OS_SETXATTR_METHODDEF \ + {"setxattr", (PyCFunction)os_setxattr, METH_VARARGS|METH_KEYWORDS, os_setxattr__doc__}, + +static PyObject * +os_setxattr_impl(PyModuleDef *module, path_t *path, path_t *attribute, Py_buffer *value, int flags, int follow_symlinks); + +static PyObject * +os_setxattr(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "attribute", "value", "flags", "follow_symlinks", NULL}; + path_t path = PATH_T_INITIALIZE("setxattr", "path", 0, 1); + path_t attribute = PATH_T_INITIALIZE("setxattr", "attribute", 0, 0); + Py_buffer value = {NULL, NULL}; + int flags = 0; + int follow_symlinks = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&O&y*|i$p:setxattr", _keywords, + path_converter, &path, path_converter, &attribute, &value, &flags, &follow_symlinks)) + goto exit; + return_value = os_setxattr_impl(module, &path, &attribute, &value, flags, follow_symlinks); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + /* Cleanup for attribute */ + path_cleanup(&attribute); + /* Cleanup for value */ + if (value.obj) + PyBuffer_Release(&value); + + return return_value; +} + +#endif /* defined(USE_XATTRS) */ + +#ifndef OS_SETXATTR_METHODDEF + #define OS_SETXATTR_METHODDEF +#endif /* !defined(OS_SETXATTR_METHODDEF) */ + +#if defined(USE_XATTRS) + +PyDoc_STRVAR(os_removexattr__doc__, +"removexattr($module, /, path, attribute, *, follow_symlinks=True)\n" +"--\n" +"\n" +"Remove extended attribute attribute on path.\n" +"\n" +"path may be either a string or an open file descriptor.\n" +"If follow_symlinks is False, and the last element of the path is a symbolic\n" +" link, removexattr will modify the symbolic link itself instead of the file\n" +" the link points to."); + +#define OS_REMOVEXATTR_METHODDEF \ + {"removexattr", (PyCFunction)os_removexattr, METH_VARARGS|METH_KEYWORDS, os_removexattr__doc__}, + +static PyObject * +os_removexattr_impl(PyModuleDef *module, path_t *path, path_t *attribute, int follow_symlinks); + +static PyObject * +os_removexattr(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "attribute", "follow_symlinks", NULL}; + path_t path = PATH_T_INITIALIZE("removexattr", "path", 0, 1); + path_t attribute = PATH_T_INITIALIZE("removexattr", "attribute", 0, 0); + int follow_symlinks = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O&O&|$p:removexattr", _keywords, + path_converter, &path, path_converter, &attribute, &follow_symlinks)) + goto exit; + return_value = os_removexattr_impl(module, &path, &attribute, follow_symlinks); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + /* Cleanup for attribute */ + path_cleanup(&attribute); + + return return_value; +} + +#endif /* defined(USE_XATTRS) */ + +#ifndef OS_REMOVEXATTR_METHODDEF + #define OS_REMOVEXATTR_METHODDEF +#endif /* !defined(OS_REMOVEXATTR_METHODDEF) */ + +#if defined(USE_XATTRS) + +PyDoc_STRVAR(os_listxattr__doc__, +"listxattr($module, /, path=None, *, follow_symlinks=True)\n" +"--\n" +"\n" +"Return a list of extended attributes on path.\n" +"\n" +"path may be either None, a string, or an open file descriptor.\n" +"if path is None, listxattr will examine the current directory.\n" +"If follow_symlinks is False, and the last element of the path is a symbolic\n" +" link, listxattr will examine the symbolic link itself instead of the file\n" +" the link points to."); + +#define OS_LISTXATTR_METHODDEF \ + {"listxattr", (PyCFunction)os_listxattr, METH_VARARGS|METH_KEYWORDS, os_listxattr__doc__}, + +static PyObject * +os_listxattr_impl(PyModuleDef *module, path_t *path, int follow_symlinks); + +static PyObject * +os_listxattr(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"path", "follow_symlinks", NULL}; + path_t path = PATH_T_INITIALIZE("listxattr", "path", 1, 1); + int follow_symlinks = 1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|O&$p:listxattr", _keywords, + path_converter, &path, &follow_symlinks)) + goto exit; + return_value = os_listxattr_impl(module, &path, follow_symlinks); + +exit: + /* Cleanup for path */ + path_cleanup(&path); + + return return_value; +} + +#endif /* defined(USE_XATTRS) */ + +#ifndef OS_LISTXATTR_METHODDEF + #define OS_LISTXATTR_METHODDEF +#endif /* !defined(OS_LISTXATTR_METHODDEF) */ + +PyDoc_STRVAR(os_urandom__doc__, +"urandom($module, size, /)\n" +"--\n" +"\n" +"Return a bytes object containing random bytes suitable for cryptographic use."); + +#define OS_URANDOM_METHODDEF \ + {"urandom", (PyCFunction)os_urandom, METH_VARARGS, os_urandom__doc__}, + +static PyObject * +os_urandom_impl(PyModuleDef *module, Py_ssize_t size); + +static PyObject * +os_urandom(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + Py_ssize_t size; + + if (!PyArg_ParseTuple(args, + "n:urandom", + &size)) + goto exit; + return_value = os_urandom_impl(module, size); + +exit: + return return_value; +} + +PyDoc_STRVAR(os_cpu_count__doc__, +"cpu_count($module, /)\n" +"--\n" +"\n" +"Return the number of CPUs in the system; return None if indeterminable."); + +#define OS_CPU_COUNT_METHODDEF \ + {"cpu_count", (PyCFunction)os_cpu_count, METH_NOARGS, os_cpu_count__doc__}, + +static PyObject * +os_cpu_count_impl(PyModuleDef *module); + +static PyObject * +os_cpu_count(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return os_cpu_count_impl(module); +} + +PyDoc_STRVAR(os_get_inheritable__doc__, +"get_inheritable($module, fd, /)\n" +"--\n" +"\n" +"Get the close-on-exe flag of the specified file descriptor."); + +#define OS_GET_INHERITABLE_METHODDEF \ + {"get_inheritable", (PyCFunction)os_get_inheritable, METH_VARARGS, os_get_inheritable__doc__}, + +static int +os_get_inheritable_impl(PyModuleDef *module, int fd); + +static PyObject * +os_get_inheritable(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + int _return_value; + + if (!PyArg_ParseTuple(args, + "i:get_inheritable", + &fd)) + goto exit; + _return_value = os_get_inheritable_impl(module, fd); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(os_set_inheritable__doc__, +"set_inheritable($module, fd, inheritable, /)\n" +"--\n" +"\n" +"Set the inheritable flag of the specified file descriptor."); + +#define OS_SET_INHERITABLE_METHODDEF \ + {"set_inheritable", (PyCFunction)os_set_inheritable, METH_VARARGS, os_set_inheritable__doc__}, + +static PyObject * +os_set_inheritable_impl(PyModuleDef *module, int fd, int inheritable); + +static PyObject * +os_set_inheritable(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int fd; + int inheritable; + + if (!PyArg_ParseTuple(args, + "ii:set_inheritable", + &fd, &inheritable)) + goto exit; + return_value = os_set_inheritable_impl(module, fd, inheritable); + +exit: + return return_value; +} + +#if defined(MS_WINDOWS) + +PyDoc_STRVAR(os_get_handle_inheritable__doc__, +"get_handle_inheritable($module, handle, /)\n" +"--\n" +"\n" +"Get the close-on-exe flag of the specified file descriptor."); + +#define OS_GET_HANDLE_INHERITABLE_METHODDEF \ + {"get_handle_inheritable", (PyCFunction)os_get_handle_inheritable, METH_VARARGS, os_get_handle_inheritable__doc__}, + +static int +os_get_handle_inheritable_impl(PyModuleDef *module, Py_intptr_t handle); + +static PyObject * +os_get_handle_inheritable(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + Py_intptr_t handle; + int _return_value; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_INTPTR ":get_handle_inheritable", + &handle)) + goto exit; + _return_value = os_get_handle_inheritable_impl(module, handle); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyBool_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* defined(MS_WINDOWS) */ + +#ifndef OS_GET_HANDLE_INHERITABLE_METHODDEF + #define OS_GET_HANDLE_INHERITABLE_METHODDEF +#endif /* !defined(OS_GET_HANDLE_INHERITABLE_METHODDEF) */ + +#if defined(MS_WINDOWS) + +PyDoc_STRVAR(os_set_handle_inheritable__doc__, +"set_handle_inheritable($module, handle, inheritable, /)\n" +"--\n" +"\n" +"Set the inheritable flag of the specified handle."); + +#define OS_SET_HANDLE_INHERITABLE_METHODDEF \ + {"set_handle_inheritable", (PyCFunction)os_set_handle_inheritable, METH_VARARGS, os_set_handle_inheritable__doc__}, + +static PyObject * +os_set_handle_inheritable_impl(PyModuleDef *module, Py_intptr_t handle, int inheritable); + +static PyObject * +os_set_handle_inheritable(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + Py_intptr_t handle; + int inheritable; + + if (!PyArg_ParseTuple(args, + "" _Py_PARSE_INTPTR "p:set_handle_inheritable", + &handle, &inheritable)) + goto exit; + return_value = os_set_handle_inheritable_impl(module, handle, inheritable); + +exit: + return return_value; +} + +#endif /* defined(MS_WINDOWS) */ + +#ifndef OS_SET_HANDLE_INHERITABLE_METHODDEF + #define OS_SET_HANDLE_INHERITABLE_METHODDEF +#endif /* !defined(OS_SET_HANDLE_INHERITABLE_METHODDEF) */ +/*[clinic end generated code: output=7c87ead6c6381918 input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/pyexpat.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/pyexpat.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,289 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(pyexpat_xmlparser_Parse__doc__, +"Parse($self, data, isFinal=0, /)\n" +"--\n" +"\n" +"Parse XML data.\n" +"\n" +"`isfinal\' should be true at end of input."); + +#define PYEXPAT_XMLPARSER_PARSE_METHODDEF \ + {"Parse", (PyCFunction)pyexpat_xmlparser_Parse, METH_VARARGS, pyexpat_xmlparser_Parse__doc__}, + +static PyObject * +pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyObject *data, int isFinal); + +static PyObject * +pyexpat_xmlparser_Parse(xmlparseobject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *data; + int isFinal = 0; + + if (!PyArg_ParseTuple(args, + "O|i:Parse", + &data, &isFinal)) + goto exit; + return_value = pyexpat_xmlparser_Parse_impl(self, data, isFinal); + +exit: + return return_value; +} + +PyDoc_STRVAR(pyexpat_xmlparser_ParseFile__doc__, +"ParseFile($self, file, /)\n" +"--\n" +"\n" +"Parse XML data from file-like object."); + +#define PYEXPAT_XMLPARSER_PARSEFILE_METHODDEF \ + {"ParseFile", (PyCFunction)pyexpat_xmlparser_ParseFile, METH_O, pyexpat_xmlparser_ParseFile__doc__}, + +PyDoc_STRVAR(pyexpat_xmlparser_SetBase__doc__, +"SetBase($self, base, /)\n" +"--\n" +"\n" +"Set the base URL for the parser."); + +#define PYEXPAT_XMLPARSER_SETBASE_METHODDEF \ + {"SetBase", (PyCFunction)pyexpat_xmlparser_SetBase, METH_VARARGS, pyexpat_xmlparser_SetBase__doc__}, + +static PyObject * +pyexpat_xmlparser_SetBase_impl(xmlparseobject *self, const char *base); + +static PyObject * +pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *args) +{ + PyObject *return_value = NULL; + const char *base; + + if (!PyArg_ParseTuple(args, + "s:SetBase", + &base)) + goto exit; + return_value = pyexpat_xmlparser_SetBase_impl(self, base); + +exit: + return return_value; +} + +PyDoc_STRVAR(pyexpat_xmlparser_GetBase__doc__, +"GetBase($self, /)\n" +"--\n" +"\n" +"Return base URL string for the parser."); + +#define PYEXPAT_XMLPARSER_GETBASE_METHODDEF \ + {"GetBase", (PyCFunction)pyexpat_xmlparser_GetBase, METH_NOARGS, pyexpat_xmlparser_GetBase__doc__}, + +static PyObject * +pyexpat_xmlparser_GetBase_impl(xmlparseobject *self); + +static PyObject * +pyexpat_xmlparser_GetBase(xmlparseobject *self, PyObject *Py_UNUSED(ignored)) +{ + return pyexpat_xmlparser_GetBase_impl(self); +} + +PyDoc_STRVAR(pyexpat_xmlparser_GetInputContext__doc__, +"GetInputContext($self, /)\n" +"--\n" +"\n" +"Return the untranslated text of the input that caused the current event.\n" +"\n" +"If the event was generated by a large amount of text (such as a start tag\n" +"for an element with many attributes), not all of the text may be available."); + +#define PYEXPAT_XMLPARSER_GETINPUTCONTEXT_METHODDEF \ + {"GetInputContext", (PyCFunction)pyexpat_xmlparser_GetInputContext, METH_NOARGS, pyexpat_xmlparser_GetInputContext__doc__}, + +static PyObject * +pyexpat_xmlparser_GetInputContext_impl(xmlparseobject *self); + +static PyObject * +pyexpat_xmlparser_GetInputContext(xmlparseobject *self, PyObject *Py_UNUSED(ignored)) +{ + return pyexpat_xmlparser_GetInputContext_impl(self); +} + +PyDoc_STRVAR(pyexpat_xmlparser_ExternalEntityParserCreate__doc__, +"ExternalEntityParserCreate($self, context, encoding=None, /)\n" +"--\n" +"\n" +"Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler."); + +#define PYEXPAT_XMLPARSER_EXTERNALENTITYPARSERCREATE_METHODDEF \ + {"ExternalEntityParserCreate", (PyCFunction)pyexpat_xmlparser_ExternalEntityParserCreate, METH_VARARGS, pyexpat_xmlparser_ExternalEntityParserCreate__doc__}, + +static PyObject * +pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self, const char *context, const char *encoding); + +static PyObject * +pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args) +{ + PyObject *return_value = NULL; + const char *context; + const char *encoding = NULL; + + if (!PyArg_ParseTuple(args, + "z|s:ExternalEntityParserCreate", + &context, &encoding)) + goto exit; + return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, context, encoding); + +exit: + return return_value; +} + +PyDoc_STRVAR(pyexpat_xmlparser_SetParamEntityParsing__doc__, +"SetParamEntityParsing($self, flag, /)\n" +"--\n" +"\n" +"Controls parsing of parameter entities (including the external DTD subset).\n" +"\n" +"Possible flag values are XML_PARAM_ENTITY_PARSING_NEVER,\n" +"XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE and\n" +"XML_PARAM_ENTITY_PARSING_ALWAYS. Returns true if setting the flag\n" +"was successful."); + +#define PYEXPAT_XMLPARSER_SETPARAMENTITYPARSING_METHODDEF \ + {"SetParamEntityParsing", (PyCFunction)pyexpat_xmlparser_SetParamEntityParsing, METH_VARARGS, pyexpat_xmlparser_SetParamEntityParsing__doc__}, + +static PyObject * +pyexpat_xmlparser_SetParamEntityParsing_impl(xmlparseobject *self, int flag); + +static PyObject * +pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int flag; + + if (!PyArg_ParseTuple(args, + "i:SetParamEntityParsing", + &flag)) + goto exit; + return_value = pyexpat_xmlparser_SetParamEntityParsing_impl(self, flag); + +exit: + return return_value; +} + +#if (XML_COMBINED_VERSION >= 19505) + +PyDoc_STRVAR(pyexpat_xmlparser_UseForeignDTD__doc__, +"UseForeignDTD($self, flag=True, /)\n" +"--\n" +"\n" +"Allows the application to provide an artificial external subset if one is not specified as part of the document instance.\n" +"\n" +"This readily allows the use of a \'default\' document type controlled by the\n" +"application, while still getting the advantage of providing document type\n" +"information to the parser. \'flag\' defaults to True if not provided."); + +#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF \ + {"UseForeignDTD", (PyCFunction)pyexpat_xmlparser_UseForeignDTD, METH_VARARGS, pyexpat_xmlparser_UseForeignDTD__doc__}, + +static PyObject * +pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, int flag); + +static PyObject * +pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int flag = 1; + + if (!PyArg_ParseTuple(args, + "|p:UseForeignDTD", + &flag)) + goto exit; + return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, flag); + +exit: + return return_value; +} + +#endif /* (XML_COMBINED_VERSION >= 19505) */ + +#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF + #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF +#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */ + +PyDoc_STRVAR(pyexpat_xmlparser___dir____doc__, +"__dir__($self, /)\n" +"--"); + +#define PYEXPAT_XMLPARSER___DIR___METHODDEF \ + {"__dir__", (PyCFunction)pyexpat_xmlparser___dir__, METH_NOARGS, pyexpat_xmlparser___dir____doc__}, + +static PyObject * +pyexpat_xmlparser___dir___impl(xmlparseobject *self); + +static PyObject * +pyexpat_xmlparser___dir__(xmlparseobject *self, PyObject *Py_UNUSED(ignored)) +{ + return pyexpat_xmlparser___dir___impl(self); +} + +PyDoc_STRVAR(pyexpat_ParserCreate__doc__, +"ParserCreate($module, /, encoding=None, namespace_separator=None,\n" +" intern=None)\n" +"--\n" +"\n" +"Return a new XML parser object."); + +#define PYEXPAT_PARSERCREATE_METHODDEF \ + {"ParserCreate", (PyCFunction)pyexpat_ParserCreate, METH_VARARGS|METH_KEYWORDS, pyexpat_ParserCreate__doc__}, + +static PyObject * +pyexpat_ParserCreate_impl(PyModuleDef *module, const char *encoding, const char *namespace_separator, PyObject *intern); + +static PyObject * +pyexpat_ParserCreate(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"encoding", "namespace_separator", "intern", NULL}; + const char *encoding = NULL; + const char *namespace_separator = NULL; + PyObject *intern = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|zzO:ParserCreate", _keywords, + &encoding, &namespace_separator, &intern)) + goto exit; + return_value = pyexpat_ParserCreate_impl(module, encoding, namespace_separator, intern); + +exit: + return return_value; +} + +PyDoc_STRVAR(pyexpat_ErrorString__doc__, +"ErrorString($module, code, /)\n" +"--\n" +"\n" +"Returns string error for given number."); + +#define PYEXPAT_ERRORSTRING_METHODDEF \ + {"ErrorString", (PyCFunction)pyexpat_ErrorString, METH_VARARGS, pyexpat_ErrorString__doc__}, + +static PyObject * +pyexpat_ErrorString_impl(PyModuleDef *module, long code); + +static PyObject * +pyexpat_ErrorString(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + long code; + + if (!PyArg_ParseTuple(args, + "l:ErrorString", + &code)) + goto exit; + return_value = pyexpat_ErrorString_impl(module, code); + +exit: + return return_value; +} +/*[clinic end generated code: output=0d50bd6199ed47e4 input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/sha1module.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/sha1module.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,96 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(SHA1Type_copy__doc__, +"copy($self, /)\n" +"--\n" +"\n" +"Return a copy of the hash object."); + +#define SHA1TYPE_COPY_METHODDEF \ + {"copy", (PyCFunction)SHA1Type_copy, METH_NOARGS, SHA1Type_copy__doc__}, + +static PyObject * +SHA1Type_copy_impl(SHA1object *self); + +static PyObject * +SHA1Type_copy(SHA1object *self, PyObject *Py_UNUSED(ignored)) +{ + return SHA1Type_copy_impl(self); +} + +PyDoc_STRVAR(SHA1Type_digest__doc__, +"digest($self, /)\n" +"--\n" +"\n" +"Return the digest value as a string of binary data."); + +#define SHA1TYPE_DIGEST_METHODDEF \ + {"digest", (PyCFunction)SHA1Type_digest, METH_NOARGS, SHA1Type_digest__doc__}, + +static PyObject * +SHA1Type_digest_impl(SHA1object *self); + +static PyObject * +SHA1Type_digest(SHA1object *self, PyObject *Py_UNUSED(ignored)) +{ + return SHA1Type_digest_impl(self); +} + +PyDoc_STRVAR(SHA1Type_hexdigest__doc__, +"hexdigest($self, /)\n" +"--\n" +"\n" +"Return the digest value as a string of hexadecimal digits."); + +#define SHA1TYPE_HEXDIGEST_METHODDEF \ + {"hexdigest", (PyCFunction)SHA1Type_hexdigest, METH_NOARGS, SHA1Type_hexdigest__doc__}, + +static PyObject * +SHA1Type_hexdigest_impl(SHA1object *self); + +static PyObject * +SHA1Type_hexdigest(SHA1object *self, PyObject *Py_UNUSED(ignored)) +{ + return SHA1Type_hexdigest_impl(self); +} + +PyDoc_STRVAR(SHA1Type_update__doc__, +"update($self, obj, /)\n" +"--\n" +"\n" +"Update this hash object\'s state with the provided string."); + +#define SHA1TYPE_UPDATE_METHODDEF \ + {"update", (PyCFunction)SHA1Type_update, METH_O, SHA1Type_update__doc__}, + +PyDoc_STRVAR(_sha1_sha1__doc__, +"sha1($module, /, string=b\'\')\n" +"--\n" +"\n" +"Return a new SHA1 hash object; optionally initialized with a string."); + +#define _SHA1_SHA1_METHODDEF \ + {"sha1", (PyCFunction)_sha1_sha1, METH_VARARGS|METH_KEYWORDS, _sha1_sha1__doc__}, + +static PyObject * +_sha1_sha1_impl(PyModuleDef *module, PyObject *string); + +static PyObject * +_sha1_sha1(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"string", NULL}; + PyObject *string = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|O:sha1", _keywords, + &string)) + goto exit; + return_value = _sha1_sha1_impl(module, string); + +exit: + return return_value; +} +/*[clinic end generated code: output=b2890b9ca964b217 input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/sha256module.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/sha256module.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,125 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(SHA256Type_copy__doc__, +"copy($self, /)\n" +"--\n" +"\n" +"Return a copy of the hash object."); + +#define SHA256TYPE_COPY_METHODDEF \ + {"copy", (PyCFunction)SHA256Type_copy, METH_NOARGS, SHA256Type_copy__doc__}, + +static PyObject * +SHA256Type_copy_impl(SHAobject *self); + +static PyObject * +SHA256Type_copy(SHAobject *self, PyObject *Py_UNUSED(ignored)) +{ + return SHA256Type_copy_impl(self); +} + +PyDoc_STRVAR(SHA256Type_digest__doc__, +"digest($self, /)\n" +"--\n" +"\n" +"Return the digest value as a string of binary data."); + +#define SHA256TYPE_DIGEST_METHODDEF \ + {"digest", (PyCFunction)SHA256Type_digest, METH_NOARGS, SHA256Type_digest__doc__}, + +static PyObject * +SHA256Type_digest_impl(SHAobject *self); + +static PyObject * +SHA256Type_digest(SHAobject *self, PyObject *Py_UNUSED(ignored)) +{ + return SHA256Type_digest_impl(self); +} + +PyDoc_STRVAR(SHA256Type_hexdigest__doc__, +"hexdigest($self, /)\n" +"--\n" +"\n" +"Return the digest value as a string of hexadecimal digits."); + +#define SHA256TYPE_HEXDIGEST_METHODDEF \ + {"hexdigest", (PyCFunction)SHA256Type_hexdigest, METH_NOARGS, SHA256Type_hexdigest__doc__}, + +static PyObject * +SHA256Type_hexdigest_impl(SHAobject *self); + +static PyObject * +SHA256Type_hexdigest(SHAobject *self, PyObject *Py_UNUSED(ignored)) +{ + return SHA256Type_hexdigest_impl(self); +} + +PyDoc_STRVAR(SHA256Type_update__doc__, +"update($self, obj, /)\n" +"--\n" +"\n" +"Update this hash object\'s state with the provided string."); + +#define SHA256TYPE_UPDATE_METHODDEF \ + {"update", (PyCFunction)SHA256Type_update, METH_O, SHA256Type_update__doc__}, + +PyDoc_STRVAR(_sha256_sha256__doc__, +"sha256($module, /, string=b\'\')\n" +"--\n" +"\n" +"Return a new SHA-256 hash object; optionally initialized with a string."); + +#define _SHA256_SHA256_METHODDEF \ + {"sha256", (PyCFunction)_sha256_sha256, METH_VARARGS|METH_KEYWORDS, _sha256_sha256__doc__}, + +static PyObject * +_sha256_sha256_impl(PyModuleDef *module, PyObject *string); + +static PyObject * +_sha256_sha256(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"string", NULL}; + PyObject *string = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|O:sha256", _keywords, + &string)) + goto exit; + return_value = _sha256_sha256_impl(module, string); + +exit: + return return_value; +} + +PyDoc_STRVAR(_sha256_sha224__doc__, +"sha224($module, /, string=b\'\')\n" +"--\n" +"\n" +"Return a new SHA-224 hash object; optionally initialized with a string."); + +#define _SHA256_SHA224_METHODDEF \ + {"sha224", (PyCFunction)_sha256_sha224, METH_VARARGS|METH_KEYWORDS, _sha256_sha224__doc__}, + +static PyObject * +_sha256_sha224_impl(PyModuleDef *module, PyObject *string); + +static PyObject * +_sha256_sha224(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"string", NULL}; + PyObject *string = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|O:sha224", _keywords, + &string)) + goto exit; + return_value = _sha256_sha224_impl(module, string); + +exit: + return return_value; +} +/*[clinic end generated code: output=8a0520371b097358 input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/sha512module.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/sha512module.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,173 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#if defined(PY_LONG_LONG) + +PyDoc_STRVAR(SHA512Type_copy__doc__, +"copy($self, /)\n" +"--\n" +"\n" +"Return a copy of the hash object."); + +#define SHA512TYPE_COPY_METHODDEF \ + {"copy", (PyCFunction)SHA512Type_copy, METH_NOARGS, SHA512Type_copy__doc__}, + +static PyObject * +SHA512Type_copy_impl(SHAobject *self); + +static PyObject * +SHA512Type_copy(SHAobject *self, PyObject *Py_UNUSED(ignored)) +{ + return SHA512Type_copy_impl(self); +} + +#endif /* defined(PY_LONG_LONG) */ + +#ifndef SHA512TYPE_COPY_METHODDEF + #define SHA512TYPE_COPY_METHODDEF +#endif /* !defined(SHA512TYPE_COPY_METHODDEF) */ + +#if defined(PY_LONG_LONG) + +PyDoc_STRVAR(SHA512Type_digest__doc__, +"digest($self, /)\n" +"--\n" +"\n" +"Return the digest value as a string of binary data."); + +#define SHA512TYPE_DIGEST_METHODDEF \ + {"digest", (PyCFunction)SHA512Type_digest, METH_NOARGS, SHA512Type_digest__doc__}, + +static PyObject * +SHA512Type_digest_impl(SHAobject *self); + +static PyObject * +SHA512Type_digest(SHAobject *self, PyObject *Py_UNUSED(ignored)) +{ + return SHA512Type_digest_impl(self); +} + +#endif /* defined(PY_LONG_LONG) */ + +#ifndef SHA512TYPE_DIGEST_METHODDEF + #define SHA512TYPE_DIGEST_METHODDEF +#endif /* !defined(SHA512TYPE_DIGEST_METHODDEF) */ + +#if defined(PY_LONG_LONG) + +PyDoc_STRVAR(SHA512Type_hexdigest__doc__, +"hexdigest($self, /)\n" +"--\n" +"\n" +"Return the digest value as a string of hexadecimal digits."); + +#define SHA512TYPE_HEXDIGEST_METHODDEF \ + {"hexdigest", (PyCFunction)SHA512Type_hexdigest, METH_NOARGS, SHA512Type_hexdigest__doc__}, + +static PyObject * +SHA512Type_hexdigest_impl(SHAobject *self); + +static PyObject * +SHA512Type_hexdigest(SHAobject *self, PyObject *Py_UNUSED(ignored)) +{ + return SHA512Type_hexdigest_impl(self); +} + +#endif /* defined(PY_LONG_LONG) */ + +#ifndef SHA512TYPE_HEXDIGEST_METHODDEF + #define SHA512TYPE_HEXDIGEST_METHODDEF +#endif /* !defined(SHA512TYPE_HEXDIGEST_METHODDEF) */ + +#if defined(PY_LONG_LONG) + +PyDoc_STRVAR(SHA512Type_update__doc__, +"update($self, obj, /)\n" +"--\n" +"\n" +"Update this hash object\'s state with the provided string."); + +#define SHA512TYPE_UPDATE_METHODDEF \ + {"update", (PyCFunction)SHA512Type_update, METH_O, SHA512Type_update__doc__}, + +#endif /* defined(PY_LONG_LONG) */ + +#ifndef SHA512TYPE_UPDATE_METHODDEF + #define SHA512TYPE_UPDATE_METHODDEF +#endif /* !defined(SHA512TYPE_UPDATE_METHODDEF) */ + +#if defined(PY_LONG_LONG) + +PyDoc_STRVAR(_sha512_sha512__doc__, +"sha512($module, /, string=b\'\')\n" +"--\n" +"\n" +"Return a new SHA-512 hash object; optionally initialized with a string."); + +#define _SHA512_SHA512_METHODDEF \ + {"sha512", (PyCFunction)_sha512_sha512, METH_VARARGS|METH_KEYWORDS, _sha512_sha512__doc__}, + +static PyObject * +_sha512_sha512_impl(PyModuleDef *module, PyObject *string); + +static PyObject * +_sha512_sha512(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"string", NULL}; + PyObject *string = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|O:sha512", _keywords, + &string)) + goto exit; + return_value = _sha512_sha512_impl(module, string); + +exit: + return return_value; +} + +#endif /* defined(PY_LONG_LONG) */ + +#ifndef _SHA512_SHA512_METHODDEF + #define _SHA512_SHA512_METHODDEF +#endif /* !defined(_SHA512_SHA512_METHODDEF) */ + +#if defined(PY_LONG_LONG) + +PyDoc_STRVAR(_sha512_sha384__doc__, +"sha384($module, /, string=b\'\')\n" +"--\n" +"\n" +"Return a new SHA-384 hash object; optionally initialized with a string."); + +#define _SHA512_SHA384_METHODDEF \ + {"sha384", (PyCFunction)_sha512_sha384, METH_VARARGS|METH_KEYWORDS, _sha512_sha384__doc__}, + +static PyObject * +_sha512_sha384_impl(PyModuleDef *module, PyObject *string); + +static PyObject * +_sha512_sha384(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"string", NULL}; + PyObject *string = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|O:sha384", _keywords, + &string)) + goto exit; + return_value = _sha512_sha384_impl(module, string); + +exit: + return return_value; +} + +#endif /* defined(PY_LONG_LONG) */ + +#ifndef _SHA512_SHA384_METHODDEF + #define _SHA512_SHA384_METHODDEF +#endif /* !defined(_SHA512_SHA384_METHODDEF) */ +/*[clinic end generated code: output=18c87ce66e489d38 input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/clinic/unicodedata.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/unicodedata.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,37 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(unicodedata_UCD_decimal__doc__, +"decimal($self, unichr, default=None, /)\n" +"--\n" +"\n" +"Converts a Unicode character into its equivalent decimal value.\n" +"\n" +"Returns the decimal value assigned to the Unicode character unichr\n" +"as integer. If no such value is defined, default is returned, or, if\n" +"not given, ValueError is raised."); + +#define UNICODEDATA_UCD_DECIMAL_METHODDEF \ + {"decimal", (PyCFunction)unicodedata_UCD_decimal, METH_VARARGS, unicodedata_UCD_decimal__doc__}, + +static PyObject * +unicodedata_UCD_decimal_impl(PreviousDBVersion *self, PyUnicodeObject *unichr, PyObject *default_value); + +static PyObject * +unicodedata_UCD_decimal(PreviousDBVersion *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyUnicodeObject *unichr; + PyObject *default_value = NULL; + + if (!PyArg_ParseTuple(args, + "O!|O:decimal", + &PyUnicode_Type, &unichr, &default_value)) + goto exit; + return_value = unicodedata_UCD_decimal_impl(self, unichr, default_value); + +exit: + return return_value; +} +/*[clinic end generated code: output=15b82651419cc823 input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Modules/md5module.c --- a/Modules/md5module.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/md5module.c Sun Feb 22 11:52:48 2015 +0200 @@ -53,6 +53,7 @@ typedef struct { struct md5_state hash_state; } MD5object; +#include "clinic/md5module.c.h" /* ------------------------------------------------------------------------ * @@ -343,27 +344,9 @@ MD5Type.copy Return a copy of the hash object. [clinic start generated code]*/ -PyDoc_STRVAR(MD5Type_copy__doc__, -"copy($self, /)\n" -"--\n" -"\n" -"Return a copy of the hash object."); - -#define MD5TYPE_COPY_METHODDEF \ - {"copy", (PyCFunction)MD5Type_copy, METH_NOARGS, MD5Type_copy__doc__}, - -static PyObject * -MD5Type_copy_impl(MD5object *self); - -static PyObject * -MD5Type_copy(MD5object *self, PyObject *Py_UNUSED(ignored)) -{ - return MD5Type_copy_impl(self); -} - static PyObject * MD5Type_copy_impl(MD5object *self) -/*[clinic end generated code: output=3b3a88920b3dc7f4 input=2c09e6d2493f3079]*/ +/*[clinic end generated code: output=596eb36852f02071 input=2c09e6d2493f3079]*/ { MD5object *newobj; @@ -385,27 +368,9 @@ MD5Type.digest Return the digest value as a string of binary data. [clinic start generated code]*/ -PyDoc_STRVAR(MD5Type_digest__doc__, -"digest($self, /)\n" -"--\n" -"\n" -"Return the digest value as a string of binary data."); - -#define MD5TYPE_DIGEST_METHODDEF \ - {"digest", (PyCFunction)MD5Type_digest, METH_NOARGS, MD5Type_digest__doc__}, - -static PyObject * -MD5Type_digest_impl(MD5object *self); - -static PyObject * -MD5Type_digest(MD5object *self, PyObject *Py_UNUSED(ignored)) -{ - return MD5Type_digest_impl(self); -} - static PyObject * MD5Type_digest_impl(MD5object *self) -/*[clinic end generated code: output=7a796b28fa89485f input=7b96e65389412a34]*/ +/*[clinic end generated code: output=eb691dc4190a07ec input=7b96e65389412a34]*/ { unsigned char digest[MD5_DIGESTSIZE]; struct md5_state temp; @@ -421,27 +386,9 @@ MD5Type.hexdigest Return the digest value as a string of hexadecimal digits. [clinic start generated code]*/ -PyDoc_STRVAR(MD5Type_hexdigest__doc__, -"hexdigest($self, /)\n" -"--\n" -"\n" -"Return the digest value as a string of hexadecimal digits."); - -#define MD5TYPE_HEXDIGEST_METHODDEF \ - {"hexdigest", (PyCFunction)MD5Type_hexdigest, METH_NOARGS, MD5Type_hexdigest__doc__}, - -static PyObject * -MD5Type_hexdigest_impl(MD5object *self); - -static PyObject * -MD5Type_hexdigest(MD5object *self, PyObject *Py_UNUSED(ignored)) -{ - return MD5Type_hexdigest_impl(self); -} - static PyObject * MD5Type_hexdigest_impl(MD5object *self) -/*[clinic end generated code: output=daa73609f94f92e1 input=b60b19de644798dd]*/ +/*[clinic end generated code: output=17badced1f3ac932 input=b60b19de644798dd]*/ { unsigned char digest[MD5_DIGESTSIZE]; struct md5_state temp; @@ -482,18 +429,9 @@ MD5Type.update Update this hash object's state with the provided string. [clinic start generated code]*/ -PyDoc_STRVAR(MD5Type_update__doc__, -"update($self, obj, /)\n" -"--\n" -"\n" -"Update this hash object\'s state with the provided string."); - -#define MD5TYPE_UPDATE_METHODDEF \ - {"update", (PyCFunction)MD5Type_update, METH_O, MD5Type_update__doc__}, - static PyObject * MD5Type_update(MD5object *self, PyObject *obj) -/*[clinic end generated code: output=9d09b6c6cdc6cac3 input=6e1efcd9ecf17032]*/ +/*[clinic end generated code: output=f6ad168416338423 input=6e1efcd9ecf17032]*/ { Py_buffer buf; @@ -594,38 +532,9 @@ static PyTypeObject MD5type = { Return a new MD5 hash object; optionally initialized with a string. [clinic start generated code]*/ -PyDoc_STRVAR(_md5_md5__doc__, -"md5($module, /, string=b\'\')\n" -"--\n" -"\n" -"Return a new MD5 hash object; optionally initialized with a string."); - -#define _MD5_MD5_METHODDEF \ - {"md5", (PyCFunction)_md5_md5, METH_VARARGS|METH_KEYWORDS, _md5_md5__doc__}, - -static PyObject * -_md5_md5_impl(PyModuleDef *module, PyObject *string); - -static PyObject * -_md5_md5(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"string", NULL}; - PyObject *string = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|O:md5", _keywords, - &string)) - goto exit; - return_value = _md5_md5_impl(module, string); - -exit: - return return_value; -} - static PyObject * _md5_md5_impl(PyModuleDef *module, PyObject *string) -/*[clinic end generated code: output=1039e912d919880e input=d12ef8f72d684f7b]*/ +/*[clinic end generated code: output=3527436a2090b956 input=d12ef8f72d684f7b]*/ { MD5object *new; Py_buffer buf; diff -r a824c40e8fc0 Modules/posixmodule.c --- a/Modules/posixmodule.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/posixmodule.c Sun Feb 22 11:52:48 2015 +0200 @@ -2571,61 +2571,9 @@ It's an error to use dir_fd or follow_sy [clinic start generated code]*/ -PyDoc_STRVAR(os_stat__doc__, -"stat($module, /, path, *, dir_fd=None, follow_symlinks=True)\n" -"--\n" -"\n" -"Perform a stat system call on the given path.\n" -"\n" -" path\n" -" Path to be examined; can be string, bytes, or open-file-descriptor int.\n" -" dir_fd\n" -" If not None, it should be a file descriptor open to a directory,\n" -" and path should be a relative string; path will then be relative to\n" -" that directory.\n" -" follow_symlinks\n" -" If False, and the last element of the path is a symbolic link,\n" -" stat will examine the symbolic link itself instead of the file\n" -" the link points to.\n" -"\n" -"dir_fd and follow_symlinks may not be implemented\n" -" on your platform. If they are unavailable, using them will raise a\n" -" NotImplementedError.\n" -"\n" -"It\'s an error to use dir_fd or follow_symlinks when specifying path as\n" -" an open file descriptor."); - -#define OS_STAT_METHODDEF \ - {"stat", (PyCFunction)os_stat, METH_VARARGS|METH_KEYWORDS, os_stat__doc__}, - -static PyObject * -os_stat_impl(PyModuleDef *module, path_t *path, int dir_fd, int follow_symlinks); - -static PyObject * -os_stat(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "dir_fd", "follow_symlinks", NULL}; - path_t path = PATH_T_INITIALIZE("stat", "path", 0, 1); - int dir_fd = DEFAULT_DIR_FD; - int follow_symlinks = 1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&|$O&p:stat", _keywords, - path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) - goto exit; - return_value = os_stat_impl(module, &path, dir_fd, follow_symlinks); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_stat_impl(PyModuleDef *module, path_t *path, int dir_fd, int follow_symlinks) -/*[clinic end generated code: output=0e9f9508fa0c0607 input=099d356c306fa24a]*/ +/*[clinic end generated code: output=708c225f94fcfc8e input=099d356c306fa24a]*/ { return posix_do_stat("stat", path, dir_fd, follow_symlinks); } @@ -2646,45 +2594,9 @@ Like stat(), but do not follow symbolic Equivalent to stat(path, follow_symlinks=False). [clinic start generated code]*/ -PyDoc_STRVAR(os_lstat__doc__, -"lstat($module, /, path, *, dir_fd=None)\n" -"--\n" -"\n" -"Perform a stat system call on the given path, without following symbolic links.\n" -"\n" -"Like stat(), but do not follow symbolic links.\n" -"Equivalent to stat(path, follow_symlinks=False)."); - -#define OS_LSTAT_METHODDEF \ - {"lstat", (PyCFunction)os_lstat, METH_VARARGS|METH_KEYWORDS, os_lstat__doc__}, - -static PyObject * -os_lstat_impl(PyModuleDef *module, path_t *path, int dir_fd); - -static PyObject * -os_lstat(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "dir_fd", NULL}; - path_t path = PATH_T_INITIALIZE("lstat", "path", 0, 0); - int dir_fd = DEFAULT_DIR_FD; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&|$O&:lstat", _keywords, - path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd)) - goto exit; - return_value = os_lstat_impl(module, &path, dir_fd); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_lstat_impl(PyModuleDef *module, path_t *path, int dir_fd) -/*[clinic end generated code: output=85702247224a2b1c input=0b7474765927b925]*/ +/*[clinic end generated code: output=7a748e333fcb39bd input=0b7474765927b925]*/ { int follow_symlinks = 0; return posix_do_stat("lstat", path, dir_fd, follow_symlinks); @@ -2730,75 +2642,9 @@ Note that most operations will use the e [clinic start generated code]*/ -PyDoc_STRVAR(os_access__doc__, -"access($module, /, path, mode, *, dir_fd=None, effective_ids=False,\n" -" follow_symlinks=True)\n" -"--\n" -"\n" -"Use the real uid/gid to test for access to a path.\n" -"\n" -" path\n" -" Path to be tested; can be string, bytes, or open-file-descriptor int.\n" -" mode\n" -" Operating-system mode bitfield. Can be F_OK to test existence,\n" -" or the inclusive-OR of R_OK, W_OK, and X_OK.\n" -" dir_fd\n" -" If not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that\n" -" directory.\n" -" effective_ids\n" -" If True, access will use the effective uid/gid instead of\n" -" the real uid/gid.\n" -" follow_symlinks\n" -" If False, and the last element of the path is a symbolic link,\n" -" access will examine the symbolic link itself instead of the file\n" -" the link points to.\n" -"\n" -"dir_fd, effective_ids, and follow_symlinks may not be implemented\n" -" on your platform. If they are unavailable, using them will raise a\n" -" NotImplementedError.\n" -"\n" -"Note that most operations will use the effective uid/gid, therefore this\n" -" routine can be used in a suid/sgid environment to test if the invoking user\n" -" has the specified access to the path."); - -#define OS_ACCESS_METHODDEF \ - {"access", (PyCFunction)os_access, METH_VARARGS|METH_KEYWORDS, os_access__doc__}, - -static int -os_access_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd, int effective_ids, int follow_symlinks); - -static PyObject * -os_access(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL}; - path_t path = PATH_T_INITIALIZE("access", "path", 0, 1); - int mode; - int dir_fd = DEFAULT_DIR_FD; - int effective_ids = 0; - int follow_symlinks = 1; - int _return_value; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&i|$O&pp:access", _keywords, - path_converter, &path, &mode, FACCESSAT_DIR_FD_CONVERTER, &dir_fd, &effective_ids, &follow_symlinks)) - goto exit; - _return_value = os_access_impl(module, &path, mode, dir_fd, effective_ids, follow_symlinks); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyBool_FromLong((long)_return_value); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static int os_access_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd, int effective_ids, int follow_symlinks) -/*[clinic end generated code: output=dfd404666906f012 input=b75a756797af45ec]*/ +/*[clinic end generated code: output=f9e734db3d88b767 input=b75a756797af45ec]*/ { int return_value; @@ -2888,44 +2734,9 @@ os.ttyname -> DecodeFSDefault Return the name of the terminal device connected to 'fd'. [clinic start generated code]*/ -PyDoc_STRVAR(os_ttyname__doc__, -"ttyname($module, fd, /)\n" -"--\n" -"\n" -"Return the name of the terminal device connected to \'fd\'.\n" -"\n" -" fd\n" -" Integer file descriptor handle."); - -#define OS_TTYNAME_METHODDEF \ - {"ttyname", (PyCFunction)os_ttyname, METH_VARARGS, os_ttyname__doc__}, - -static char * -os_ttyname_impl(PyModuleDef *module, int fd); - -static PyObject * -os_ttyname(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - char *_return_value; - - if (!PyArg_ParseTuple(args, - "i:ttyname", - &fd)) - goto exit; - _return_value = os_ttyname_impl(module, fd); - if (_return_value == NULL) - goto exit; - return_value = PyUnicode_DecodeFSDefault(_return_value); - -exit: - return return_value; -} - static char * os_ttyname_impl(PyModuleDef *module, int fd) -/*[clinic end generated code: output=cee7bc4cffec01a2 input=5f72ca83e76b3b45]*/ +/*[clinic end generated code: output=03ad3d5ccaef75c3 input=5f72ca83e76b3b45]*/ { char *ret; @@ -2943,27 +2754,9 @@ os.ctermid Return the name of the controlling terminal for this process. [clinic start generated code]*/ -PyDoc_STRVAR(os_ctermid__doc__, -"ctermid($module, /)\n" -"--\n" -"\n" -"Return the name of the controlling terminal for this process."); - -#define OS_CTERMID_METHODDEF \ - {"ctermid", (PyCFunction)os_ctermid, METH_NOARGS, os_ctermid__doc__}, - -static PyObject * -os_ctermid_impl(PyModuleDef *module); - -static PyObject * -os_ctermid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_ctermid_impl(module); -} - static PyObject * os_ctermid_impl(PyModuleDef *module) -/*[clinic end generated code: output=277bf7964ec2d782 input=3b87fdd52556382d]*/ +/*[clinic end generated code: output=1b73788201e0aebd input=3b87fdd52556382d]*/ { char *ret; char buffer[L_ctermid]; @@ -2992,45 +2785,9 @@ On some platforms, path may also be spec If this functionality is unavailable, using it raises an exception. [clinic start generated code]*/ -PyDoc_STRVAR(os_chdir__doc__, -"chdir($module, /, path)\n" -"--\n" -"\n" -"Change the current working directory to the specified path.\n" -"\n" -"path may always be specified as a string.\n" -"On some platforms, path may also be specified as an open file descriptor.\n" -" If this functionality is unavailable, using it raises an exception."); - -#define OS_CHDIR_METHODDEF \ - {"chdir", (PyCFunction)os_chdir, METH_VARARGS|METH_KEYWORDS, os_chdir__doc__}, - -static PyObject * -os_chdir_impl(PyModuleDef *module, path_t *path); - -static PyObject * -os_chdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", NULL}; - path_t path = PATH_T_INITIALIZE("chdir", "path", 0, PATH_HAVE_FCHDIR); - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&:chdir", _keywords, - path_converter, &path)) - goto exit; - return_value = os_chdir_impl(module, &path); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_chdir_impl(PyModuleDef *module, path_t *path) -/*[clinic end generated code: output=cc07592dd23ca9e0 input=1a4a15b4d12cb15d]*/ +/*[clinic end generated code: output=7358e3a20fb5aa93 input=1a4a15b4d12cb15d]*/ { int result; @@ -3072,41 +2829,9 @@ Equivalent to os.chdir(fd). [clinic start generated code]*/ -PyDoc_STRVAR(os_fchdir__doc__, -"fchdir($module, /, fd)\n" -"--\n" -"\n" -"Change to the directory of the given file descriptor.\n" -"\n" -"fd must be opened on a directory, not a file.\n" -"Equivalent to os.chdir(fd)."); - -#define OS_FCHDIR_METHODDEF \ - {"fchdir", (PyCFunction)os_fchdir, METH_VARARGS|METH_KEYWORDS, os_fchdir__doc__}, - -static PyObject * -os_fchdir_impl(PyModuleDef *module, int fd); - -static PyObject * -os_fchdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"fd", NULL}; - int fd; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&:fchdir", _keywords, - fildes_converter, &fd)) - goto exit; - return_value = os_fchdir_impl(module, fd); - -exit: - return return_value; -} - static PyObject * os_fchdir_impl(PyModuleDef *module, int fd) -/*[clinic end generated code: output=9f6dbc89b2778834 input=18e816479a2fa985]*/ +/*[clinic end generated code: output=361d30df6b2d3418 input=18e816479a2fa985]*/ { return posix_fildes_fd(fd, fchdir); } @@ -3145,64 +2870,9 @@ dir_fd and follow_symlinks may not be im [clinic start generated code]*/ -PyDoc_STRVAR(os_chmod__doc__, -"chmod($module, /, path, mode, *, dir_fd=None, follow_symlinks=True)\n" -"--\n" -"\n" -"Change the access permissions of a file.\n" -"\n" -" path\n" -" Path to be modified. May always be specified as a str or bytes.\n" -" On some platforms, path may also be specified as an open file descriptor.\n" -" If this functionality is unavailable, using it raises an exception.\n" -" mode\n" -" Operating-system mode bitfield.\n" -" dir_fd\n" -" If not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that\n" -" directory.\n" -" follow_symlinks\n" -" If False, and the last element of the path is a symbolic link,\n" -" chmod will modify the symbolic link itself instead of the file\n" -" the link points to.\n" -"\n" -"It is an error to use dir_fd or follow_symlinks when specifying path as\n" -" an open file descriptor.\n" -"dir_fd and follow_symlinks may not be implemented on your platform.\n" -" If they are unavailable, using them will raise a NotImplementedError."); - -#define OS_CHMOD_METHODDEF \ - {"chmod", (PyCFunction)os_chmod, METH_VARARGS|METH_KEYWORDS, os_chmod__doc__}, - -static PyObject * -os_chmod_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd, int follow_symlinks); - -static PyObject * -os_chmod(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "mode", "dir_fd", "follow_symlinks", NULL}; - path_t path = PATH_T_INITIALIZE("chmod", "path", 0, PATH_HAVE_FCHMOD); - int mode; - int dir_fd = DEFAULT_DIR_FD; - int follow_symlinks = 1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&i|$O&p:chmod", _keywords, - path_converter, &path, &mode, FCHMODAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) - goto exit; - return_value = os_chmod_impl(module, &path, mode, dir_fd, follow_symlinks); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_chmod_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd, int follow_symlinks) -/*[clinic end generated code: output=1e9db031aea46422 input=7f1618e5e15cc196]*/ +/*[clinic end generated code: output=96063c976f23106a input=7f1618e5e15cc196]*/ { int result; @@ -3313,41 +2983,9 @@ Change the access permissions of the fil Equivalent to os.chmod(fd, mode). [clinic start generated code]*/ -PyDoc_STRVAR(os_fchmod__doc__, -"fchmod($module, /, fd, mode)\n" -"--\n" -"\n" -"Change the access permissions of the file given by file descriptor fd.\n" -"\n" -"Equivalent to os.chmod(fd, mode)."); - -#define OS_FCHMOD_METHODDEF \ - {"fchmod", (PyCFunction)os_fchmod, METH_VARARGS|METH_KEYWORDS, os_fchmod__doc__}, - -static PyObject * -os_fchmod_impl(PyModuleDef *module, int fd, int mode); - -static PyObject * -os_fchmod(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"fd", "mode", NULL}; - int fd; - int mode; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "ii:fchmod", _keywords, - &fd, &mode)) - goto exit; - return_value = os_fchmod_impl(module, fd, mode); - -exit: - return return_value; -} - static PyObject * os_fchmod_impl(PyModuleDef *module, int fd, int mode) -/*[clinic end generated code: output=3c19fbfd724a8e0f input=8ab11975ca01ee5b]*/ +/*[clinic end generated code: output=2ee31ca226d1ed33 input=8ab11975ca01ee5b]*/ { int res; int async_err = 0; @@ -3378,45 +3016,9 @@ If path is a symlink, this affects the l Equivalent to chmod(path, mode, follow_symlinks=False)." [clinic start generated code]*/ -PyDoc_STRVAR(os_lchmod__doc__, -"lchmod($module, /, path, mode)\n" -"--\n" -"\n" -"Change the access permissions of a file, without following symbolic links.\n" -"\n" -"If path is a symlink, this affects the link itself rather than the target.\n" -"Equivalent to chmod(path, mode, follow_symlinks=False).\""); - -#define OS_LCHMOD_METHODDEF \ - {"lchmod", (PyCFunction)os_lchmod, METH_VARARGS|METH_KEYWORDS, os_lchmod__doc__}, - -static PyObject * -os_lchmod_impl(PyModuleDef *module, path_t *path, int mode); - -static PyObject * -os_lchmod(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "mode", NULL}; - path_t path = PATH_T_INITIALIZE("lchmod", "path", 0, 0); - int mode; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&i:lchmod", _keywords, - path_converter, &path, &mode)) - goto exit; - return_value = os_lchmod_impl(module, &path, mode); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_lchmod_impl(PyModuleDef *module, path_t *path, int mode) -/*[clinic end generated code: output=2849977d65f8c68c input=90c5663c7465d24f]*/ +/*[clinic end generated code: output=7c0cc46588d89e46 input=90c5663c7465d24f]*/ { int res; Py_BEGIN_ALLOW_THREADS @@ -3449,49 +3051,9 @@ unavailable, using it will raise a NotIm [clinic start generated code]*/ -PyDoc_STRVAR(os_chflags__doc__, -"chflags($module, /, path, flags, follow_symlinks=True)\n" -"--\n" -"\n" -"Set file flags.\n" -"\n" -"If follow_symlinks is False, and the last element of the path is a symbolic\n" -" link, chflags will change flags on the symbolic link itself instead of the\n" -" file the link points to.\n" -"follow_symlinks may not be implemented on your platform. If it is\n" -"unavailable, using it will raise a NotImplementedError."); - -#define OS_CHFLAGS_METHODDEF \ - {"chflags", (PyCFunction)os_chflags, METH_VARARGS|METH_KEYWORDS, os_chflags__doc__}, - -static PyObject * -os_chflags_impl(PyModuleDef *module, path_t *path, unsigned long flags, int follow_symlinks); - -static PyObject * -os_chflags(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "flags", "follow_symlinks", NULL}; - path_t path = PATH_T_INITIALIZE("chflags", "path", 0, 0); - unsigned long flags; - int follow_symlinks = 1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&k|p:chflags", _keywords, - path_converter, &path, &flags, &follow_symlinks)) - goto exit; - return_value = os_chflags_impl(module, &path, flags, follow_symlinks); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_chflags_impl(PyModuleDef *module, path_t *path, unsigned long flags, int follow_symlinks) -/*[clinic end generated code: output=2767927bf071e3cf input=0327e29feb876236]*/ +/*[clinic end generated code: output=9e5f9417afc20c4b input=0327e29feb876236]*/ { int result; @@ -3530,45 +3092,9 @@ This function will not follow symbolic l Equivalent to chflags(path, flags, follow_symlinks=False). [clinic start generated code]*/ -PyDoc_STRVAR(os_lchflags__doc__, -"lchflags($module, /, path, flags)\n" -"--\n" -"\n" -"Set file flags.\n" -"\n" -"This function will not follow symbolic links.\n" -"Equivalent to chflags(path, flags, follow_symlinks=False)."); - -#define OS_LCHFLAGS_METHODDEF \ - {"lchflags", (PyCFunction)os_lchflags, METH_VARARGS|METH_KEYWORDS, os_lchflags__doc__}, - -static PyObject * -os_lchflags_impl(PyModuleDef *module, path_t *path, unsigned long flags); - -static PyObject * -os_lchflags(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "flags", NULL}; - path_t path = PATH_T_INITIALIZE("lchflags", "path", 0, 0); - unsigned long flags; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&k:lchflags", _keywords, - path_converter, &path, &flags)) - goto exit; - return_value = os_lchflags_impl(module, &path, flags); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_lchflags_impl(PyModuleDef *module, path_t *path, unsigned long flags) -/*[clinic end generated code: output=bb93b6b8a5e45aa7 input=f9f82ea8b585ca9d]*/ +/*[clinic end generated code: output=6741322fb949661b input=f9f82ea8b585ca9d]*/ { int res; Py_BEGIN_ALLOW_THREADS @@ -3591,41 +3117,9 @@ Change root directory to path. [clinic start generated code]*/ -PyDoc_STRVAR(os_chroot__doc__, -"chroot($module, /, path)\n" -"--\n" -"\n" -"Change root directory to path."); - -#define OS_CHROOT_METHODDEF \ - {"chroot", (PyCFunction)os_chroot, METH_VARARGS|METH_KEYWORDS, os_chroot__doc__}, - -static PyObject * -os_chroot_impl(PyModuleDef *module, path_t *path); - -static PyObject * -os_chroot(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", NULL}; - path_t path = PATH_T_INITIALIZE("chroot", "path", 0, 0); - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&:chroot", _keywords, - path_converter, &path)) - goto exit; - return_value = os_chroot_impl(module, &path); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_chroot_impl(PyModuleDef *module, path_t *path) -/*[clinic end generated code: output=15b1256cbe4f24a1 input=14822965652c3dc3]*/ +/*[clinic end generated code: output=b6dbfabe74ecaa9d input=14822965652c3dc3]*/ { int res; Py_BEGIN_ALLOW_THREADS @@ -3647,38 +3141,9 @@ os.fsync Force write of fd to disk. [clinic start generated code]*/ -PyDoc_STRVAR(os_fsync__doc__, -"fsync($module, /, fd)\n" -"--\n" -"\n" -"Force write of fd to disk."); - -#define OS_FSYNC_METHODDEF \ - {"fsync", (PyCFunction)os_fsync, METH_VARARGS|METH_KEYWORDS, os_fsync__doc__}, - -static PyObject * -os_fsync_impl(PyModuleDef *module, int fd); - -static PyObject * -os_fsync(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"fd", NULL}; - int fd; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&:fsync", _keywords, - fildes_converter, &fd)) - goto exit; - return_value = os_fsync_impl(module, fd); - -exit: - return return_value; -} - static PyObject * os_fsync_impl(PyModuleDef *module, int fd) -/*[clinic end generated code: output=59f32d3a0b360133 input=21c3645c056967f2]*/ +/*[clinic end generated code: output=83a350851064aea7 input=21c3645c056967f2]*/ { return posix_fildes_fd(fd, fsync); } @@ -3692,27 +3157,9 @@ os.sync Force write of everything to disk. [clinic start generated code]*/ -PyDoc_STRVAR(os_sync__doc__, -"sync($module, /)\n" -"--\n" -"\n" -"Force write of everything to disk."); - -#define OS_SYNC_METHODDEF \ - {"sync", (PyCFunction)os_sync, METH_NOARGS, os_sync__doc__}, - -static PyObject * -os_sync_impl(PyModuleDef *module); - -static PyObject * -os_sync(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_sync_impl(module); -} - static PyObject * os_sync_impl(PyModuleDef *module) -/*[clinic end generated code: output=526c495683d0bb38 input=84749fe5e9b404ff]*/ +/*[clinic end generated code: output=ba524f656c201c40 input=84749fe5e9b404ff]*/ { Py_BEGIN_ALLOW_THREADS sync(); @@ -3735,38 +3182,9 @@ os.fdatasync Force write of fd to disk without forcing update of metadata. [clinic start generated code]*/ -PyDoc_STRVAR(os_fdatasync__doc__, -"fdatasync($module, /, fd)\n" -"--\n" -"\n" -"Force write of fd to disk without forcing update of metadata."); - -#define OS_FDATASYNC_METHODDEF \ - {"fdatasync", (PyCFunction)os_fdatasync, METH_VARARGS|METH_KEYWORDS, os_fdatasync__doc__}, - -static PyObject * -os_fdatasync_impl(PyModuleDef *module, int fd); - -static PyObject * -os_fdatasync(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"fd", NULL}; - int fd; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&:fdatasync", _keywords, - fildes_converter, &fd)) - goto exit; - return_value = os_fdatasync_impl(module, fd); - -exit: - return return_value; -} - static PyObject * os_fdatasync_impl(PyModuleDef *module, int fd) -/*[clinic end generated code: output=2335fdfd37c92180 input=bc74791ee54dd291]*/ +/*[clinic end generated code: output=e0f04a3aff515b75 input=bc74791ee54dd291]*/ { return posix_fildes_fd(fd, fdatasync); } @@ -3813,69 +3231,9 @@ dir_fd and follow_symlinks may not be im [clinic start generated code]*/ -PyDoc_STRVAR(os_chown__doc__, -"chown($module, /, path, uid, gid, *, dir_fd=None, follow_symlinks=True)\n" -"--\n" -"\n" -"Change the owner and group id of path to the numeric uid and gid.\\\n" -"\n" -" path\n" -" Path to be examined; can be string, bytes, or open-file-descriptor int.\n" -" dir_fd\n" -" If not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that\n" -" directory.\n" -" follow_symlinks\n" -" If False, and the last element of the path is a symbolic link,\n" -" stat will examine the symbolic link itself instead of the file\n" -" the link points to.\n" -"\n" -"path may always be specified as a string.\n" -"On some platforms, path may also be specified as an open file descriptor.\n" -" If this functionality is unavailable, using it raises an exception.\n" -"If dir_fd is not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that directory.\n" -"If follow_symlinks is False, and the last element of the path is a symbolic\n" -" link, chown will modify the symbolic link itself instead of the file the\n" -" link points to.\n" -"It is an error to use dir_fd or follow_symlinks when specifying path as\n" -" an open file descriptor.\n" -"dir_fd and follow_symlinks may not be implemented on your platform.\n" -" If they are unavailable, using them will raise a NotImplementedError."); - -#define OS_CHOWN_METHODDEF \ - {"chown", (PyCFunction)os_chown, METH_VARARGS|METH_KEYWORDS, os_chown__doc__}, - -static PyObject * -os_chown_impl(PyModuleDef *module, path_t *path, uid_t uid, gid_t gid, int dir_fd, int follow_symlinks); - -static PyObject * -os_chown(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "uid", "gid", "dir_fd", "follow_symlinks", NULL}; - path_t path = PATH_T_INITIALIZE("chown", "path", 0, PATH_HAVE_FCHOWN); - uid_t uid; - gid_t gid; - int dir_fd = DEFAULT_DIR_FD; - int follow_symlinks = 1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&O&O&|$O&p:chown", _keywords, - path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid, FCHOWNAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) - goto exit; - return_value = os_chown_impl(module, &path, uid, gid, dir_fd, follow_symlinks); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_chown_impl(PyModuleDef *module, path_t *path, uid_t uid, gid_t gid, int dir_fd, int follow_symlinks) -/*[clinic end generated code: output=22f011e3b4f9ff49 input=a61cc35574814d5d]*/ +/*[clinic end generated code: output=59a8db91897fb46c input=a61cc35574814d5d]*/ { int result; @@ -3942,42 +3300,9 @@ Equivalent to os.chown(fd, uid, gid). [clinic start generated code]*/ -PyDoc_STRVAR(os_fchown__doc__, -"fchown($module, /, fd, uid, gid)\n" -"--\n" -"\n" -"Change the owner and group id of the file specified by file descriptor.\n" -"\n" -"Equivalent to os.chown(fd, uid, gid)."); - -#define OS_FCHOWN_METHODDEF \ - {"fchown", (PyCFunction)os_fchown, METH_VARARGS|METH_KEYWORDS, os_fchown__doc__}, - -static PyObject * -os_fchown_impl(PyModuleDef *module, int fd, uid_t uid, gid_t gid); - -static PyObject * -os_fchown(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"fd", "uid", "gid", NULL}; - int fd; - uid_t uid; - gid_t gid; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "iO&O&:fchown", _keywords, - &fd, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid)) - goto exit; - return_value = os_fchown_impl(module, fd, uid, gid); - -exit: - return return_value; -} - static PyObject * os_fchown_impl(PyModuleDef *module, int fd, uid_t uid, gid_t gid) -/*[clinic end generated code: output=687781cb7d8974d6 input=3af544ba1b13a0d7]*/ +/*[clinic end generated code: output=7545abf8f6086d76 input=3af544ba1b13a0d7]*/ { int res; int async_err = 0; @@ -4009,46 +3334,9 @@ This function will not follow symbolic l Equivalent to os.chown(path, uid, gid, follow_symlinks=False). [clinic start generated code]*/ -PyDoc_STRVAR(os_lchown__doc__, -"lchown($module, /, path, uid, gid)\n" -"--\n" -"\n" -"Change the owner and group id of path to the numeric uid and gid.\n" -"\n" -"This function will not follow symbolic links.\n" -"Equivalent to os.chown(path, uid, gid, follow_symlinks=False)."); - -#define OS_LCHOWN_METHODDEF \ - {"lchown", (PyCFunction)os_lchown, METH_VARARGS|METH_KEYWORDS, os_lchown__doc__}, - -static PyObject * -os_lchown_impl(PyModuleDef *module, path_t *path, uid_t uid, gid_t gid); - -static PyObject * -os_lchown(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "uid", "gid", NULL}; - path_t path = PATH_T_INITIALIZE("lchown", "path", 0, 0); - uid_t uid; - gid_t gid; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&O&O&:lchown", _keywords, - path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid)) - goto exit; - return_value = os_lchown_impl(module, &path, uid, gid); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_lchown_impl(PyModuleDef *module, path_t *path, uid_t uid, gid_t gid) -/*[clinic end generated code: output=bf25fdb0d25130e2 input=b1c6014d563a7161]*/ +/*[clinic end generated code: output=bb0d2da1579ac275 input=b1c6014d563a7161]*/ { int res; Py_BEGIN_ALLOW_THREADS @@ -4121,27 +3409,9 @@ os.getcwd Return a unicode string representing the current working directory. [clinic start generated code]*/ -PyDoc_STRVAR(os_getcwd__doc__, -"getcwd($module, /)\n" -"--\n" -"\n" -"Return a unicode string representing the current working directory."); - -#define OS_GETCWD_METHODDEF \ - {"getcwd", (PyCFunction)os_getcwd, METH_NOARGS, os_getcwd__doc__}, - -static PyObject * -os_getcwd_impl(PyModuleDef *module); - -static PyObject * -os_getcwd(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getcwd_impl(module); -} - static PyObject * os_getcwd_impl(PyModuleDef *module) -/*[clinic end generated code: output=d70b281db5c78ff7 input=f069211bb70e3d39]*/ +/*[clinic end generated code: output=efe3a8c0121525ea input=f069211bb70e3d39]*/ { return posix_getcwd(0); } @@ -4153,27 +3423,9 @@ os.getcwdb Return a bytes string representing the current working directory. [clinic start generated code]*/ -PyDoc_STRVAR(os_getcwdb__doc__, -"getcwdb($module, /)\n" -"--\n" -"\n" -"Return a bytes string representing the current working directory."); - -#define OS_GETCWDB_METHODDEF \ - {"getcwdb", (PyCFunction)os_getcwdb, METH_NOARGS, os_getcwdb__doc__}, - -static PyObject * -os_getcwdb_impl(PyModuleDef *module); - -static PyObject * -os_getcwdb(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getcwdb_impl(module); -} - static PyObject * os_getcwdb_impl(PyModuleDef *module) -/*[clinic end generated code: output=75da47f2d75f9166 input=f6f6a378dad3d9cb]*/ +/*[clinic end generated code: output=7fce42ee4b2a296a input=f6f6a378dad3d9cb]*/ { return posix_getcwd(1); } @@ -4208,58 +3460,9 @@ src_dir_fd, dst_dir_fd, and follow_symli NotImplementedError. [clinic start generated code]*/ -PyDoc_STRVAR(os_link__doc__, -"link($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None,\n" -" follow_symlinks=True)\n" -"--\n" -"\n" -"Create a hard link to a file.\n" -"\n" -"If either src_dir_fd or dst_dir_fd is not None, it should be a file\n" -" descriptor open to a directory, and the respective path string (src or dst)\n" -" should be relative; the path will then be relative to that directory.\n" -"If follow_symlinks is False, and the last element of src is a symbolic\n" -" link, link will create a link to the symbolic link itself instead of the\n" -" file the link points to.\n" -"src_dir_fd, dst_dir_fd, and follow_symlinks may not be implemented on your\n" -" platform. If they are unavailable, using them will raise a\n" -" NotImplementedError."); - -#define OS_LINK_METHODDEF \ - {"link", (PyCFunction)os_link, METH_VARARGS|METH_KEYWORDS, os_link__doc__}, - -static PyObject * -os_link_impl(PyModuleDef *module, path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd, int follow_symlinks); - -static PyObject * -os_link(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", "follow_symlinks", NULL}; - path_t src = PATH_T_INITIALIZE("link", "src", 0, 0); - path_t dst = PATH_T_INITIALIZE("link", "dst", 0, 0); - int src_dir_fd = DEFAULT_DIR_FD; - int dst_dir_fd = DEFAULT_DIR_FD; - int follow_symlinks = 1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&O&|$O&O&p:link", _keywords, - path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd, &follow_symlinks)) - goto exit; - return_value = os_link_impl(module, &src, &dst, src_dir_fd, dst_dir_fd, follow_symlinks); - -exit: - /* Cleanup for src */ - path_cleanup(&src); - /* Cleanup for dst */ - path_cleanup(&dst); - - return return_value; -} - static PyObject * os_link_impl(PyModuleDef *module, path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd, int follow_symlinks) -/*[clinic end generated code: output=53477662fe02e183 input=b0095ebbcbaa7e04]*/ +/*[clinic end generated code: output=c0a9ded8111d2a79 input=b0095ebbcbaa7e04]*/ { #ifdef MS_WINDOWS BOOL result; @@ -4597,52 +3800,9 @@ entries '.' and '..' even if they are pr [clinic start generated code]*/ -PyDoc_STRVAR(os_listdir__doc__, -"listdir($module, /, path=None)\n" -"--\n" -"\n" -"Return a list containing the names of the files in the directory.\n" -"\n" -"path can be specified as either str or bytes. If path is bytes,\n" -" the filenames returned will also be bytes; in all other circumstances\n" -" the filenames returned will be str.\n" -"If path is None, uses the path=\'.\'.\n" -"On some platforms, path may also be specified as an open file descriptor;\\\n" -" the file descriptor must refer to a directory.\n" -" If this functionality is unavailable, using it raises NotImplementedError.\n" -"\n" -"The list is in arbitrary order. It does not include the special\n" -"entries \'.\' and \'..\' even if they are present in the directory."); - -#define OS_LISTDIR_METHODDEF \ - {"listdir", (PyCFunction)os_listdir, METH_VARARGS|METH_KEYWORDS, os_listdir__doc__}, - -static PyObject * -os_listdir_impl(PyModuleDef *module, path_t *path); - -static PyObject * -os_listdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", NULL}; - path_t path = PATH_T_INITIALIZE("listdir", "path", 1, PATH_HAVE_FDOPENDIR); - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|O&:listdir", _keywords, - path_converter, &path)) - goto exit; - return_value = os_listdir_impl(module, &path); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_listdir_impl(PyModuleDef *module, path_t *path) -/*[clinic end generated code: output=e159bd9be6909018 input=09e300416e3cd729]*/ +/*[clinic end generated code: output=1fbe67c1f780c8b7 input=09e300416e3cd729]*/ { #if defined(MS_WINDOWS) && !defined(HAVE_OPENDIR) return _listdir_windows_no_opendir(path, NULL); @@ -4721,37 +3881,9 @@ os._getfinalpathname A helper function for samepath on windows. [clinic start generated code]*/ -PyDoc_STRVAR(os__getfinalpathname__doc__, -"_getfinalpathname($module, path, /)\n" -"--\n" -"\n" -"A helper function for samepath on windows."); - -#define OS__GETFINALPATHNAME_METHODDEF \ - {"_getfinalpathname", (PyCFunction)os__getfinalpathname, METH_VARARGS, os__getfinalpathname__doc__}, - -static PyObject * -os__getfinalpathname_impl(PyModuleDef *module, PyObject *path); - -static PyObject * -os__getfinalpathname(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *path; - - if (!PyArg_ParseTuple(args, - "U:_getfinalpathname", - &path)) - goto exit; - return_value = os__getfinalpathname_impl(module, path); - -exit: - return return_value; -} - static PyObject * os__getfinalpathname_impl(PyModuleDef *module, PyObject *path) -/*[clinic end generated code: output=4563c6eacf1b0881 input=71d5e89334891bf4]*/ +/*[clinic end generated code: output=8be81a5f51a34bcf input=71d5e89334891bf4]*/ { HANDLE hFile; int buf_size; @@ -4858,38 +3990,9 @@ os._getvolumepathname A helper function for ismount on Win32. [clinic start generated code]*/ -PyDoc_STRVAR(os__getvolumepathname__doc__, -"_getvolumepathname($module, /, path)\n" -"--\n" -"\n" -"A helper function for ismount on Win32."); - -#define OS__GETVOLUMEPATHNAME_METHODDEF \ - {"_getvolumepathname", (PyCFunction)os__getvolumepathname, METH_VARARGS|METH_KEYWORDS, os__getvolumepathname__doc__}, - -static PyObject * -os__getvolumepathname_impl(PyModuleDef *module, PyObject *path); - -static PyObject * -os__getvolumepathname(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", NULL}; - PyObject *path; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "U:_getvolumepathname", _keywords, - &path)) - goto exit; - return_value = os__getvolumepathname_impl(module, path); - -exit: - return return_value; -} - static PyObject * os__getvolumepathname_impl(PyModuleDef *module, PyObject *path) -/*[clinic end generated code: output=ac0833b6d6da7657 input=7eacadc40acbda6b]*/ +/*[clinic end generated code: output=79a0ba729f956dbe input=7eacadc40acbda6b]*/ { PyObject *result; wchar_t *path_wchar, *mountpath=NULL; @@ -4955,50 +4058,9 @@ dir_fd may not be implemented on your pl The mode argument is ignored on Windows. [clinic start generated code]*/ -PyDoc_STRVAR(os_mkdir__doc__, -"mkdir($module, /, path, mode=511, *, dir_fd=None)\n" -"--\n" -"\n" -"Create a directory.\n" -"\n" -"If dir_fd is not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that directory.\n" -"dir_fd may not be implemented on your platform.\n" -" If it is unavailable, using it will raise a NotImplementedError.\n" -"\n" -"The mode argument is ignored on Windows."); - -#define OS_MKDIR_METHODDEF \ - {"mkdir", (PyCFunction)os_mkdir, METH_VARARGS|METH_KEYWORDS, os_mkdir__doc__}, - -static PyObject * -os_mkdir_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd); - -static PyObject * -os_mkdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "mode", "dir_fd", NULL}; - path_t path = PATH_T_INITIALIZE("mkdir", "path", 0, 0); - int mode = 511; - int dir_fd = DEFAULT_DIR_FD; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&|i$O&:mkdir", _keywords, - path_converter, &path, &mode, MKDIRAT_DIR_FD_CONVERTER, &dir_fd)) - goto exit; - return_value = os_mkdir_impl(module, &path, mode, dir_fd); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_mkdir_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd) -/*[clinic end generated code: output=55c6ef2bc1b207e6 input=e965f68377e9b1ce]*/ +/*[clinic end generated code: output=8bf1f738873ef2c5 input=e965f68377e9b1ce]*/ { int result; @@ -5048,37 +4110,9 @@ os.nice Add increment to the priority of process and return the new priority. [clinic start generated code]*/ -PyDoc_STRVAR(os_nice__doc__, -"nice($module, increment, /)\n" -"--\n" -"\n" -"Add increment to the priority of process and return the new priority."); - -#define OS_NICE_METHODDEF \ - {"nice", (PyCFunction)os_nice, METH_VARARGS, os_nice__doc__}, - -static PyObject * -os_nice_impl(PyModuleDef *module, int increment); - -static PyObject * -os_nice(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int increment; - - if (!PyArg_ParseTuple(args, - "i:nice", - &increment)) - goto exit; - return_value = os_nice_impl(module, increment); - -exit: - return return_value; -} - static PyObject * os_nice_impl(PyModuleDef *module, int increment) -/*[clinic end generated code: output=c360dc2a3bd8e3d0 input=864be2d402a21da2]*/ +/*[clinic end generated code: output=8870418a3fc07b51 input=864be2d402a21da2]*/ { int value; @@ -5116,39 +4150,9 @@ os.getpriority Return program scheduling priority. [clinic start generated code]*/ -PyDoc_STRVAR(os_getpriority__doc__, -"getpriority($module, /, which, who)\n" -"--\n" -"\n" -"Return program scheduling priority."); - -#define OS_GETPRIORITY_METHODDEF \ - {"getpriority", (PyCFunction)os_getpriority, METH_VARARGS|METH_KEYWORDS, os_getpriority__doc__}, - -static PyObject * -os_getpriority_impl(PyModuleDef *module, int which, int who); - -static PyObject * -os_getpriority(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"which", "who", NULL}; - int which; - int who; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "ii:getpriority", _keywords, - &which, &who)) - goto exit; - return_value = os_getpriority_impl(module, which, who); - -exit: - return return_value; -} - static PyObject * os_getpriority_impl(PyModuleDef *module, int which, int who) -/*[clinic end generated code: output=81639cf765f05dae input=9be615d40e2544ef]*/ +/*[clinic end generated code: output=4759937aa5b67ed6 input=9be615d40e2544ef]*/ { int retval; @@ -5172,40 +4176,9 @@ os.setpriority Set program scheduling priority. [clinic start generated code]*/ -PyDoc_STRVAR(os_setpriority__doc__, -"setpriority($module, /, which, who, priority)\n" -"--\n" -"\n" -"Set program scheduling priority."); - -#define OS_SETPRIORITY_METHODDEF \ - {"setpriority", (PyCFunction)os_setpriority, METH_VARARGS|METH_KEYWORDS, os_setpriority__doc__}, - -static PyObject * -os_setpriority_impl(PyModuleDef *module, int which, int who, int priority); - -static PyObject * -os_setpriority(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"which", "who", "priority", NULL}; - int which; - int who; - int priority; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "iii:setpriority", _keywords, - &which, &who, &priority)) - goto exit; - return_value = os_setpriority_impl(module, which, who, priority); - -exit: - return return_value; -} - static PyObject * os_setpriority_impl(PyModuleDef *module, int which, int who, int priority) -/*[clinic end generated code: output=ddad62651fb2120c input=710ccbf65b9dc513]*/ +/*[clinic end generated code: output=6497d3301547e7d5 input=710ccbf65b9dc513]*/ { int retval; @@ -5291,52 +4264,9 @@ src_dir_fd and dst_dir_fd, may not be im If they are unavailable, using them will raise a NotImplementedError. [clinic start generated code]*/ -PyDoc_STRVAR(os_rename__doc__, -"rename($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None)\n" -"--\n" -"\n" -"Rename a file or directory.\n" -"\n" -"If either src_dir_fd or dst_dir_fd is not None, it should be a file\n" -" descriptor open to a directory, and the respective path string (src or dst)\n" -" should be relative; the path will then be relative to that directory.\n" -"src_dir_fd and dst_dir_fd, may not be implemented on your platform.\n" -" If they are unavailable, using them will raise a NotImplementedError."); - -#define OS_RENAME_METHODDEF \ - {"rename", (PyCFunction)os_rename, METH_VARARGS|METH_KEYWORDS, os_rename__doc__}, - -static PyObject * -os_rename_impl(PyModuleDef *module, path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd); - -static PyObject * -os_rename(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; - path_t src = PATH_T_INITIALIZE("rename", "src", 0, 0); - path_t dst = PATH_T_INITIALIZE("rename", "dst", 0, 0); - int src_dir_fd = DEFAULT_DIR_FD; - int dst_dir_fd = DEFAULT_DIR_FD; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&O&|$O&O&:rename", _keywords, - path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd)) - goto exit; - return_value = os_rename_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); - -exit: - /* Cleanup for src */ - path_cleanup(&src); - /* Cleanup for dst */ - path_cleanup(&dst); - - return return_value; -} - static PyObject * os_rename_impl(PyModuleDef *module, path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd) -/*[clinic end generated code: output=c936bdc81f460a1e input=faa61c847912c850]*/ +/*[clinic end generated code: output=1bb520bf2fad186d input=faa61c847912c850]*/ { return internal_rename(src, dst, src_dir_fd, dst_dir_fd, 0); } @@ -5354,52 +4284,9 @@ src_dir_fd and dst_dir_fd, may not be im If they are unavailable, using them will raise a NotImplementedError." [clinic start generated code]*/ -PyDoc_STRVAR(os_replace__doc__, -"replace($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None)\n" -"--\n" -"\n" -"Rename a file or directory, overwriting the destination.\n" -"\n" -"If either src_dir_fd or dst_dir_fd is not None, it should be a file\n" -" descriptor open to a directory, and the respective path string (src or dst)\n" -" should be relative; the path will then be relative to that directory.\n" -"src_dir_fd and dst_dir_fd, may not be implemented on your platform.\n" -" If they are unavailable, using them will raise a NotImplementedError.\""); - -#define OS_REPLACE_METHODDEF \ - {"replace", (PyCFunction)os_replace, METH_VARARGS|METH_KEYWORDS, os_replace__doc__}, - -static PyObject * -os_replace_impl(PyModuleDef *module, path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd); - -static PyObject * -os_replace(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; - path_t src = PATH_T_INITIALIZE("replace", "src", 0, 0); - path_t dst = PATH_T_INITIALIZE("replace", "dst", 0, 0); - int src_dir_fd = DEFAULT_DIR_FD; - int dst_dir_fd = DEFAULT_DIR_FD; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&O&|$O&O&:replace", _keywords, - path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd)) - goto exit; - return_value = os_replace_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); - -exit: - /* Cleanup for src */ - path_cleanup(&src); - /* Cleanup for dst */ - path_cleanup(&dst); - - return return_value; -} - static PyObject * os_replace_impl(PyModuleDef *module, path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd) -/*[clinic end generated code: output=224e4710d290d171 input=25515dfb107c8421]*/ +/*[clinic end generated code: output=aa9ddad55fdef8e3 input=25515dfb107c8421]*/ { return internal_rename(src, dst, src_dir_fd, dst_dir_fd, 1); } @@ -5420,47 +4307,9 @@ dir_fd may not be implemented on your pl If it is unavailable, using it will raise a NotImplementedError. [clinic start generated code]*/ -PyDoc_STRVAR(os_rmdir__doc__, -"rmdir($module, /, path, *, dir_fd=None)\n" -"--\n" -"\n" -"Remove a directory.\n" -"\n" -"If dir_fd is not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that directory.\n" -"dir_fd may not be implemented on your platform.\n" -" If it is unavailable, using it will raise a NotImplementedError."); - -#define OS_RMDIR_METHODDEF \ - {"rmdir", (PyCFunction)os_rmdir, METH_VARARGS|METH_KEYWORDS, os_rmdir__doc__}, - -static PyObject * -os_rmdir_impl(PyModuleDef *module, path_t *path, int dir_fd); - -static PyObject * -os_rmdir(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "dir_fd", NULL}; - path_t path = PATH_T_INITIALIZE("rmdir", "path", 0, 0); - int dir_fd = DEFAULT_DIR_FD; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&|$O&:rmdir", _keywords, - path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) - goto exit; - return_value = os_rmdir_impl(module, &path, dir_fd); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_rmdir_impl(PyModuleDef *module, path_t *path, int dir_fd) -/*[clinic end generated code: output=70b9fdbe3bee0591 input=38c8b375ca34a7e2]*/ +/*[clinic end generated code: output=cabadec80d5a77c7 input=38c8b375ca34a7e2]*/ { int result; @@ -5498,42 +4347,9 @@ os.system -> long Execute the command in a subshell. [clinic start generated code]*/ -PyDoc_STRVAR(os_system__doc__, -"system($module, /, command)\n" -"--\n" -"\n" -"Execute the command in a subshell."); - -#define OS_SYSTEM_METHODDEF \ - {"system", (PyCFunction)os_system, METH_VARARGS|METH_KEYWORDS, os_system__doc__}, - -static long -os_system_impl(PyModuleDef *module, Py_UNICODE *command); - -static PyObject * -os_system(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"command", NULL}; - Py_UNICODE *command; - long _return_value; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "u:system", _keywords, - &command)) - goto exit; - _return_value = os_system_impl(module, command); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromLong(_return_value); - -exit: - return return_value; -} - static long os_system_impl(PyModuleDef *module, Py_UNICODE *command) -/*[clinic end generated code: output=29fe699c0b2e9d38 input=303f5ce97df606b0]*/ +/*[clinic end generated code: output=4c3bd5abcd9c29e7 input=303f5ce97df606b0]*/ { long result; Py_BEGIN_ALLOW_THREADS @@ -5550,45 +4366,9 @@ os.system -> long Execute the command in a subshell. [clinic start generated code]*/ -PyDoc_STRVAR(os_system__doc__, -"system($module, /, command)\n" -"--\n" -"\n" -"Execute the command in a subshell."); - -#define OS_SYSTEM_METHODDEF \ - {"system", (PyCFunction)os_system, METH_VARARGS|METH_KEYWORDS, os_system__doc__}, - -static long -os_system_impl(PyModuleDef *module, PyObject *command); - -static PyObject * -os_system(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"command", NULL}; - PyObject *command = NULL; - long _return_value; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&:system", _keywords, - PyUnicode_FSConverter, &command)) - goto exit; - _return_value = os_system_impl(module, command); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromLong(_return_value); - -exit: - /* Cleanup for command */ - Py_XDECREF(command); - - return return_value; -} - static long os_system_impl(PyModuleDef *module, PyObject *command) -/*[clinic end generated code: output=5be9f3c40ead3bad input=86a58554ba6094af]*/ +/*[clinic end generated code: output=800f775e10b7be55 input=86a58554ba6094af]*/ { long result; char *bytes = PyBytes_AsString(command); @@ -5610,37 +4390,9 @@ os.umask Set the current numeric umask and return the previous umask. [clinic start generated code]*/ -PyDoc_STRVAR(os_umask__doc__, -"umask($module, mask, /)\n" -"--\n" -"\n" -"Set the current numeric umask and return the previous umask."); - -#define OS_UMASK_METHODDEF \ - {"umask", (PyCFunction)os_umask, METH_VARARGS, os_umask__doc__}, - -static PyObject * -os_umask_impl(PyModuleDef *module, int mask); - -static PyObject * -os_umask(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int mask; - - if (!PyArg_ParseTuple(args, - "i:umask", - &mask)) - goto exit; - return_value = os_umask_impl(module, mask); - -exit: - return return_value; -} - static PyObject * os_umask_impl(PyModuleDef *module, int mask) -/*[clinic end generated code: output=90048b39d2d4a961 input=ab6bfd9b24d8a7e8]*/ +/*[clinic end generated code: output=9e1fe3c9f14d6a05 input=ab6bfd9b24d8a7e8]*/ { int i = (int)umask(mask); if (i < 0) @@ -5704,47 +4456,9 @@ dir_fd may not be implemented on your pl [clinic start generated code]*/ -PyDoc_STRVAR(os_unlink__doc__, -"unlink($module, /, path, *, dir_fd=None)\n" -"--\n" -"\n" -"Remove a file (same as remove()).\n" -"\n" -"If dir_fd is not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that directory.\n" -"dir_fd may not be implemented on your platform.\n" -" If it is unavailable, using it will raise a NotImplementedError."); - -#define OS_UNLINK_METHODDEF \ - {"unlink", (PyCFunction)os_unlink, METH_VARARGS|METH_KEYWORDS, os_unlink__doc__}, - -static PyObject * -os_unlink_impl(PyModuleDef *module, path_t *path, int dir_fd); - -static PyObject * -os_unlink(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "dir_fd", NULL}; - path_t path = PATH_T_INITIALIZE("unlink", "path", 0, 0); - int dir_fd = DEFAULT_DIR_FD; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&|$O&:unlink", _keywords, - path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) - goto exit; - return_value = os_unlink_impl(module, &path, dir_fd); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_unlink_impl(PyModuleDef *module, path_t *path, int dir_fd) -/*[clinic end generated code: output=59a6e66d67ff2e75 input=d7bcde2b1b2a2552]*/ +/*[clinic end generated code: output=474afd5cd09b237e input=d7bcde2b1b2a2552]*/ { int result; @@ -5783,47 +4497,9 @@ dir_fd may not be implemented on your pl If it is unavailable, using it will raise a NotImplementedError. [clinic start generated code]*/ -PyDoc_STRVAR(os_remove__doc__, -"remove($module, /, path, *, dir_fd=None)\n" -"--\n" -"\n" -"Remove a file (same as unlink()).\n" -"\n" -"If dir_fd is not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that directory.\n" -"dir_fd may not be implemented on your platform.\n" -" If it is unavailable, using it will raise a NotImplementedError."); - -#define OS_REMOVE_METHODDEF \ - {"remove", (PyCFunction)os_remove, METH_VARARGS|METH_KEYWORDS, os_remove__doc__}, - -static PyObject * -os_remove_impl(PyModuleDef *module, path_t *path, int dir_fd); - -static PyObject * -os_remove(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "dir_fd", NULL}; - path_t path = PATH_T_INITIALIZE("remove", "path", 0, 0); - int dir_fd = DEFAULT_DIR_FD; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&|$O&:remove", _keywords, - path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) - goto exit; - return_value = os_remove_impl(module, &path, dir_fd); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_remove_impl(PyModuleDef *module, path_t *path, int dir_fd) -/*[clinic end generated code: output=cb170cf1e195b8ed input=e05c5ab55cd30983]*/ +/*[clinic end generated code: output=d0d5149e64832b9e input=e05c5ab55cd30983]*/ { return os_unlink_impl(module, path, dir_fd); } @@ -5867,30 +4543,9 @@ The object behaves like a named tuple wi [clinic start generated code]*/ -PyDoc_STRVAR(os_uname__doc__, -"uname($module, /)\n" -"--\n" -"\n" -"Return an object identifying the current operating system.\n" -"\n" -"The object behaves like a named tuple with the following fields:\n" -" (sysname, nodename, release, version, machine)"); - -#define OS_UNAME_METHODDEF \ - {"uname", (PyCFunction)os_uname, METH_NOARGS, os_uname__doc__}, - -static PyObject * -os_uname_impl(PyModuleDef *module); - -static PyObject * -os_uname(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_uname_impl(module); -} - static PyObject * os_uname_impl(PyModuleDef *module) -/*[clinic end generated code: output=459a86521ff5041c input=e68bd246db3043ed]*/ +/*[clinic end generated code: output=01e1421b757e753f input=e68bd246db3043ed]*/ { struct utsname u; int res; @@ -6142,73 +4797,9 @@ dir_fd and follow_symlinks may not be av [clinic start generated code]*/ -PyDoc_STRVAR(os_utime__doc__, -"utime($module, /, path, times=None, *, ns=None, dir_fd=None,\n" -" follow_symlinks=True)\n" -"--\n" -"\n" -"Set the access and modified time of path.\n" -"\n" -"path may always be specified as a string.\n" -"On some platforms, path may also be specified as an open file descriptor.\n" -" If this functionality is unavailable, using it raises an exception.\n" -"\n" -"If times is not None, it must be a tuple (atime, mtime);\n" -" atime and mtime should be expressed as float seconds since the epoch.\n" -"If ns is not None, it must be a tuple (atime_ns, mtime_ns);\n" -" atime_ns and mtime_ns should be expressed as integer nanoseconds\n" -" since the epoch.\n" -"If both times and ns are None, utime uses the current time.\n" -"Specifying tuples for both times and ns is an error.\n" -"\n" -"If dir_fd is not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that directory.\n" -"If follow_symlinks is False, and the last element of the path is a symbolic\n" -" link, utime will modify the symbolic link itself instead of the file the\n" -" link points to.\n" -"It is an error to use dir_fd or follow_symlinks when specifying path\n" -" as an open file descriptor.\n" -"dir_fd and follow_symlinks may not be available on your platform.\n" -" If they are unavailable, using them will raise a NotImplementedError."); - -#define OS_UTIME_METHODDEF \ - {"utime", (PyCFunction)os_utime, METH_VARARGS|METH_KEYWORDS, os_utime__doc__}, - -static PyObject * -os_utime_impl(PyModuleDef *module, path_t *path, PyObject *times, PyObject *ns, int dir_fd, int follow_symlinks); - -static PyObject * -os_utime(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "times", "ns", "dir_fd", "follow_symlinks", NULL}; - path_t path = PATH_T_INITIALIZE("utime", "path", 0, PATH_UTIME_HAVE_FD); - PyObject *times = NULL; - PyObject *ns = NULL; - int dir_fd = DEFAULT_DIR_FD; - int follow_symlinks = 1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&|O$OO&p:utime", _keywords, - path_converter, &path, ×, &ns, FUTIMENSAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) - goto exit; - return_value = os_utime_impl(module, &path, times, ns, dir_fd, follow_symlinks); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - -#ifdef MS_WINDOWS -void -_Py_time_t_to_FILE_TIME(time_t time_in, int nsec_in, FILETIME *out_ptr); -#endif - static PyObject * os_utime_impl(PyModuleDef *module, path_t *path, PyObject *times, PyObject *ns, int dir_fd, int follow_symlinks) -/*[clinic end generated code: output=891489c35cc68c5d input=1f18c17d5941aa82]*/ +/*[clinic end generated code: output=c52d8fd0d1067f0b input=1f18c17d5941aa82]*/ { #ifdef MS_WINDOWS HANDLE hFile; @@ -6375,38 +4966,9 @@ os._exit Exit to the system with specified status, without normal exit processing. [clinic start generated code]*/ -PyDoc_STRVAR(os__exit__doc__, -"_exit($module, /, status)\n" -"--\n" -"\n" -"Exit to the system with specified status, without normal exit processing."); - -#define OS__EXIT_METHODDEF \ - {"_exit", (PyCFunction)os__exit, METH_VARARGS|METH_KEYWORDS, os__exit__doc__}, - -static PyObject * -os__exit_impl(PyModuleDef *module, int status); - -static PyObject * -os__exit(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"status", NULL}; - int status; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:_exit", _keywords, - &status)) - goto exit; - return_value = os__exit_impl(module, status); - -exit: - return return_value; -} - static PyObject * os__exit_impl(PyModuleDef *module, int status) -/*[clinic end generated code: output=4f9858c4cc2dcb89 input=5e6d57556b0c4a62]*/ +/*[clinic end generated code: output=472a3cbaf68f3621 input=5e6d57556b0c4a62]*/ { _exit(status); return NULL; /* Make gcc -Wall happy */ @@ -6560,46 +5122,9 @@ os.execv Execute an executable path with arguments, replacing current process. [clinic start generated code]*/ -PyDoc_STRVAR(os_execv__doc__, -"execv($module, path, argv, /)\n" -"--\n" -"\n" -"Execute an executable path with arguments, replacing current process.\n" -"\n" -" path\n" -" Path of executable file.\n" -" argv\n" -" Tuple or list of strings."); - -#define OS_EXECV_METHODDEF \ - {"execv", (PyCFunction)os_execv, METH_VARARGS, os_execv__doc__}, - -static PyObject * -os_execv_impl(PyModuleDef *module, PyObject *path, PyObject *argv); - -static PyObject * -os_execv(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *path = NULL; - PyObject *argv; - - if (!PyArg_ParseTuple(args, - "O&O:execv", - PyUnicode_FSConverter, &path, &argv)) - goto exit; - return_value = os_execv_impl(module, path, argv); - -exit: - /* Cleanup for path */ - Py_XDECREF(path); - - return return_value; -} - static PyObject * os_execv_impl(PyModuleDef *module, PyObject *path, PyObject *argv) -/*[clinic end generated code: output=b0f5f2caa6097edc input=96041559925e5229]*/ +/*[clinic end generated code: output=9221f08143146fff input=96041559925e5229]*/ { char *path_char; char **argvlist; @@ -6647,50 +5172,9 @@ os.execve Execute an executable path with arguments, replacing current process. [clinic start generated code]*/ -PyDoc_STRVAR(os_execve__doc__, -"execve($module, /, path, argv, env)\n" -"--\n" -"\n" -"Execute an executable path with arguments, replacing current process.\n" -"\n" -" path\n" -" Path of executable file.\n" -" argv\n" -" Tuple or list of strings.\n" -" env\n" -" Dictionary of strings mapping to strings."); - -#define OS_EXECVE_METHODDEF \ - {"execve", (PyCFunction)os_execve, METH_VARARGS|METH_KEYWORDS, os_execve__doc__}, - -static PyObject * -os_execve_impl(PyModuleDef *module, path_t *path, PyObject *argv, PyObject *env); - -static PyObject * -os_execve(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "argv", "env", NULL}; - path_t path = PATH_T_INITIALIZE("execve", "path", 0, PATH_HAVE_FEXECVE); - PyObject *argv; - PyObject *env; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&OO:execve", _keywords, - path_converter, &path, &argv, &env)) - goto exit; - return_value = os_execve_impl(module, &path, argv, env); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_execve_impl(PyModuleDef *module, path_t *path, PyObject *argv, PyObject *env) -/*[clinic end generated code: output=fb283760f5d15ab7 input=626804fa092606d9]*/ +/*[clinic end generated code: output=7758d4f230d8aac6 input=626804fa092606d9]*/ { char **argvlist = NULL; char **envlist; @@ -6758,49 +5242,9 @@ os.spawnv Execute the program specified by path in a new process. [clinic start generated code]*/ -PyDoc_STRVAR(os_spawnv__doc__, -"spawnv($module, mode, path, argv, /)\n" -"--\n" -"\n" -"Execute the program specified by path in a new process.\n" -"\n" -" mode\n" -" Mode of process creation.\n" -" path\n" -" Path of executable file.\n" -" argv\n" -" Tuple or list of strings."); - -#define OS_SPAWNV_METHODDEF \ - {"spawnv", (PyCFunction)os_spawnv, METH_VARARGS, os_spawnv__doc__}, - -static PyObject * -os_spawnv_impl(PyModuleDef *module, int mode, PyObject *path, PyObject *argv); - -static PyObject * -os_spawnv(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int mode; - PyObject *path = NULL; - PyObject *argv; - - if (!PyArg_ParseTuple(args, - "iO&O:spawnv", - &mode, PyUnicode_FSConverter, &path, &argv)) - goto exit; - return_value = os_spawnv_impl(module, mode, path, argv); - -exit: - /* Cleanup for path */ - Py_XDECREF(path); - - return return_value; -} - static PyObject * os_spawnv_impl(PyModuleDef *module, int mode, PyObject *path, PyObject *argv) -/*[clinic end generated code: output=dfee6be062e780e3 input=042c91dfc1e6debc]*/ +/*[clinic end generated code: output=140a7945484c8cc5 input=042c91dfc1e6debc]*/ { char *path_char; char **argvlist; @@ -6875,52 +5319,9 @@ os.spawnve Execute the program specified by path in a new process. [clinic start generated code]*/ -PyDoc_STRVAR(os_spawnve__doc__, -"spawnve($module, mode, path, argv, env, /)\n" -"--\n" -"\n" -"Execute the program specified by path in a new process.\n" -"\n" -" mode\n" -" Mode of process creation.\n" -" path\n" -" Path of executable file.\n" -" argv\n" -" Tuple or list of strings.\n" -" env\n" -" Dictionary of strings mapping to strings."); - -#define OS_SPAWNVE_METHODDEF \ - {"spawnve", (PyCFunction)os_spawnve, METH_VARARGS, os_spawnve__doc__}, - -static PyObject * -os_spawnve_impl(PyModuleDef *module, int mode, PyObject *path, PyObject *argv, PyObject *env); - -static PyObject * -os_spawnve(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int mode; - PyObject *path = NULL; - PyObject *argv; - PyObject *env; - - if (!PyArg_ParseTuple(args, - "iO&OO:spawnve", - &mode, PyUnicode_FSConverter, &path, &argv, &env)) - goto exit; - return_value = os_spawnve_impl(module, mode, path, argv, env); - -exit: - /* Cleanup for path */ - Py_XDECREF(path); - - return return_value; -} - static PyObject * os_spawnve_impl(PyModuleDef *module, int mode, PyObject *path, PyObject *argv, PyObject *env) -/*[clinic end generated code: output=6f7df38473f63c7c input=02362fd937963f8f]*/ +/*[clinic end generated code: output=1c52955789461be8 input=02362fd937963f8f]*/ { char *path_char; char **argvlist; @@ -7008,29 +5409,9 @@ Fork a child process with a single multi Return 0 to child process and PID of child to parent process. [clinic start generated code]*/ -PyDoc_STRVAR(os_fork1__doc__, -"fork1($module, /)\n" -"--\n" -"\n" -"Fork a child process with a single multiplexed (i.e., not bound) thread.\n" -"\n" -"Return 0 to child process and PID of child to parent process."); - -#define OS_FORK1_METHODDEF \ - {"fork1", (PyCFunction)os_fork1, METH_NOARGS, os_fork1__doc__}, - -static PyObject * -os_fork1_impl(PyModuleDef *module); - -static PyObject * -os_fork1(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_fork1_impl(module); -} - static PyObject * os_fork1_impl(PyModuleDef *module) -/*[clinic end generated code: output=fa04088d6bc02efa input=12db02167893926e]*/ +/*[clinic end generated code: output=e27b4f66419c9dcf input=12db02167893926e]*/ { pid_t pid; int result = 0; @@ -7065,29 +5446,9 @@ Fork a child process. Return 0 to child process and PID of child to parent process. [clinic start generated code]*/ -PyDoc_STRVAR(os_fork__doc__, -"fork($module, /)\n" -"--\n" -"\n" -"Fork a child process.\n" -"\n" -"Return 0 to child process and PID of child to parent process."); - -#define OS_FORK_METHODDEF \ - {"fork", (PyCFunction)os_fork, METH_NOARGS, os_fork__doc__}, - -static PyObject * -os_fork_impl(PyModuleDef *module); - -static PyObject * -os_fork(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_fork_impl(module); -} - static PyObject * os_fork_impl(PyModuleDef *module) -/*[clinic end generated code: output=b3c8e6bdc11eedc6 input=13c956413110eeaa]*/ +/*[clinic end generated code: output=898b1ecd3498ba12 input=13c956413110eeaa]*/ { pid_t pid; int result = 0; @@ -7123,38 +5484,9 @@ os.sched_get_priority_max Get the maximum scheduling priority for policy. [clinic start generated code]*/ -PyDoc_STRVAR(os_sched_get_priority_max__doc__, -"sched_get_priority_max($module, /, policy)\n" -"--\n" -"\n" -"Get the maximum scheduling priority for policy."); - -#define OS_SCHED_GET_PRIORITY_MAX_METHODDEF \ - {"sched_get_priority_max", (PyCFunction)os_sched_get_priority_max, METH_VARARGS|METH_KEYWORDS, os_sched_get_priority_max__doc__}, - -static PyObject * -os_sched_get_priority_max_impl(PyModuleDef *module, int policy); - -static PyObject * -os_sched_get_priority_max(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"policy", NULL}; - int policy; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:sched_get_priority_max", _keywords, - &policy)) - goto exit; - return_value = os_sched_get_priority_max_impl(module, policy); - -exit: - return return_value; -} - static PyObject * os_sched_get_priority_max_impl(PyModuleDef *module, int policy) -/*[clinic end generated code: output=a580a52f25238c1f input=2097b7998eca6874]*/ +/*[clinic end generated code: output=a6a30fa5071f2d81 input=2097b7998eca6874]*/ { int max; @@ -7173,38 +5505,9 @@ os.sched_get_priority_min Get the minimum scheduling priority for policy. [clinic start generated code]*/ -PyDoc_STRVAR(os_sched_get_priority_min__doc__, -"sched_get_priority_min($module, /, policy)\n" -"--\n" -"\n" -"Get the minimum scheduling priority for policy."); - -#define OS_SCHED_GET_PRIORITY_MIN_METHODDEF \ - {"sched_get_priority_min", (PyCFunction)os_sched_get_priority_min, METH_VARARGS|METH_KEYWORDS, os_sched_get_priority_min__doc__}, - -static PyObject * -os_sched_get_priority_min_impl(PyModuleDef *module, int policy); - -static PyObject * -os_sched_get_priority_min(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"policy", NULL}; - int policy; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:sched_get_priority_min", _keywords, - &policy)) - goto exit; - return_value = os_sched_get_priority_min_impl(module, policy); - -exit: - return return_value; -} - static PyObject * os_sched_get_priority_min_impl(PyModuleDef *module, int policy) -/*[clinic end generated code: output=bad8ba10e7d0e977 input=21bc8fa0d70983bf]*/ +/*[clinic end generated code: output=5ca3ed6bc43e9b20 input=21bc8fa0d70983bf]*/ { int min = sched_get_priority_min(policy); if (min < 0) @@ -7225,39 +5528,9 @@ Get the scheduling policy for the proces Passing 0 for pid returns the scheduling policy for the calling process. [clinic start generated code]*/ -PyDoc_STRVAR(os_sched_getscheduler__doc__, -"sched_getscheduler($module, pid, /)\n" -"--\n" -"\n" -"Get the scheduling policy for the process identifiedy by pid.\n" -"\n" -"Passing 0 for pid returns the scheduling policy for the calling process."); - -#define OS_SCHED_GETSCHEDULER_METHODDEF \ - {"sched_getscheduler", (PyCFunction)os_sched_getscheduler, METH_VARARGS, os_sched_getscheduler__doc__}, - -static PyObject * -os_sched_getscheduler_impl(PyModuleDef *module, pid_t pid); - -static PyObject * -os_sched_getscheduler(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - pid_t pid; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_PID ":sched_getscheduler", - &pid)) - goto exit; - return_value = os_sched_getscheduler_impl(module, pid); - -exit: - return return_value; -} - static PyObject * os_sched_getscheduler_impl(PyModuleDef *module, pid_t pid) -/*[clinic end generated code: output=e0d6244207b1d828 input=5f14cfd1f189e1a0]*/ +/*[clinic end generated code: output=8cd63c15caf54fa9 input=5f14cfd1f189e1a0]*/ { int policy; @@ -7282,38 +5555,9 @@ os.sched_param.__new__ Current has only one field: sched_priority"); [clinic start generated code]*/ -PyDoc_STRVAR(os_sched_param__doc__, -"sched_param(sched_priority)\n" -"--\n" -"\n" -"Current has only one field: sched_priority\");\n" -"\n" -" sched_priority\n" -" A scheduling parameter."); - -static PyObject * -os_sched_param_impl(PyTypeObject *type, PyObject *sched_priority); - -static PyObject * -os_sched_param(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"sched_priority", NULL}; - PyObject *sched_priority; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:sched_param", _keywords, - &sched_priority)) - goto exit; - return_value = os_sched_param_impl(type, sched_priority); - -exit: - return return_value; -} - static PyObject * os_sched_param_impl(PyTypeObject *type, PyObject *sched_priority) -/*[clinic end generated code: output=d3791e345f7fe573 input=73a4c22f7071fc62]*/ +/*[clinic end generated code: output=48f4067d60f48c13 input=73a4c22f7071fc62]*/ { PyObject *res; @@ -7326,6 +5570,8 @@ os_sched_param_impl(PyTypeObject *type, } +PyDoc_VAR(os_sched_param__doc__); + static PyStructSequence_Field sched_param_fields[] = { {"sched_priority", "the scheduling priority"}, {0} @@ -7375,42 +5621,9 @@ If pid is 0, the calling process is chan param is an instance of sched_param. [clinic start generated code]*/ -PyDoc_STRVAR(os_sched_setscheduler__doc__, -"sched_setscheduler($module, pid, policy, param, /)\n" -"--\n" -"\n" -"Set the scheduling policy for the process identified by pid.\n" -"\n" -"If pid is 0, the calling process is changed.\n" -"param is an instance of sched_param."); - -#define OS_SCHED_SETSCHEDULER_METHODDEF \ - {"sched_setscheduler", (PyCFunction)os_sched_setscheduler, METH_VARARGS, os_sched_setscheduler__doc__}, - -static PyObject * -os_sched_setscheduler_impl(PyModuleDef *module, pid_t pid, int policy, struct sched_param *param); - -static PyObject * -os_sched_setscheduler(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - pid_t pid; - int policy; - struct sched_param param; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_PID "iO&:sched_setscheduler", - &pid, &policy, convert_sched_param, ¶m)) - goto exit; - return_value = os_sched_setscheduler_impl(module, pid, policy, ¶m); - -exit: - return return_value; -} - static PyObject * os_sched_setscheduler_impl(PyModuleDef *module, pid_t pid, int policy, struct sched_param *param) -/*[clinic end generated code: output=36abdb73f81c224f input=c581f9469a5327dd]*/ +/*[clinic end generated code: output=97f40f8384e554b0 input=c581f9469a5327dd]*/ { /* ** sched_setscheduler() returns 0 in Linux, but the previous @@ -7436,40 +5649,9 @@ If pid is 0, returns parameters for the Return value is an instance of sched_param. [clinic start generated code]*/ -PyDoc_STRVAR(os_sched_getparam__doc__, -"sched_getparam($module, pid, /)\n" -"--\n" -"\n" -"Returns scheduling parameters for the process identified by pid.\n" -"\n" -"If pid is 0, returns parameters for the calling process.\n" -"Return value is an instance of sched_param."); - -#define OS_SCHED_GETPARAM_METHODDEF \ - {"sched_getparam", (PyCFunction)os_sched_getparam, METH_VARARGS, os_sched_getparam__doc__}, - -static PyObject * -os_sched_getparam_impl(PyModuleDef *module, pid_t pid); - -static PyObject * -os_sched_getparam(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - pid_t pid; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_PID ":sched_getparam", - &pid)) - goto exit; - return_value = os_sched_getparam_impl(module, pid); - -exit: - return return_value; -} - static PyObject * os_sched_getparam_impl(PyModuleDef *module, pid_t pid) -/*[clinic end generated code: output=b33acc8db004a8c9 input=18a1ef9c2efae296]*/ +/*[clinic end generated code: output=f42c5bd2604ecd08 input=18a1ef9c2efae296]*/ { struct sched_param param; PyObject *result; @@ -7502,41 +5684,9 @@ If pid is 0, sets parameters for the cal param should be an instance of sched_param. [clinic start generated code]*/ -PyDoc_STRVAR(os_sched_setparam__doc__, -"sched_setparam($module, pid, param, /)\n" -"--\n" -"\n" -"Set scheduling parameters for the process identified by pid.\n" -"\n" -"If pid is 0, sets parameters for the calling process.\n" -"param should be an instance of sched_param."); - -#define OS_SCHED_SETPARAM_METHODDEF \ - {"sched_setparam", (PyCFunction)os_sched_setparam, METH_VARARGS, os_sched_setparam__doc__}, - -static PyObject * -os_sched_setparam_impl(PyModuleDef *module, pid_t pid, struct sched_param *param); - -static PyObject * -os_sched_setparam(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - pid_t pid; - struct sched_param param; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_PID "O&:sched_setparam", - &pid, convert_sched_param, ¶m)) - goto exit; - return_value = os_sched_setparam_impl(module, pid, ¶m); - -exit: - return return_value; -} - static PyObject * os_sched_setparam_impl(PyModuleDef *module, pid_t pid, struct sched_param *param) -/*[clinic end generated code: output=488bdf5bcbe0d4e8 input=6b8d6dfcecdc21bd]*/ +/*[clinic end generated code: output=c6560b34395bb343 input=6b8d6dfcecdc21bd]*/ { if (sched_setparam(pid, param)) return posix_error(); @@ -7556,43 +5706,9 @@ Return the round-robin quantum for the p Value returned is a float. [clinic start generated code]*/ -PyDoc_STRVAR(os_sched_rr_get_interval__doc__, -"sched_rr_get_interval($module, pid, /)\n" -"--\n" -"\n" -"Return the round-robin quantum for the process identified by pid, in seconds.\n" -"\n" -"Value returned is a float."); - -#define OS_SCHED_RR_GET_INTERVAL_METHODDEF \ - {"sched_rr_get_interval", (PyCFunction)os_sched_rr_get_interval, METH_VARARGS, os_sched_rr_get_interval__doc__}, - -static double -os_sched_rr_get_interval_impl(PyModuleDef *module, pid_t pid); - -static PyObject * -os_sched_rr_get_interval(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - pid_t pid; - double _return_value; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_PID ":sched_rr_get_interval", - &pid)) - goto exit; - _return_value = os_sched_rr_get_interval_impl(module, pid); - if ((_return_value == -1.0) && PyErr_Occurred()) - goto exit; - return_value = PyFloat_FromDouble(_return_value); - -exit: - return return_value; -} - static double os_sched_rr_get_interval_impl(PyModuleDef *module, pid_t pid) -/*[clinic end generated code: output=5b3b8d1f27fb2c0a input=2a973da15cca6fae]*/ +/*[clinic end generated code: output=7adc137a86dea581 input=2a973da15cca6fae]*/ { struct timespec interval; if (sched_rr_get_interval(pid, &interval)) { @@ -7610,27 +5726,9 @@ os.sched_yield Voluntarily relinquish the CPU. [clinic start generated code]*/ -PyDoc_STRVAR(os_sched_yield__doc__, -"sched_yield($module, /)\n" -"--\n" -"\n" -"Voluntarily relinquish the CPU."); - -#define OS_SCHED_YIELD_METHODDEF \ - {"sched_yield", (PyCFunction)os_sched_yield, METH_NOARGS, os_sched_yield__doc__}, - -static PyObject * -os_sched_yield_impl(PyModuleDef *module); - -static PyObject * -os_sched_yield(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_sched_yield_impl(module); -} - static PyObject * os_sched_yield_impl(PyModuleDef *module) -/*[clinic end generated code: output=9d2e5f29f1370324 input=e54d6f98189391d4]*/ +/*[clinic end generated code: output=d7bd51869c4cb6a8 input=e54d6f98189391d4]*/ { if (sched_yield()) return posix_error(); @@ -7652,40 +5750,9 @@ Set the CPU affinity of the process iden mask should be an iterable of integers identifying CPUs. [clinic start generated code]*/ -PyDoc_STRVAR(os_sched_setaffinity__doc__, -"sched_setaffinity($module, pid, mask, /)\n" -"--\n" -"\n" -"Set the CPU affinity of the process identified by pid to mask.\n" -"\n" -"mask should be an iterable of integers identifying CPUs."); - -#define OS_SCHED_SETAFFINITY_METHODDEF \ - {"sched_setaffinity", (PyCFunction)os_sched_setaffinity, METH_VARARGS, os_sched_setaffinity__doc__}, - -static PyObject * -os_sched_setaffinity_impl(PyModuleDef *module, pid_t pid, PyObject *mask); - -static PyObject * -os_sched_setaffinity(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - pid_t pid; - PyObject *mask; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_PID "O:sched_setaffinity", - &pid, &mask)) - goto exit; - return_value = os_sched_setaffinity_impl(module, pid, mask); - -exit: - return return_value; -} - static PyObject * os_sched_setaffinity_impl(PyModuleDef *module, pid_t pid, PyObject *mask) -/*[clinic end generated code: output=5199929738130196 input=a0791a597c7085ba]*/ +/*[clinic end generated code: output=582bcbf40d3253a9 input=a0791a597c7085ba]*/ { int ncpus; size_t setsize; @@ -7779,39 +5846,9 @@ Return the affinity of the process ident The affinity is returned as a set of CPU identifiers. [clinic start generated code]*/ -PyDoc_STRVAR(os_sched_getaffinity__doc__, -"sched_getaffinity($module, pid, /)\n" -"--\n" -"\n" -"Return the affinity of the process identified by pid.\n" -"\n" -"The affinity is returned as a set of CPU identifiers."); - -#define OS_SCHED_GETAFFINITY_METHODDEF \ - {"sched_getaffinity", (PyCFunction)os_sched_getaffinity, METH_VARARGS, os_sched_getaffinity__doc__}, - -static PyObject * -os_sched_getaffinity_impl(PyModuleDef *module, pid_t pid); - -static PyObject * -os_sched_getaffinity(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - pid_t pid; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_PID ":sched_getaffinity", - &pid)) - goto exit; - return_value = os_sched_getaffinity_impl(module, pid); - -exit: - return return_value; -} - static PyObject * os_sched_getaffinity_impl(PyModuleDef *module, pid_t pid) -/*[clinic end generated code: output=7b273b0fca9830f0 input=eaf161936874b8a1]*/ +/*[clinic end generated code: output=b431a8f310e369e7 input=eaf161936874b8a1]*/ { int cpu, ncpus, count; size_t setsize; @@ -7867,46 +5904,6 @@ error: #endif /* HAVE_SCHED_H */ -#ifndef OS_SCHED_GET_PRIORITY_MAX_METHODDEF -#define OS_SCHED_GET_PRIORITY_MAX_METHODDEF -#endif /* OS_SCHED_GET_PRIORITY_MAX_METHODDEF */ - -#ifndef OS_SCHED_GET_PRIORITY_MIN_METHODDEF -#define OS_SCHED_GET_PRIORITY_MIN_METHODDEF -#endif /* OS_SCHED_GET_PRIORITY_MIN_METHODDEF */ - -#ifndef OS_SCHED_GETSCHEDULER_METHODDEF -#define OS_SCHED_GETSCHEDULER_METHODDEF -#endif /* OS_SCHED_GETSCHEDULER_METHODDEF */ - -#ifndef OS_SCHED_SETSCHEDULER_METHODDEF -#define OS_SCHED_SETSCHEDULER_METHODDEF -#endif /* OS_SCHED_SETSCHEDULER_METHODDEF */ - -#ifndef OS_SCHED_GETPARAM_METHODDEF -#define OS_SCHED_GETPARAM_METHODDEF -#endif /* OS_SCHED_GETPARAM_METHODDEF */ - -#ifndef OS_SCHED_SETPARAM_METHODDEF -#define OS_SCHED_SETPARAM_METHODDEF -#endif /* OS_SCHED_SETPARAM_METHODDEF */ - -#ifndef OS_SCHED_RR_GET_INTERVAL_METHODDEF -#define OS_SCHED_RR_GET_INTERVAL_METHODDEF -#endif /* OS_SCHED_RR_GET_INTERVAL_METHODDEF */ - -#ifndef OS_SCHED_YIELD_METHODDEF -#define OS_SCHED_YIELD_METHODDEF -#endif /* OS_SCHED_YIELD_METHODDEF */ - -#ifndef OS_SCHED_SETAFFINITY_METHODDEF -#define OS_SCHED_SETAFFINITY_METHODDEF -#endif /* OS_SCHED_SETAFFINITY_METHODDEF */ - -#ifndef OS_SCHED_GETAFFINITY_METHODDEF -#define OS_SCHED_GETAFFINITY_METHODDEF -#endif /* OS_SCHED_GETAFFINITY_METHODDEF */ - /* AIX uses /dev/ptc but is otherwise the same as /dev/ptmx */ /* IRIX has both /dev/ptc and /dev/ptmx, use ptmx */ @@ -7945,30 +5942,9 @@ Return a tuple of (master_fd, slave_fd) for both the master and slave ends. [clinic start generated code]*/ -PyDoc_STRVAR(os_openpty__doc__, -"openpty($module, /)\n" -"--\n" -"\n" -"Open a pseudo-terminal.\n" -"\n" -"Return a tuple of (master_fd, slave_fd) containing open file descriptors\n" -"for both the master and slave ends."); - -#define OS_OPENPTY_METHODDEF \ - {"openpty", (PyCFunction)os_openpty, METH_NOARGS, os_openpty__doc__}, - -static PyObject * -os_openpty_impl(PyModuleDef *module); - -static PyObject * -os_openpty(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_openpty_impl(module); -} - static PyObject * os_openpty_impl(PyModuleDef *module) -/*[clinic end generated code: output=b12d3c1735468464 input=f3d99fd99e762907]*/ +/*[clinic end generated code: output=358e571c1ba135ee input=f3d99fd99e762907]*/ { int master_fd = -1, slave_fd = -1; #ifndef HAVE_OPENPTY @@ -8070,32 +6046,9 @@ and pid of child to the parent process. To both, return fd of newly opened pseudo-terminal. [clinic start generated code]*/ -PyDoc_STRVAR(os_forkpty__doc__, -"forkpty($module, /)\n" -"--\n" -"\n" -"Fork a new process with a new pseudo-terminal as controlling tty.\n" -"\n" -"Returns a tuple of (pid, master_fd).\n" -"Like fork(), return pid of 0 to the child process,\n" -"and pid of child to the parent process.\n" -"To both, return fd of newly opened pseudo-terminal."); - -#define OS_FORKPTY_METHODDEF \ - {"forkpty", (PyCFunction)os_forkpty, METH_NOARGS, os_forkpty__doc__}, - -static PyObject * -os_forkpty_impl(PyModuleDef *module); - -static PyObject * -os_forkpty(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_forkpty_impl(module); -} - static PyObject * os_forkpty_impl(PyModuleDef *module) -/*[clinic end generated code: output=d4f82958d2ed5cad input=f1f7f4bae3966010]*/ +/*[clinic end generated code: output=a11b8391dce3cb57 input=f1f7f4bae3966010]*/ { int master_fd = -1, result = 0; pid_t pid; @@ -8129,27 +6082,9 @@ os.getegid Return the current process's effective group id. [clinic start generated code]*/ -PyDoc_STRVAR(os_getegid__doc__, -"getegid($module, /)\n" -"--\n" -"\n" -"Return the current process\'s effective group id."); - -#define OS_GETEGID_METHODDEF \ - {"getegid", (PyCFunction)os_getegid, METH_NOARGS, os_getegid__doc__}, - -static PyObject * -os_getegid_impl(PyModuleDef *module); - -static PyObject * -os_getegid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getegid_impl(module); -} - static PyObject * os_getegid_impl(PyModuleDef *module) -/*[clinic end generated code: output=fd12c346fa41cccb input=1596f79ad1107d5d]*/ +/*[clinic end generated code: output=90f433a8c0b1d919 input=1596f79ad1107d5d]*/ { return _PyLong_FromGid(getegid()); } @@ -8163,27 +6098,9 @@ os.geteuid Return the current process's effective user id. [clinic start generated code]*/ -PyDoc_STRVAR(os_geteuid__doc__, -"geteuid($module, /)\n" -"--\n" -"\n" -"Return the current process\'s effective user id."); - -#define OS_GETEUID_METHODDEF \ - {"geteuid", (PyCFunction)os_geteuid, METH_NOARGS, os_geteuid__doc__}, - -static PyObject * -os_geteuid_impl(PyModuleDef *module); - -static PyObject * -os_geteuid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_geteuid_impl(module); -} - static PyObject * os_geteuid_impl(PyModuleDef *module) -/*[clinic end generated code: output=03d98e07f4bc03d4 input=4644c662d3bd9f19]*/ +/*[clinic end generated code: output=1a532c4a66874357 input=4644c662d3bd9f19]*/ { return _PyLong_FromUid(geteuid()); } @@ -8197,27 +6114,9 @@ os.getgid Return the current process's group id. [clinic start generated code]*/ -PyDoc_STRVAR(os_getgid__doc__, -"getgid($module, /)\n" -"--\n" -"\n" -"Return the current process\'s group id."); - -#define OS_GETGID_METHODDEF \ - {"getgid", (PyCFunction)os_getgid, METH_NOARGS, os_getgid__doc__}, - -static PyObject * -os_getgid_impl(PyModuleDef *module); - -static PyObject * -os_getgid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getgid_impl(module); -} - static PyObject * os_getgid_impl(PyModuleDef *module) -/*[clinic end generated code: output=07b0356121b8098d input=58796344cd87c0f6]*/ +/*[clinic end generated code: output=91a22021b74ea46b input=58796344cd87c0f6]*/ { return _PyLong_FromGid(getgid()); } @@ -8230,27 +6129,9 @@ os.getpid Return the current process id. [clinic start generated code]*/ -PyDoc_STRVAR(os_getpid__doc__, -"getpid($module, /)\n" -"--\n" -"\n" -"Return the current process id."); - -#define OS_GETPID_METHODDEF \ - {"getpid", (PyCFunction)os_getpid, METH_NOARGS, os_getpid__doc__}, - -static PyObject * -os_getpid_impl(PyModuleDef *module); - -static PyObject * -os_getpid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getpid_impl(module); -} - static PyObject * os_getpid_impl(PyModuleDef *module) -/*[clinic end generated code: output=d63a01a3cebc573d input=5a9a00f0ab68aa00]*/ +/*[clinic end generated code: output=8fbf3a934ee09e62 input=5a9a00f0ab68aa00]*/ { return PyLong_FromPid(getpid()); } @@ -8340,27 +6221,9 @@ os.getgroups Return list of supplemental group IDs for the process. [clinic start generated code]*/ -PyDoc_STRVAR(os_getgroups__doc__, -"getgroups($module, /)\n" -"--\n" -"\n" -"Return list of supplemental group IDs for the process."); - -#define OS_GETGROUPS_METHODDEF \ - {"getgroups", (PyCFunction)os_getgroups, METH_NOARGS, os_getgroups__doc__}, - -static PyObject * -os_getgroups_impl(PyModuleDef *module); - -static PyObject * -os_getgroups(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getgroups_impl(module); -} - static PyObject * os_getgroups_impl(PyModuleDef *module) -/*[clinic end generated code: output=d9a3559b2e6f4ab8 input=d3f109412e6a155c]*/ +/*[clinic end generated code: output=6e7c4fd2db6d5c60 input=d3f109412e6a155c]*/ { PyObject *result = NULL; @@ -8513,38 +6376,9 @@ os.getpgid Call the system call getpgid(), and return the result. [clinic start generated code]*/ -PyDoc_STRVAR(os_getpgid__doc__, -"getpgid($module, /, pid)\n" -"--\n" -"\n" -"Call the system call getpgid(), and return the result."); - -#define OS_GETPGID_METHODDEF \ - {"getpgid", (PyCFunction)os_getpgid, METH_VARARGS|METH_KEYWORDS, os_getpgid__doc__}, - -static PyObject * -os_getpgid_impl(PyModuleDef *module, pid_t pid); - -static PyObject * -os_getpgid(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"pid", NULL}; - pid_t pid; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "" _Py_PARSE_PID ":getpgid", _keywords, - &pid)) - goto exit; - return_value = os_getpgid_impl(module, pid); - -exit: - return return_value; -} - static PyObject * os_getpgid_impl(PyModuleDef *module, pid_t pid) -/*[clinic end generated code: output=3db4ed686179160d input=39d710ae3baaf1c7]*/ +/*[clinic end generated code: output=70e713b4d54b7c61 input=39d710ae3baaf1c7]*/ { pid_t pgid = getpgid(pid); if (pgid < 0) @@ -8561,27 +6395,9 @@ os.getpgrp Return the current process group id. [clinic start generated code]*/ -PyDoc_STRVAR(os_getpgrp__doc__, -"getpgrp($module, /)\n" -"--\n" -"\n" -"Return the current process group id."); - -#define OS_GETPGRP_METHODDEF \ - {"getpgrp", (PyCFunction)os_getpgrp, METH_NOARGS, os_getpgrp__doc__}, - -static PyObject * -os_getpgrp_impl(PyModuleDef *module); - -static PyObject * -os_getpgrp(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getpgrp_impl(module); -} - static PyObject * os_getpgrp_impl(PyModuleDef *module) -/*[clinic end generated code: output=3b0d3663ea054277 input=6846fb2bb9a3705e]*/ +/*[clinic end generated code: output=cf3403585846811f input=6846fb2bb9a3705e]*/ { #ifdef GETPGRP_HAVE_ARG return PyLong_FromPid(getpgrp(0)); @@ -8599,27 +6415,9 @@ os.setpgrp Make the current process the leader of its process group. [clinic start generated code]*/ -PyDoc_STRVAR(os_setpgrp__doc__, -"setpgrp($module, /)\n" -"--\n" -"\n" -"Make the current process the leader of its process group."); - -#define OS_SETPGRP_METHODDEF \ - {"setpgrp", (PyCFunction)os_setpgrp, METH_NOARGS, os_setpgrp__doc__}, - -static PyObject * -os_setpgrp_impl(PyModuleDef *module); - -static PyObject * -os_setpgrp(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_setpgrp_impl(module); -} - static PyObject * os_setpgrp_impl(PyModuleDef *module) -/*[clinic end generated code: output=8fbb0ee29ef6fb2d input=1f0619fcb5731e7e]*/ +/*[clinic end generated code: output=59650f55a963d7ac input=1f0619fcb5731e7e]*/ { #ifdef SETPGRP_HAVE_ARG if (setpgrp(0, 0) < 0) @@ -8686,30 +6484,9 @@ If the parent process has already exited return its id; others systems will return the id of the 'init' process (1). [clinic start generated code]*/ -PyDoc_STRVAR(os_getppid__doc__, -"getppid($module, /)\n" -"--\n" -"\n" -"Return the parent\'s process id.\n" -"\n" -"If the parent process has already exited, Windows machines will still\n" -"return its id; others systems will return the id of the \'init\' process (1)."); - -#define OS_GETPPID_METHODDEF \ - {"getppid", (PyCFunction)os_getppid, METH_NOARGS, os_getppid__doc__}, - -static PyObject * -os_getppid_impl(PyModuleDef *module); - -static PyObject * -os_getppid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getppid_impl(module); -} - static PyObject * os_getppid_impl(PyModuleDef *module) -/*[clinic end generated code: output=9ff3b387781edf3a input=e637cb87539c030e]*/ +/*[clinic end generated code: output=4e49c8e7a8738cd2 input=e637cb87539c030e]*/ { #ifdef MS_WINDOWS return win32_getppid(); @@ -8727,27 +6504,9 @@ os.getlogin Return the actual login name. [clinic start generated code]*/ -PyDoc_STRVAR(os_getlogin__doc__, -"getlogin($module, /)\n" -"--\n" -"\n" -"Return the actual login name."); - -#define OS_GETLOGIN_METHODDEF \ - {"getlogin", (PyCFunction)os_getlogin, METH_NOARGS, os_getlogin__doc__}, - -static PyObject * -os_getlogin_impl(PyModuleDef *module); - -static PyObject * -os_getlogin(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getlogin_impl(module); -} - static PyObject * os_getlogin_impl(PyModuleDef *module) -/*[clinic end generated code: output=ab6211dab104cbb2 input=2a21ab1e917163df]*/ +/*[clinic end generated code: output=037ebdb3e4b5dac1 input=2a21ab1e917163df]*/ { PyObject *result = NULL; #ifdef MS_WINDOWS @@ -8788,27 +6547,9 @@ os.getuid Return the current process's user id. [clinic start generated code]*/ -PyDoc_STRVAR(os_getuid__doc__, -"getuid($module, /)\n" -"--\n" -"\n" -"Return the current process\'s user id."); - -#define OS_GETUID_METHODDEF \ - {"getuid", (PyCFunction)os_getuid, METH_NOARGS, os_getuid__doc__}, - -static PyObject * -os_getuid_impl(PyModuleDef *module); - -static PyObject * -os_getuid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getuid_impl(module); -} - static PyObject * os_getuid_impl(PyModuleDef *module) -/*[clinic end generated code: output=77e0dcf2e37d1e89 input=b53c8b35f110a516]*/ +/*[clinic end generated code: output=03a8b894cefb3fa5 input=b53c8b35f110a516]*/ { return _PyLong_FromUid(getuid()); } @@ -8830,38 +6571,9 @@ os.kill Kill a process with a signal. [clinic start generated code]*/ -PyDoc_STRVAR(os_kill__doc__, -"kill($module, pid, signal, /)\n" -"--\n" -"\n" -"Kill a process with a signal."); - -#define OS_KILL_METHODDEF \ - {"kill", (PyCFunction)os_kill, METH_VARARGS, os_kill__doc__}, - -static PyObject * -os_kill_impl(PyModuleDef *module, pid_t pid, Py_ssize_t signal); - -static PyObject * -os_kill(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - pid_t pid; - Py_ssize_t signal; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_PID "n:kill", - &pid, &signal)) - goto exit; - return_value = os_kill_impl(module, pid, signal); - -exit: - return return_value; -} - static PyObject * os_kill_impl(PyModuleDef *module, pid_t pid, Py_ssize_t signal) -/*[clinic end generated code: output=2f5c77920ed575e6 input=61a36b86ca275ab9]*/ +/*[clinic end generated code: output=74f907dd00a83c26 input=61a36b86ca275ab9]*/ #ifndef MS_WINDOWS { if (kill(pid, (int)signal) == -1) @@ -8920,38 +6632,9 @@ os.killpg Kill a process group with a signal. [clinic start generated code]*/ -PyDoc_STRVAR(os_killpg__doc__, -"killpg($module, pgid, signal, /)\n" -"--\n" -"\n" -"Kill a process group with a signal."); - -#define OS_KILLPG_METHODDEF \ - {"killpg", (PyCFunction)os_killpg, METH_VARARGS, os_killpg__doc__}, - -static PyObject * -os_killpg_impl(PyModuleDef *module, pid_t pgid, int signal); - -static PyObject * -os_killpg(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - pid_t pgid; - int signal; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_PID "i:killpg", - &pgid, &signal)) - goto exit; - return_value = os_killpg_impl(module, pgid, signal); - -exit: - return return_value; -} - static PyObject * os_killpg_impl(PyModuleDef *module, pid_t pgid, int signal) -/*[clinic end generated code: output=0e05215d1c007e01 input=38b5449eb8faec19]*/ +/*[clinic end generated code: output=3434a766ef945f93 input=38b5449eb8faec19]*/ { /* XXX some man pages make the `pgid` parameter an int, others a pid_t. Since getpgrp() returns a pid_t, we assume killpg should @@ -8977,37 +6660,9 @@ os.plock Lock program segments into memory."); [clinic start generated code]*/ -PyDoc_STRVAR(os_plock__doc__, -"plock($module, op, /)\n" -"--\n" -"\n" -"Lock program segments into memory.\");"); - -#define OS_PLOCK_METHODDEF \ - {"plock", (PyCFunction)os_plock, METH_VARARGS, os_plock__doc__}, - -static PyObject * -os_plock_impl(PyModuleDef *module, int op); - -static PyObject * -os_plock(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int op; - - if (!PyArg_ParseTuple(args, - "i:plock", - &op)) - goto exit; - return_value = os_plock_impl(module, op); - -exit: - return return_value; -} - static PyObject * os_plock_impl(PyModuleDef *module, int op) -/*[clinic end generated code: output=2744fe4b6e5f4dbc input=e6e5e348e1525f60]*/ +/*[clinic end generated code: output=5cb851f81b914984 input=e6e5e348e1525f60]*/ { if (plock(op) == -1) return posix_error(); @@ -9026,37 +6681,9 @@ os.setuid Set the current process's user id. [clinic start generated code]*/ -PyDoc_STRVAR(os_setuid__doc__, -"setuid($module, uid, /)\n" -"--\n" -"\n" -"Set the current process\'s user id."); - -#define OS_SETUID_METHODDEF \ - {"setuid", (PyCFunction)os_setuid, METH_VARARGS, os_setuid__doc__}, - -static PyObject * -os_setuid_impl(PyModuleDef *module, uid_t uid); - -static PyObject * -os_setuid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - uid_t uid; - - if (!PyArg_ParseTuple(args, - "O&:setuid", - _Py_Uid_Converter, &uid)) - goto exit; - return_value = os_setuid_impl(module, uid); - -exit: - return return_value; -} - static PyObject * os_setuid_impl(PyModuleDef *module, uid_t uid) -/*[clinic end generated code: output=aea344bc22ccf400 input=c921a3285aa22256]*/ +/*[clinic end generated code: output=941ea9a8d1e5d565 input=c921a3285aa22256]*/ { if (setuid(uid) < 0) return posix_error(); @@ -9075,37 +6702,9 @@ os.seteuid Set the current process's effective user id. [clinic start generated code]*/ -PyDoc_STRVAR(os_seteuid__doc__, -"seteuid($module, euid, /)\n" -"--\n" -"\n" -"Set the current process\'s effective user id."); - -#define OS_SETEUID_METHODDEF \ - {"seteuid", (PyCFunction)os_seteuid, METH_VARARGS, os_seteuid__doc__}, - -static PyObject * -os_seteuid_impl(PyModuleDef *module, uid_t euid); - -static PyObject * -os_seteuid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - uid_t euid; - - if (!PyArg_ParseTuple(args, - "O&:seteuid", - _Py_Uid_Converter, &euid)) - goto exit; - return_value = os_seteuid_impl(module, euid); - -exit: - return return_value; -} - static PyObject * os_seteuid_impl(PyModuleDef *module, uid_t euid) -/*[clinic end generated code: output=6e824cce4f3b8a5d input=ba93d927e4781aa9]*/ +/*[clinic end generated code: output=66f4f6823a648d6d input=ba93d927e4781aa9]*/ { if (seteuid(euid) < 0) return posix_error(); @@ -9124,37 +6723,9 @@ os.setegid Set the current process's effective group id. [clinic start generated code]*/ -PyDoc_STRVAR(os_setegid__doc__, -"setegid($module, egid, /)\n" -"--\n" -"\n" -"Set the current process\'s effective group id."); - -#define OS_SETEGID_METHODDEF \ - {"setegid", (PyCFunction)os_setegid, METH_VARARGS, os_setegid__doc__}, - -static PyObject * -os_setegid_impl(PyModuleDef *module, gid_t egid); - -static PyObject * -os_setegid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - gid_t egid; - - if (!PyArg_ParseTuple(args, - "O&:setegid", - _Py_Gid_Converter, &egid)) - goto exit; - return_value = os_setegid_impl(module, egid); - -exit: - return return_value; -} - static PyObject * os_setegid_impl(PyModuleDef *module, gid_t egid) -/*[clinic end generated code: output=80a32263a4d56a9c input=4080526d0ccd6ce3]*/ +/*[clinic end generated code: output=ca094a69a081a60f input=4080526d0ccd6ce3]*/ { if (setegid(egid) < 0) return posix_error(); @@ -9174,38 +6745,9 @@ os.setreuid Set the current process's real and effective user ids. [clinic start generated code]*/ -PyDoc_STRVAR(os_setreuid__doc__, -"setreuid($module, ruid, euid, /)\n" -"--\n" -"\n" -"Set the current process\'s real and effective user ids."); - -#define OS_SETREUID_METHODDEF \ - {"setreuid", (PyCFunction)os_setreuid, METH_VARARGS, os_setreuid__doc__}, - -static PyObject * -os_setreuid_impl(PyModuleDef *module, uid_t ruid, uid_t euid); - -static PyObject * -os_setreuid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - uid_t ruid; - uid_t euid; - - if (!PyArg_ParseTuple(args, - "O&O&:setreuid", - _Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid)) - goto exit; - return_value = os_setreuid_impl(module, ruid, euid); - -exit: - return return_value; -} - static PyObject * os_setreuid_impl(PyModuleDef *module, uid_t ruid, uid_t euid) -/*[clinic end generated code: output=d7f226f943dad739 input=0ca8978de663880c]*/ +/*[clinic end generated code: output=b2938c3e73d27ec7 input=0ca8978de663880c]*/ { if (setreuid(ruid, euid) < 0) { return posix_error(); @@ -9228,38 +6770,9 @@ os.setregid Set the current process's real and effective group ids. [clinic start generated code]*/ -PyDoc_STRVAR(os_setregid__doc__, -"setregid($module, rgid, egid, /)\n" -"--\n" -"\n" -"Set the current process\'s real and effective group ids."); - -#define OS_SETREGID_METHODDEF \ - {"setregid", (PyCFunction)os_setregid, METH_VARARGS, os_setregid__doc__}, - -static PyObject * -os_setregid_impl(PyModuleDef *module, gid_t rgid, gid_t egid); - -static PyObject * -os_setregid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - gid_t rgid; - gid_t egid; - - if (!PyArg_ParseTuple(args, - "O&O&:setregid", - _Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid)) - goto exit; - return_value = os_setregid_impl(module, rgid, egid); - -exit: - return return_value; -} - static PyObject * os_setregid_impl(PyModuleDef *module, gid_t rgid, gid_t egid) -/*[clinic end generated code: output=a82d9ab70f8e6562 input=c59499f72846db78]*/ +/*[clinic end generated code: output=db18f1839ababe3d input=c59499f72846db78]*/ { if (setregid(rgid, egid) < 0) return posix_error(); @@ -9277,37 +6790,9 @@ os.setgid Set the current process's group id. [clinic start generated code]*/ -PyDoc_STRVAR(os_setgid__doc__, -"setgid($module, gid, /)\n" -"--\n" -"\n" -"Set the current process\'s group id."); - -#define OS_SETGID_METHODDEF \ - {"setgid", (PyCFunction)os_setgid, METH_VARARGS, os_setgid__doc__}, - -static PyObject * -os_setgid_impl(PyModuleDef *module, gid_t gid); - -static PyObject * -os_setgid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - gid_t gid; - - if (!PyArg_ParseTuple(args, - "O&:setgid", - _Py_Gid_Converter, &gid)) - goto exit; - return_value = os_setgid_impl(module, gid); - -exit: - return return_value; -} - static PyObject * os_setgid_impl(PyModuleDef *module, gid_t gid) -/*[clinic end generated code: output=08287886db435f23 input=27d30c4059045dc6]*/ +/*[clinic end generated code: output=756cb42c6abd9d87 input=27d30c4059045dc6]*/ { if (setgid(gid) < 0) return posix_error(); @@ -9326,18 +6811,9 @@ os.setgroups Set the groups of the current process to list. [clinic start generated code]*/ -PyDoc_STRVAR(os_setgroups__doc__, -"setgroups($module, groups, /)\n" -"--\n" -"\n" -"Set the groups of the current process to list."); - -#define OS_SETGROUPS_METHODDEF \ - {"setgroups", (PyCFunction)os_setgroups, METH_O, os_setgroups__doc__}, - static PyObject * os_setgroups(PyModuleDef *module, PyObject *groups) -/*[clinic end generated code: output=0b8de65d5b3cda94 input=fa742ca3daf85a7e]*/ +/*[clinic end generated code: output=7945c2e3cc817c58 input=fa742ca3daf85a7e]*/ { int i, len; gid_t grouplist[MAX_GROUPS]; @@ -9450,41 +6926,9 @@ Returns a tuple of information about the (pid, status, rusage) [clinic start generated code]*/ -PyDoc_STRVAR(os_wait3__doc__, -"wait3($module, /, options)\n" -"--\n" -"\n" -"Wait for completion of a child process.\n" -"\n" -"Returns a tuple of information about the child process:\n" -" (pid, status, rusage)"); - -#define OS_WAIT3_METHODDEF \ - {"wait3", (PyCFunction)os_wait3, METH_VARARGS|METH_KEYWORDS, os_wait3__doc__}, - -static PyObject * -os_wait3_impl(PyModuleDef *module, int options); - -static PyObject * -os_wait3(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"options", NULL}; - int options; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:wait3", _keywords, - &options)) - goto exit; - return_value = os_wait3_impl(module, options); - -exit: - return return_value; -} - static PyObject * os_wait3_impl(PyModuleDef *module, int options) -/*[clinic end generated code: output=1f2a63b6a93cbb57 input=8ac4c56956b61710]*/ +/*[clinic end generated code: output=e18af4924dc54945 input=8ac4c56956b61710]*/ { pid_t pid; struct rusage ru; @@ -9519,42 +6963,9 @@ Returns a tuple of information about the (pid, status, rusage) [clinic start generated code]*/ -PyDoc_STRVAR(os_wait4__doc__, -"wait4($module, /, pid, options)\n" -"--\n" -"\n" -"Wait for completion of a specific child process.\n" -"\n" -"Returns a tuple of information about the child process:\n" -" (pid, status, rusage)"); - -#define OS_WAIT4_METHODDEF \ - {"wait4", (PyCFunction)os_wait4, METH_VARARGS|METH_KEYWORDS, os_wait4__doc__}, - -static PyObject * -os_wait4_impl(PyModuleDef *module, pid_t pid, int options); - -static PyObject * -os_wait4(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"pid", "options", NULL}; - pid_t pid; - int options; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "" _Py_PARSE_PID "i:wait4", _keywords, - &pid, &options)) - goto exit; - return_value = os_wait4_impl(module, pid, options); - -exit: - return return_value; -} - static PyObject * os_wait4_impl(PyModuleDef *module, pid_t pid, int options) -/*[clinic end generated code: output=20dfb05289d37dc6 input=d11deed0750600ba]*/ +/*[clinic end generated code: output=714f19e6ff01e099 input=d11deed0750600ba]*/ { pid_t res; struct rusage ru; @@ -9594,50 +7005,9 @@ Returns either waitid_result or None if no children in a waitable state. [clinic start generated code]*/ -PyDoc_STRVAR(os_waitid__doc__, -"waitid($module, idtype, id, options, /)\n" -"--\n" -"\n" -"Returns the result of waiting for a process or processes.\n" -"\n" -" idtype\n" -" Must be one of be P_PID, P_PGID or P_ALL.\n" -" id\n" -" The id to wait on.\n" -" options\n" -" Constructed from the ORing of one or more of WEXITED, WSTOPPED\n" -" or WCONTINUED and additionally may be ORed with WNOHANG or WNOWAIT.\n" -"\n" -"Returns either waitid_result or None if WNOHANG is specified and there are\n" -"no children in a waitable state."); - -#define OS_WAITID_METHODDEF \ - {"waitid", (PyCFunction)os_waitid, METH_VARARGS, os_waitid__doc__}, - -static PyObject * -os_waitid_impl(PyModuleDef *module, idtype_t idtype, id_t id, int options); - -static PyObject * -os_waitid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - idtype_t idtype; - id_t id; - int options; - - if (!PyArg_ParseTuple(args, - "i" _Py_PARSE_PID "i:waitid", - &idtype, &id, &options)) - goto exit; - return_value = os_waitid_impl(module, idtype, id, options); - -exit: - return return_value; -} - static PyObject * os_waitid_impl(PyModuleDef *module, idtype_t idtype, id_t id, int options) -/*[clinic end generated code: output=fb44bf97f01021b2 input=d8e7f76e052b7920]*/ +/*[clinic end generated code: output=5c0192750e22fa2e input=d8e7f76e052b7920]*/ { PyObject *result; int res; @@ -9690,43 +7060,9 @@ Returns a tuple of information regarding The options argument is ignored on Windows. [clinic start generated code]*/ -PyDoc_STRVAR(os_waitpid__doc__, -"waitpid($module, pid, options, /)\n" -"--\n" -"\n" -"Wait for completion of a given child process.\n" -"\n" -"Returns a tuple of information regarding the child process:\n" -" (pid, status)\n" -"\n" -"The options argument is ignored on Windows."); - -#define OS_WAITPID_METHODDEF \ - {"waitpid", (PyCFunction)os_waitpid, METH_VARARGS, os_waitpid__doc__}, - -static PyObject * -os_waitpid_impl(PyModuleDef *module, pid_t pid, int options); - -static PyObject * -os_waitpid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - pid_t pid; - int options; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_PID "i:waitpid", - &pid, &options)) - goto exit; - return_value = os_waitpid_impl(module, pid, options); - -exit: - return return_value; -} - static PyObject * os_waitpid_impl(PyModuleDef *module, pid_t pid, int options) -/*[clinic end generated code: output=095a6b00af70b7ac input=0bf1666b8758fda3]*/ +/*[clinic end generated code: output=5e3593353d54b15b input=0bf1666b8758fda3]*/ { pid_t res; int async_err = 0; @@ -9759,43 +7095,9 @@ Returns a tuple of information regarding The options argument is ignored on Windows. [clinic start generated code]*/ -PyDoc_STRVAR(os_waitpid__doc__, -"waitpid($module, pid, options, /)\n" -"--\n" -"\n" -"Wait for completion of a given process.\n" -"\n" -"Returns a tuple of information regarding the process:\n" -" (pid, status << 8)\n" -"\n" -"The options argument is ignored on Windows."); - -#define OS_WAITPID_METHODDEF \ - {"waitpid", (PyCFunction)os_waitpid, METH_VARARGS, os_waitpid__doc__}, - -static PyObject * -os_waitpid_impl(PyModuleDef *module, Py_intptr_t pid, int options); - -static PyObject * -os_waitpid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - Py_intptr_t pid; - int options; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_INTPTR "i:waitpid", - &pid, &options)) - goto exit; - return_value = os_waitpid_impl(module, pid, options); - -exit: - return return_value; -} - static PyObject * os_waitpid_impl(PyModuleDef *module, Py_intptr_t pid, int options) -/*[clinic end generated code: output=c20b95b15ad44a3a input=444c8f51cca5b862]*/ +/*[clinic end generated code: output=fc1d520db019625f input=444c8f51cca5b862]*/ { int status; Py_intptr_t res; @@ -9825,30 +7127,9 @@ Returns a tuple of information about the (pid, status) [clinic start generated code]*/ -PyDoc_STRVAR(os_wait__doc__, -"wait($module, /)\n" -"--\n" -"\n" -"Wait for completion of a child process.\n" -"\n" -"Returns a tuple of information about the child process:\n" -" (pid, status)"); - -#define OS_WAIT_METHODDEF \ - {"wait", (PyCFunction)os_wait, METH_NOARGS, os_wait__doc__}, - -static PyObject * -os_wait_impl(PyModuleDef *module); - -static PyObject * -os_wait(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_wait_impl(module); -} - static PyObject * os_wait_impl(PyModuleDef *module) -/*[clinic end generated code: output=2a83a9d164e7e6a8 input=03b0182d4a4700ce]*/ +/*[clinic end generated code: output=4a7f4978393e0654 input=03b0182d4a4700ce]*/ { pid_t pid; int async_err = 0; @@ -10174,56 +7455,9 @@ dir_fd may not be implemented on your pl [clinic start generated code]*/ -PyDoc_STRVAR(os_symlink__doc__, -"symlink($module, /, src, dst, target_is_directory=False, *, dir_fd=None)\n" -"--\n" -"\n" -"Create a symbolic link pointing to src named dst.\n" -"\n" -"target_is_directory is required on Windows if the target is to be\n" -" interpreted as a directory. (On Windows, symlink requires\n" -" Windows 6.0 or greater, and raises a NotImplementedError otherwise.)\n" -" target_is_directory is ignored on non-Windows platforms.\n" -"\n" -"If dir_fd is not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that directory.\n" -"dir_fd may not be implemented on your platform.\n" -" If it is unavailable, using it will raise a NotImplementedError."); - -#define OS_SYMLINK_METHODDEF \ - {"symlink", (PyCFunction)os_symlink, METH_VARARGS|METH_KEYWORDS, os_symlink__doc__}, - -static PyObject * -os_symlink_impl(PyModuleDef *module, path_t *src, path_t *dst, int target_is_directory, int dir_fd); - -static PyObject * -os_symlink(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"src", "dst", "target_is_directory", "dir_fd", NULL}; - path_t src = PATH_T_INITIALIZE("symlink", "src", 0, 0); - path_t dst = PATH_T_INITIALIZE("symlink", "dst", 0, 0); - int target_is_directory = 0; - int dir_fd = DEFAULT_DIR_FD; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&O&|p$O&:symlink", _keywords, - path_converter, &src, path_converter, &dst, &target_is_directory, SYMLINKAT_DIR_FD_CONVERTER, &dir_fd)) - goto exit; - return_value = os_symlink_impl(module, &src, &dst, target_is_directory, dir_fd); - -exit: - /* Cleanup for src */ - path_cleanup(&src); - /* Cleanup for dst */ - path_cleanup(&dst); - - return return_value; -} - static PyObject * os_symlink_impl(PyModuleDef *module, path_t *src, path_t *dst, int target_is_directory, int dir_fd) -/*[clinic end generated code: output=1a31e6d88aafe9b6 input=e820ec4472547bc3]*/ +/*[clinic end generated code: output=11aa03f278bb2c8a input=e820ec4472547bc3]*/ { #ifdef MS_WINDOWS DWORD result; @@ -10370,31 +7604,9 @@ The object returned behaves like a named All fields are floating point numbers. [clinic start generated code]*/ -PyDoc_STRVAR(os_times__doc__, -"times($module, /)\n" -"--\n" -"\n" -"Return a collection containing process timing information.\n" -"\n" -"The object returned behaves like a named tuple with these fields:\n" -" (utime, stime, cutime, cstime, elapsed_time)\n" -"All fields are floating point numbers."); - -#define OS_TIMES_METHODDEF \ - {"times", (PyCFunction)os_times, METH_NOARGS, os_times__doc__}, - -static PyObject * -os_times_impl(PyModuleDef *module); - -static PyObject * -os_times(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_times_impl(module); -} - static PyObject * os_times_impl(PyModuleDef *module) -/*[clinic end generated code: output=b86896d031a9b768 input=2bf9df3d6ab2e48b]*/ +/*[clinic end generated code: output=df0a63ebe6e6f091 input=2bf9df3d6ab2e48b]*/ #ifdef MS_WINDOWS { FILETIME create, exit, kernel, user; @@ -10446,37 +7658,9 @@ os.getsid Call the system call getsid(pid) and return the result. [clinic start generated code]*/ -PyDoc_STRVAR(os_getsid__doc__, -"getsid($module, pid, /)\n" -"--\n" -"\n" -"Call the system call getsid(pid) and return the result."); - -#define OS_GETSID_METHODDEF \ - {"getsid", (PyCFunction)os_getsid, METH_VARARGS, os_getsid__doc__}, - -static PyObject * -os_getsid_impl(PyModuleDef *module, pid_t pid); - -static PyObject * -os_getsid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - pid_t pid; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_PID ":getsid", - &pid)) - goto exit; - return_value = os_getsid_impl(module, pid); - -exit: - return return_value; -} - static PyObject * os_getsid_impl(PyModuleDef *module, pid_t pid) -/*[clinic end generated code: output=ea8390f395f4e0e1 input=eeb2b923a30ce04e]*/ +/*[clinic end generated code: output=a074f80c0e6bfb38 input=eeb2b923a30ce04e]*/ { int sid; sid = getsid(pid); @@ -10494,27 +7678,9 @@ os.setsid Call the system call setsid(). [clinic start generated code]*/ -PyDoc_STRVAR(os_setsid__doc__, -"setsid($module, /)\n" -"--\n" -"\n" -"Call the system call setsid()."); - -#define OS_SETSID_METHODDEF \ - {"setsid", (PyCFunction)os_setsid, METH_NOARGS, os_setsid__doc__}, - -static PyObject * -os_setsid_impl(PyModuleDef *module); - -static PyObject * -os_setsid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_setsid_impl(module); -} - static PyObject * os_setsid_impl(PyModuleDef *module) -/*[clinic end generated code: output=2a9a1435d8d764d5 input=5fff45858e2f0776]*/ +/*[clinic end generated code: output=398fc152ae327330 input=5fff45858e2f0776]*/ { if (setsid() < 0) return posix_error(); @@ -10534,38 +7700,9 @@ os.setpgid Call the system call setpgid(pid, pgrp). [clinic start generated code]*/ -PyDoc_STRVAR(os_setpgid__doc__, -"setpgid($module, pid, pgrp, /)\n" -"--\n" -"\n" -"Call the system call setpgid(pid, pgrp)."); - -#define OS_SETPGID_METHODDEF \ - {"setpgid", (PyCFunction)os_setpgid, METH_VARARGS, os_setpgid__doc__}, - -static PyObject * -os_setpgid_impl(PyModuleDef *module, pid_t pid, pid_t pgrp); - -static PyObject * -os_setpgid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - pid_t pid; - pid_t pgrp; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_PID "" _Py_PARSE_PID ":setpgid", - &pid, &pgrp)) - goto exit; - return_value = os_setpgid_impl(module, pid, pgrp); - -exit: - return return_value; -} - static PyObject * os_setpgid_impl(PyModuleDef *module, pid_t pid, pid_t pgrp) -/*[clinic end generated code: output=7ad79b725f890e1f input=fceb395eca572e1a]*/ +/*[clinic end generated code: output=7079a8e932912841 input=fceb395eca572e1a]*/ { if (setpgid(pid, pgrp) < 0) return posix_error(); @@ -10584,37 +7721,9 @@ os.tcgetpgrp Return the process group associated with the terminal specified by fd. [clinic start generated code]*/ -PyDoc_STRVAR(os_tcgetpgrp__doc__, -"tcgetpgrp($module, fd, /)\n" -"--\n" -"\n" -"Return the process group associated with the terminal specified by fd."); - -#define OS_TCGETPGRP_METHODDEF \ - {"tcgetpgrp", (PyCFunction)os_tcgetpgrp, METH_VARARGS, os_tcgetpgrp__doc__}, - -static PyObject * -os_tcgetpgrp_impl(PyModuleDef *module, int fd); - -static PyObject * -os_tcgetpgrp(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - - if (!PyArg_ParseTuple(args, - "i:tcgetpgrp", - &fd)) - goto exit; - return_value = os_tcgetpgrp_impl(module, fd); - -exit: - return return_value; -} - static PyObject * os_tcgetpgrp_impl(PyModuleDef *module, int fd) -/*[clinic end generated code: output=abcf52ed4c8d22cb input=7f6c18eac10ada86]*/ +/*[clinic end generated code: output=ebb6dc5f111c7dc0 input=7f6c18eac10ada86]*/ { pid_t pgid = tcgetpgrp(fd); if (pgid < 0) @@ -10635,38 +7744,9 @@ os.tcsetpgrp Set the process group associated with the terminal specified by fd. [clinic start generated code]*/ -PyDoc_STRVAR(os_tcsetpgrp__doc__, -"tcsetpgrp($module, fd, pgid, /)\n" -"--\n" -"\n" -"Set the process group associated with the terminal specified by fd."); - -#define OS_TCSETPGRP_METHODDEF \ - {"tcsetpgrp", (PyCFunction)os_tcsetpgrp, METH_VARARGS, os_tcsetpgrp__doc__}, - -static PyObject * -os_tcsetpgrp_impl(PyModuleDef *module, int fd, pid_t pgid); - -static PyObject * -os_tcsetpgrp(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - pid_t pgid; - - if (!PyArg_ParseTuple(args, - "i" _Py_PARSE_PID ":tcsetpgrp", - &fd, &pgid)) - goto exit; - return_value = os_tcsetpgrp_impl(module, fd, pgid); - -exit: - return return_value; -} - static PyObject * os_tcsetpgrp_impl(PyModuleDef *module, int fd, pid_t pgid) -/*[clinic end generated code: output=76f9bb8fd00f20f5 input=5bdc997c6a619020]*/ +/*[clinic end generated code: output=3e4b05177462cd22 input=5bdc997c6a619020]*/ { if (tcsetpgrp(fd, pgid) < 0) return posix_error(); @@ -10699,53 +7779,9 @@ dir_fd may not be implemented on your pl If it is unavailable, using it will raise a NotImplementedError. [clinic start generated code]*/ -PyDoc_STRVAR(os_open__doc__, -"open($module, /, path, flags, mode=511, *, dir_fd=None)\n" -"--\n" -"\n" -"Open a file for low level IO. Returns a file descriptor (integer).\n" -"\n" -"If dir_fd is not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that directory.\n" -"dir_fd may not be implemented on your platform.\n" -" If it is unavailable, using it will raise a NotImplementedError."); - -#define OS_OPEN_METHODDEF \ - {"open", (PyCFunction)os_open, METH_VARARGS|METH_KEYWORDS, os_open__doc__}, - -static int -os_open_impl(PyModuleDef *module, path_t *path, int flags, int mode, int dir_fd); - -static PyObject * -os_open(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "flags", "mode", "dir_fd", NULL}; - path_t path = PATH_T_INITIALIZE("open", "path", 0, 0); - int flags; - int mode = 511; - int dir_fd = DEFAULT_DIR_FD; - int _return_value; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&i|i$O&:open", _keywords, - path_converter, &path, &flags, &mode, OPENAT_DIR_FD_CONVERTER, &dir_fd)) - goto exit; - _return_value = os_open_impl(module, &path, flags, mode, dir_fd); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromLong((long)_return_value); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static int os_open_impl(PyModuleDef *module, path_t *path, int flags, int mode, int dir_fd) -/*[clinic end generated code: output=05b68fc4ed5e29c9 input=ad8623b29acd2934]*/ +/*[clinic end generated code: output=c95a64f0e62f199b input=ad8623b29acd2934]*/ { int fd; int async_err = 0; @@ -10803,38 +7839,9 @@ os.close Close a file descriptor. [clinic start generated code]*/ -PyDoc_STRVAR(os_close__doc__, -"close($module, /, fd)\n" -"--\n" -"\n" -"Close a file descriptor."); - -#define OS_CLOSE_METHODDEF \ - {"close", (PyCFunction)os_close, METH_VARARGS|METH_KEYWORDS, os_close__doc__}, - -static PyObject * -os_close_impl(PyModuleDef *module, int fd); - -static PyObject * -os_close(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"fd", NULL}; - int fd; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:close", _keywords, - &fd)) - goto exit; - return_value = os_close_impl(module, fd); - -exit: - return return_value; -} - static PyObject * os_close_impl(PyModuleDef *module, int fd) -/*[clinic end generated code: output=927004e29ad55808 input=2bc42451ca5c3223]*/ +/*[clinic end generated code: output=47bf2ea536445a26 input=2bc42451ca5c3223]*/ { int res; if (!_PyVerify_fd(fd)) @@ -10862,38 +7869,9 @@ os.closerange Closes all file descriptors in [fd_low, fd_high), ignoring errors. [clinic start generated code]*/ -PyDoc_STRVAR(os_closerange__doc__, -"closerange($module, fd_low, fd_high, /)\n" -"--\n" -"\n" -"Closes all file descriptors in [fd_low, fd_high), ignoring errors."); - -#define OS_CLOSERANGE_METHODDEF \ - {"closerange", (PyCFunction)os_closerange, METH_VARARGS, os_closerange__doc__}, - -static PyObject * -os_closerange_impl(PyModuleDef *module, int fd_low, int fd_high); - -static PyObject * -os_closerange(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd_low; - int fd_high; - - if (!PyArg_ParseTuple(args, - "ii:closerange", - &fd_low, &fd_high)) - goto exit; - return_value = os_closerange_impl(module, fd_low, fd_high); - -exit: - return return_value; -} - static PyObject * os_closerange_impl(PyModuleDef *module, int fd_low, int fd_high) -/*[clinic end generated code: output=0a929ece386811c3 input=5855a3d053ebd4ec]*/ +/*[clinic end generated code: output=70e6adb95220ba96 input=5855a3d053ebd4ec]*/ { int i; Py_BEGIN_ALLOW_THREADS @@ -10914,41 +7892,9 @@ os.dup -> int Return a duplicate of a file descriptor. [clinic start generated code]*/ -PyDoc_STRVAR(os_dup__doc__, -"dup($module, fd, /)\n" -"--\n" -"\n" -"Return a duplicate of a file descriptor."); - -#define OS_DUP_METHODDEF \ - {"dup", (PyCFunction)os_dup, METH_VARARGS, os_dup__doc__}, - -static int -os_dup_impl(PyModuleDef *module, int fd); - -static PyObject * -os_dup(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - int _return_value; - - if (!PyArg_ParseTuple(args, - "i:dup", - &fd)) - goto exit; - _return_value = os_dup_impl(module, fd); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromLong((long)_return_value); - -exit: - return return_value; -} - static int os_dup_impl(PyModuleDef *module, int fd) -/*[clinic end generated code: output=75943e057b25e1bd input=6f10f7ea97f7852a]*/ +/*[clinic end generated code: output=f4bbac8c7652d05e input=6f10f7ea97f7852a]*/ { return _Py_dup(fd); } @@ -10963,40 +7909,9 @@ os.dup2 Duplicate file descriptor. [clinic start generated code]*/ -PyDoc_STRVAR(os_dup2__doc__, -"dup2($module, /, fd, fd2, inheritable=True)\n" -"--\n" -"\n" -"Duplicate file descriptor."); - -#define OS_DUP2_METHODDEF \ - {"dup2", (PyCFunction)os_dup2, METH_VARARGS|METH_KEYWORDS, os_dup2__doc__}, - -static PyObject * -os_dup2_impl(PyModuleDef *module, int fd, int fd2, int inheritable); - -static PyObject * -os_dup2(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"fd", "fd2", "inheritable", NULL}; - int fd; - int fd2; - int inheritable = 1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "ii|p:dup2", _keywords, - &fd, &fd2, &inheritable)) - goto exit; - return_value = os_dup2_impl(module, fd, fd2, inheritable); - -exit: - return return_value; -} - static PyObject * os_dup2_impl(PyModuleDef *module, int fd, int fd2, int inheritable) -/*[clinic end generated code: output=531e482dd11a99a0 input=76e96f511be0352f]*/ +/*[clinic end generated code: output=9a099d95881a7923 input=76e96f511be0352f]*/ { int res; #if defined(HAVE_DUP3) && \ @@ -11089,46 +8004,9 @@ Apply, test or remove a POSIX lock on an [clinic start generated code]*/ -PyDoc_STRVAR(os_lockf__doc__, -"lockf($module, fd, command, length, /)\n" -"--\n" -"\n" -"Apply, test or remove a POSIX lock on an open file descriptor.\n" -"\n" -" fd\n" -" An open file descriptor.\n" -" command\n" -" One of F_LOCK, F_TLOCK, F_ULOCK or F_TEST.\n" -" length\n" -" The number of bytes to lock, starting at the current position."); - -#define OS_LOCKF_METHODDEF \ - {"lockf", (PyCFunction)os_lockf, METH_VARARGS, os_lockf__doc__}, - -static PyObject * -os_lockf_impl(PyModuleDef *module, int fd, int command, Py_off_t length); - -static PyObject * -os_lockf(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - int command; - Py_off_t length; - - if (!PyArg_ParseTuple(args, - "iiO&:lockf", - &fd, &command, Py_off_t_converter, &length)) - goto exit; - return_value = os_lockf_impl(module, fd, command, length); - -exit: - return return_value; -} - static PyObject * os_lockf_impl(PyModuleDef *module, int fd, int command, Py_off_t length) -/*[clinic end generated code: output=1b28346ac7335c0f input=65da41d2106e9b79]*/ +/*[clinic end generated code: output=25ff778f9e2fbf1b input=65da41d2106e9b79]*/ { int res; @@ -11158,46 +8036,9 @@ Return the new cursor position in number relative to the beginning of the file. [clinic start generated code]*/ -PyDoc_STRVAR(os_lseek__doc__, -"lseek($module, fd, position, how, /)\n" -"--\n" -"\n" -"Set the position of a file descriptor. Return the new position.\n" -"\n" -"Return the new cursor position in number of bytes\n" -"relative to the beginning of the file."); - -#define OS_LSEEK_METHODDEF \ - {"lseek", (PyCFunction)os_lseek, METH_VARARGS, os_lseek__doc__}, - -static Py_off_t -os_lseek_impl(PyModuleDef *module, int fd, Py_off_t position, int how); - -static PyObject * -os_lseek(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - Py_off_t position; - int how; - Py_off_t _return_value; - - if (!PyArg_ParseTuple(args, - "iO&i:lseek", - &fd, Py_off_t_converter, &position, &how)) - goto exit; - _return_value = os_lseek_impl(module, fd, position, how); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromPy_off_t(_return_value); - -exit: - return return_value; -} - static Py_off_t os_lseek_impl(PyModuleDef *module, int fd, Py_off_t position, int how) -/*[clinic end generated code: output=88cfc146f55667af input=902654ad3f96a6d3]*/ +/*[clinic end generated code: output=65d4ab96d664998c input=902654ad3f96a6d3]*/ { Py_off_t result; @@ -11244,38 +8085,9 @@ os.read Read from a file descriptor. Returns a bytes object. [clinic start generated code]*/ -PyDoc_STRVAR(os_read__doc__, -"read($module, fd, length, /)\n" -"--\n" -"\n" -"Read from a file descriptor. Returns a bytes object."); - -#define OS_READ_METHODDEF \ - {"read", (PyCFunction)os_read, METH_VARARGS, os_read__doc__}, - -static PyObject * -os_read_impl(PyModuleDef *module, int fd, Py_ssize_t length); - -static PyObject * -os_read(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - Py_ssize_t length; - - if (!PyArg_ParseTuple(args, - "in:read", - &fd, &length)) - goto exit; - return_value = os_read_impl(module, fd, length); - -exit: - return return_value; -} - static PyObject * os_read_impl(PyModuleDef *module, int fd, Py_ssize_t length) -/*[clinic end generated code: output=1f3bc27260a24968 input=1df2eaa27c0bf1d3]*/ +/*[clinic end generated code: output=be24f44178455e8b input=1df2eaa27c0bf1d3]*/ { Py_ssize_t n; int async_err = 0; @@ -11395,50 +8207,9 @@ readv returns the total number of bytes which may be less than the total capacity of all the buffers. [clinic start generated code]*/ -PyDoc_STRVAR(os_readv__doc__, -"readv($module, fd, buffers, /)\n" -"--\n" -"\n" -"Read from a file descriptor fd into an iterable of buffers.\n" -"\n" -"The buffers should be mutable buffers accepting bytes.\n" -"readv will transfer data into each buffer until it is full\n" -"and then move on to the next buffer in the sequence to hold\n" -"the rest of the data.\n" -"\n" -"readv returns the total number of bytes read,\n" -"which may be less than the total capacity of all the buffers."); - -#define OS_READV_METHODDEF \ - {"readv", (PyCFunction)os_readv, METH_VARARGS, os_readv__doc__}, - -static Py_ssize_t -os_readv_impl(PyModuleDef *module, int fd, PyObject *buffers); - -static PyObject * -os_readv(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - PyObject *buffers; - Py_ssize_t _return_value; - - if (!PyArg_ParseTuple(args, - "iO:readv", - &fd, &buffers)) - goto exit; - _return_value = os_readv_impl(module, fd, buffers); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromSsize_t(_return_value); - -exit: - return return_value; -} - static Py_ssize_t os_readv_impl(PyModuleDef *module, int fd, PyObject *buffers) -/*[clinic end generated code: output=72748b1c32a6e2a1 input=e679eb5dbfa0357d]*/ +/*[clinic end generated code: output=00fc56ff1800059f input=e679eb5dbfa0357d]*/ { int cnt; Py_ssize_t n; @@ -11491,42 +8262,9 @@ Read length bytes from file descriptor f the beginning of the file. The file offset remains unchanged. [clinic start generated code]*/ -PyDoc_STRVAR(os_pread__doc__, -"pread($module, fd, length, offset, /)\n" -"--\n" -"\n" -"Read a number of bytes from a file descriptor starting at a particular offset.\n" -"\n" -"Read length bytes from file descriptor fd, starting at offset bytes from\n" -"the beginning of the file. The file offset remains unchanged."); - -#define OS_PREAD_METHODDEF \ - {"pread", (PyCFunction)os_pread, METH_VARARGS, os_pread__doc__}, - -static PyObject * -os_pread_impl(PyModuleDef *module, int fd, int length, Py_off_t offset); - -static PyObject * -os_pread(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - int length; - Py_off_t offset; - - if (!PyArg_ParseTuple(args, - "iiO&:pread", - &fd, &length, Py_off_t_converter, &offset)) - goto exit; - return_value = os_pread_impl(module, fd, length, offset); - -exit: - return return_value; -} - static PyObject * os_pread_impl(PyModuleDef *module, int fd, int length, Py_off_t offset) -/*[clinic end generated code: output=7b62bf6c06e20ae8 input=084948dcbaa35d4c]*/ +/*[clinic end generated code: output=90d1fed87f68fa33 input=084948dcbaa35d4c]*/ { Py_ssize_t n; int async_err = 0; @@ -11571,46 +8309,9 @@ os.write -> Py_ssize_t Write a bytes object to a file descriptor. [clinic start generated code]*/ -PyDoc_STRVAR(os_write__doc__, -"write($module, fd, data, /)\n" -"--\n" -"\n" -"Write a bytes object to a file descriptor."); - -#define OS_WRITE_METHODDEF \ - {"write", (PyCFunction)os_write, METH_VARARGS, os_write__doc__}, - -static Py_ssize_t -os_write_impl(PyModuleDef *module, int fd, Py_buffer *data); - -static PyObject * -os_write(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - Py_buffer data = {NULL, NULL}; - Py_ssize_t _return_value; - - if (!PyArg_ParseTuple(args, - "iy*:write", - &fd, &data)) - goto exit; - _return_value = os_write_impl(module, fd, &data); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromSsize_t(_return_value); - -exit: - /* Cleanup for data */ - if (data.obj) - PyBuffer_Release(&data); - - return return_value; -} - static Py_ssize_t os_write_impl(PyModuleDef *module, int fd, Py_buffer *data) -/*[clinic end generated code: output=aeb96acfdd4d5112 input=3207e28963234f3c]*/ +/*[clinic end generated code: output=58845c93c9ee1dda input=3207e28963234f3c]*/ { Py_ssize_t size; int async_err = 0; @@ -11802,41 +8503,9 @@ Like stat(), but for an open file descri Equivalent to os.stat(fd). [clinic start generated code]*/ -PyDoc_STRVAR(os_fstat__doc__, -"fstat($module, /, fd)\n" -"--\n" -"\n" -"Perform a stat system call on the given file descriptor.\n" -"\n" -"Like stat(), but for an open file descriptor.\n" -"Equivalent to os.stat(fd)."); - -#define OS_FSTAT_METHODDEF \ - {"fstat", (PyCFunction)os_fstat, METH_VARARGS|METH_KEYWORDS, os_fstat__doc__}, - -static PyObject * -os_fstat_impl(PyModuleDef *module, int fd); - -static PyObject * -os_fstat(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"fd", NULL}; - int fd; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:fstat", _keywords, - &fd)) - goto exit; - return_value = os_fstat_impl(module, fd); - -exit: - return return_value; -} - static PyObject * os_fstat_impl(PyModuleDef *module, int fd) -/*[clinic end generated code: output=dae4a9678c7bd881 input=27e0e0ebbe5600c9]*/ +/*[clinic end generated code: output=d71fe98bf042b626 input=27e0e0ebbe5600c9]*/ { STRUCT_STAT st; int res; @@ -11870,44 +8539,9 @@ Return True if the file descriptor is an connected to the slave end of a terminal. [clinic start generated code]*/ -PyDoc_STRVAR(os_isatty__doc__, -"isatty($module, fd, /)\n" -"--\n" -"\n" -"Return True if the fd is connected to a terminal.\n" -"\n" -"Return True if the file descriptor is an open file descriptor\n" -"connected to the slave end of a terminal."); - -#define OS_ISATTY_METHODDEF \ - {"isatty", (PyCFunction)os_isatty, METH_VARARGS, os_isatty__doc__}, - -static int -os_isatty_impl(PyModuleDef *module, int fd); - -static PyObject * -os_isatty(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - int _return_value; - - if (!PyArg_ParseTuple(args, - "i:isatty", - &fd)) - goto exit; - _return_value = os_isatty_impl(module, fd); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyBool_FromLong((long)_return_value); - -exit: - return return_value; -} - static int os_isatty_impl(PyModuleDef *module, int fd) -/*[clinic end generated code: output=4bfadbfe22715097 input=08ce94aa1eaf7b5e]*/ +/*[clinic end generated code: output=acec9d3c29d16d33 input=08ce94aa1eaf7b5e]*/ { if (!_PyVerify_fd(fd)) return 0; @@ -11925,30 +8559,9 @@ Returns a tuple of two file descriptors: (read_fd, write_fd) [clinic start generated code]*/ -PyDoc_STRVAR(os_pipe__doc__, -"pipe($module, /)\n" -"--\n" -"\n" -"Create a pipe.\n" -"\n" -"Returns a tuple of two file descriptors:\n" -" (read_fd, write_fd)"); - -#define OS_PIPE_METHODDEF \ - {"pipe", (PyCFunction)os_pipe, METH_NOARGS, os_pipe__doc__}, - -static PyObject * -os_pipe_impl(PyModuleDef *module); - -static PyObject * -os_pipe(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_pipe_impl(module); -} - static PyObject * os_pipe_impl(PyModuleDef *module) -/*[clinic end generated code: output=0da2479f2266e774 input=02535e8c8fa6c4d4]*/ +/*[clinic end generated code: output=6b0cd3f868ec3c40 input=02535e8c8fa6c4d4]*/ { int fds[2]; #ifdef MS_WINDOWS @@ -12033,43 +8646,9 @@ flags can be constructed by ORing togeth O_NONBLOCK, O_CLOEXEC. [clinic start generated code]*/ -PyDoc_STRVAR(os_pipe2__doc__, -"pipe2($module, flags, /)\n" -"--\n" -"\n" -"Create a pipe with flags set atomically.\n" -"\n" -"Returns a tuple of two file descriptors:\n" -" (read_fd, write_fd)\n" -"\n" -"flags can be constructed by ORing together one or more of these values:\n" -"O_NONBLOCK, O_CLOEXEC."); - -#define OS_PIPE2_METHODDEF \ - {"pipe2", (PyCFunction)os_pipe2, METH_VARARGS, os_pipe2__doc__}, - -static PyObject * -os_pipe2_impl(PyModuleDef *module, int flags); - -static PyObject * -os_pipe2(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int flags; - - if (!PyArg_ParseTuple(args, - "i:pipe2", - &flags)) - goto exit; - return_value = os_pipe2_impl(module, flags); - -exit: - return return_value; -} - static PyObject * os_pipe2_impl(PyModuleDef *module, int flags) -/*[clinic end generated code: output=9e27c799ce19220b input=f261b6e7e63c6817]*/ +/*[clinic end generated code: output=c15b6075d0c6b2e7 input=f261b6e7e63c6817]*/ { int fds[2]; int res; @@ -12095,45 +8674,9 @@ Returns the total number of bytes writte buffers must be a sequence of bytes-like objects. [clinic start generated code]*/ -PyDoc_STRVAR(os_writev__doc__, -"writev($module, fd, buffers, /)\n" -"--\n" -"\n" -"Iterate over buffers, and write the contents of each to a file descriptor.\n" -"\n" -"Returns the total number of bytes written.\n" -"buffers must be a sequence of bytes-like objects."); - -#define OS_WRITEV_METHODDEF \ - {"writev", (PyCFunction)os_writev, METH_VARARGS, os_writev__doc__}, - -static Py_ssize_t -os_writev_impl(PyModuleDef *module, int fd, PyObject *buffers); - -static PyObject * -os_writev(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - PyObject *buffers; - Py_ssize_t _return_value; - - if (!PyArg_ParseTuple(args, - "iO:writev", - &fd, &buffers)) - goto exit; - _return_value = os_writev_impl(module, fd, buffers); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromSsize_t(_return_value); - -exit: - return return_value; -} - static Py_ssize_t os_writev_impl(PyModuleDef *module, int fd, PyObject *buffers) -/*[clinic end generated code: output=591c662dccbe4951 input=5b8d17fe4189d2fe]*/ +/*[clinic end generated code: output=a48925dbf2d5c238 input=5b8d17fe4189d2fe]*/ { int cnt; Py_ssize_t result; @@ -12183,51 +8726,9 @@ the file. Returns the number of bytes w current file offset. [clinic start generated code]*/ -PyDoc_STRVAR(os_pwrite__doc__, -"pwrite($module, fd, buffer, offset, /)\n" -"--\n" -"\n" -"Write bytes to a file descriptor starting at a particular offset.\n" -"\n" -"Write buffer to fd, starting at offset bytes from the beginning of\n" -"the file. Returns the number of bytes writte. Does not change the\n" -"current file offset."); - -#define OS_PWRITE_METHODDEF \ - {"pwrite", (PyCFunction)os_pwrite, METH_VARARGS, os_pwrite__doc__}, - -static Py_ssize_t -os_pwrite_impl(PyModuleDef *module, int fd, Py_buffer *buffer, Py_off_t offset); - -static PyObject * -os_pwrite(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - Py_buffer buffer = {NULL, NULL}; - Py_off_t offset; - Py_ssize_t _return_value; - - if (!PyArg_ParseTuple(args, - "iy*O&:pwrite", - &fd, &buffer, Py_off_t_converter, &offset)) - goto exit; - _return_value = os_pwrite_impl(module, fd, &buffer, offset); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromSsize_t(_return_value); - -exit: - /* Cleanup for buffer */ - if (buffer.obj) - PyBuffer_Release(&buffer); - - return return_value; -} - static Py_ssize_t os_pwrite_impl(PyModuleDef *module, int fd, Py_buffer *buffer, Py_off_t offset) -/*[clinic end generated code: output=ec9cc5b2238e96a7 input=19903f1b3dd26377]*/ +/*[clinic end generated code: output=95225f3b496feaf3 input=19903f1b3dd26377]*/ { Py_ssize_t size; int async_err = 0; @@ -12267,48 +8768,9 @@ dir_fd may not be implemented on your pl If it is unavailable, using it will raise a NotImplementedError. [clinic start generated code]*/ -PyDoc_STRVAR(os_mkfifo__doc__, -"mkfifo($module, /, path, mode=438, *, dir_fd=None)\n" -"--\n" -"\n" -"Create a \"fifo\" (a POSIX named pipe).\n" -"\n" -"If dir_fd is not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that directory.\n" -"dir_fd may not be implemented on your platform.\n" -" If it is unavailable, using it will raise a NotImplementedError."); - -#define OS_MKFIFO_METHODDEF \ - {"mkfifo", (PyCFunction)os_mkfifo, METH_VARARGS|METH_KEYWORDS, os_mkfifo__doc__}, - -static PyObject * -os_mkfifo_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd); - -static PyObject * -os_mkfifo(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "mode", "dir_fd", NULL}; - path_t path = PATH_T_INITIALIZE("mkfifo", "path", 0, 0); - int mode = 438; - int dir_fd = DEFAULT_DIR_FD; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&|i$O&:mkfifo", _keywords, - path_converter, &path, &mode, MKFIFOAT_DIR_FD_CONVERTER, &dir_fd)) - goto exit; - return_value = os_mkfifo_impl(module, &path, mode, dir_fd); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_mkfifo_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd) -/*[clinic end generated code: output=b3321927546893d0 input=73032e98a36e0e19]*/ +/*[clinic end generated code: output=8f5f5e72c630049a input=73032e98a36e0e19]*/ { int result; int async_err = 0; @@ -12357,56 +8819,9 @@ dir_fd may not be implemented on your pl If it is unavailable, using it will raise a NotImplementedError. [clinic start generated code]*/ -PyDoc_STRVAR(os_mknod__doc__, -"mknod($module, /, path, mode=384, device=0, *, dir_fd=None)\n" -"--\n" -"\n" -"Create a node in the file system.\n" -"\n" -"Create a node in the file system (file, device special file or named pipe)\n" -"at path. mode specifies both the permissions to use and the\n" -"type of node to be created, being combined (bitwise OR) with one of\n" -"S_IFREG, S_IFCHR, S_IFBLK, and S_IFIFO. If S_IFCHR or S_IFBLK is set on mode,\n" -"device defines the newly created device special file (probably using\n" -"os.makedev()). Otherwise device is ignored.\n" -"\n" -"If dir_fd is not None, it should be a file descriptor open to a directory,\n" -" and path should be relative; path will then be relative to that directory.\n" -"dir_fd may not be implemented on your platform.\n" -" If it is unavailable, using it will raise a NotImplementedError."); - -#define OS_MKNOD_METHODDEF \ - {"mknod", (PyCFunction)os_mknod, METH_VARARGS|METH_KEYWORDS, os_mknod__doc__}, - -static PyObject * -os_mknod_impl(PyModuleDef *module, path_t *path, int mode, dev_t device, int dir_fd); - -static PyObject * -os_mknod(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "mode", "device", "dir_fd", NULL}; - path_t path = PATH_T_INITIALIZE("mknod", "path", 0, 0); - int mode = 384; - dev_t device = 0; - int dir_fd = DEFAULT_DIR_FD; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&|iO&$O&:mknod", _keywords, - path_converter, &path, &mode, _Py_Dev_Converter, &device, MKNODAT_DIR_FD_CONVERTER, &dir_fd)) - goto exit; - return_value = os_mknod_impl(module, &path, mode, device, dir_fd); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_mknod_impl(PyModuleDef *module, path_t *path, int mode, dev_t device, int dir_fd) -/*[clinic end generated code: output=f71d54eaf9bb6f1a input=ee44531551a4d83b]*/ +/*[clinic end generated code: output=f7f813e8847de12f input=ee44531551a4d83b]*/ { int result; int async_err = 0; @@ -12440,41 +8855,9 @@ os.major -> unsigned_int Extracts a device major number from a raw device number. [clinic start generated code]*/ -PyDoc_STRVAR(os_major__doc__, -"major($module, device, /)\n" -"--\n" -"\n" -"Extracts a device major number from a raw device number."); - -#define OS_MAJOR_METHODDEF \ - {"major", (PyCFunction)os_major, METH_VARARGS, os_major__doc__}, - -static unsigned int -os_major_impl(PyModuleDef *module, dev_t device); - -static PyObject * -os_major(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - dev_t device; - unsigned int _return_value; - - if (!PyArg_ParseTuple(args, - "O&:major", - _Py_Dev_Converter, &device)) - goto exit; - _return_value = os_major_impl(module, device); - if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromUnsignedLong((unsigned long)_return_value); - -exit: - return return_value; -} - static unsigned int os_major_impl(PyModuleDef *module, dev_t device) -/*[clinic end generated code: output=a2d06e908ebf95b5 input=1e16a4d30c4d4462]*/ +/*[clinic end generated code: output=ba55693ab49bac34 input=1e16a4d30c4d4462]*/ { return major(device); } @@ -12489,41 +8872,9 @@ os.minor -> unsigned_int Extracts a device minor number from a raw device number. [clinic start generated code]*/ -PyDoc_STRVAR(os_minor__doc__, -"minor($module, device, /)\n" -"--\n" -"\n" -"Extracts a device minor number from a raw device number."); - -#define OS_MINOR_METHODDEF \ - {"minor", (PyCFunction)os_minor, METH_VARARGS, os_minor__doc__}, - -static unsigned int -os_minor_impl(PyModuleDef *module, dev_t device); - -static PyObject * -os_minor(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - dev_t device; - unsigned int _return_value; - - if (!PyArg_ParseTuple(args, - "O&:minor", - _Py_Dev_Converter, &device)) - goto exit; - _return_value = os_minor_impl(module, device); - if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromUnsignedLong((unsigned long)_return_value); - -exit: - return return_value; -} - static unsigned int os_minor_impl(PyModuleDef *module, dev_t device) -/*[clinic end generated code: output=6332287ee3f006e2 input=0842c6d23f24c65e]*/ +/*[clinic end generated code: output=2867219ebf274e27 input=0842c6d23f24c65e]*/ { return minor(device); } @@ -12539,42 +8890,9 @@ os.makedev -> dev_t Composes a raw device number from the major and minor device numbers. [clinic start generated code]*/ -PyDoc_STRVAR(os_makedev__doc__, -"makedev($module, major, minor, /)\n" -"--\n" -"\n" -"Composes a raw device number from the major and minor device numbers."); - -#define OS_MAKEDEV_METHODDEF \ - {"makedev", (PyCFunction)os_makedev, METH_VARARGS, os_makedev__doc__}, - -static dev_t -os_makedev_impl(PyModuleDef *module, int major, int minor); - -static PyObject * -os_makedev(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int major; - int minor; - dev_t _return_value; - - if (!PyArg_ParseTuple(args, - "ii:makedev", - &major, &minor)) - goto exit; - _return_value = os_makedev_impl(module, major, minor); - if ((_return_value == (dev_t)-1) && PyErr_Occurred()) - goto exit; - return_value = _PyLong_FromDev(_return_value); - -exit: - return return_value; -} - static dev_t os_makedev_impl(PyModuleDef *module, int major, int minor) -/*[clinic end generated code: output=38e9a9774c96511a input=4b9fd8fc73cbe48f]*/ +/*[clinic end generated code: output=7cb6264352437660 input=4b9fd8fc73cbe48f]*/ { return makedev(major, minor); } @@ -12592,38 +8910,9 @@ os.ftruncate Truncate a file, specified by file descriptor, to a specific length. [clinic start generated code]*/ -PyDoc_STRVAR(os_ftruncate__doc__, -"ftruncate($module, fd, length, /)\n" -"--\n" -"\n" -"Truncate a file, specified by file descriptor, to a specific length."); - -#define OS_FTRUNCATE_METHODDEF \ - {"ftruncate", (PyCFunction)os_ftruncate, METH_VARARGS, os_ftruncate__doc__}, - -static PyObject * -os_ftruncate_impl(PyModuleDef *module, int fd, Py_off_t length); - -static PyObject * -os_ftruncate(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - Py_off_t length; - - if (!PyArg_ParseTuple(args, - "iO&:ftruncate", - &fd, Py_off_t_converter, &length)) - goto exit; - return_value = os_ftruncate_impl(module, fd, length); - -exit: - return return_value; -} - static PyObject * os_ftruncate_impl(PyModuleDef *module, int fd, Py_off_t length) -/*[clinic end generated code: output=62326766cb9b76bf input=63b43641e52818f2]*/ +/*[clinic end generated code: output=3666f401d76bf834 input=63b43641e52818f2]*/ { int result; int async_err = 0; @@ -12653,45 +8942,9 @@ On some platforms, path may also be spec If this functionality is unavailable, using it raises an exception. [clinic start generated code]*/ -PyDoc_STRVAR(os_truncate__doc__, -"truncate($module, /, path, length)\n" -"--\n" -"\n" -"Truncate a file, specified by path, to a specific length.\n" -"\n" -"On some platforms, path may also be specified as an open file descriptor.\n" -" If this functionality is unavailable, using it raises an exception."); - -#define OS_TRUNCATE_METHODDEF \ - {"truncate", (PyCFunction)os_truncate, METH_VARARGS|METH_KEYWORDS, os_truncate__doc__}, - -static PyObject * -os_truncate_impl(PyModuleDef *module, path_t *path, Py_off_t length); - -static PyObject * -os_truncate(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "length", NULL}; - path_t path = PATH_T_INITIALIZE("truncate", "path", 0, PATH_HAVE_FTRUNCATE); - Py_off_t length; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&O&:truncate", _keywords, - path_converter, &path, Py_off_t_converter, &length)) - goto exit; - return_value = os_truncate_impl(module, &path, length); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_truncate_impl(PyModuleDef *module, path_t *path, Py_off_t length) -/*[clinic end generated code: output=6bd76262d2e027c6 input=77229cf0b50a9b77]*/ +/*[clinic end generated code: output=f60a9e08370e9e2e input=77229cf0b50a9b77]*/ { int result; @@ -12735,42 +8988,9 @@ Ensure that the file specified by fd enc starting at offset bytes from the beginning and continuing for length bytes. [clinic start generated code]*/ -PyDoc_STRVAR(os_posix_fallocate__doc__, -"posix_fallocate($module, fd, offset, length, /)\n" -"--\n" -"\n" -"Ensure a file has allocated at least a particular number of bytes on disk.\n" -"\n" -"Ensure that the file specified by fd encompasses a range of bytes\n" -"starting at offset bytes from the beginning and continuing for length bytes."); - -#define OS_POSIX_FALLOCATE_METHODDEF \ - {"posix_fallocate", (PyCFunction)os_posix_fallocate, METH_VARARGS, os_posix_fallocate__doc__}, - -static PyObject * -os_posix_fallocate_impl(PyModuleDef *module, int fd, Py_off_t offset, Py_off_t length); - -static PyObject * -os_posix_fallocate(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - Py_off_t offset; - Py_off_t length; - - if (!PyArg_ParseTuple(args, - "iO&O&:posix_fallocate", - &fd, Py_off_t_converter, &offset, Py_off_t_converter, &length)) - goto exit; - return_value = os_posix_fallocate_impl(module, fd, offset, length); - -exit: - return return_value; -} - static PyObject * os_posix_fallocate_impl(PyModuleDef *module, int fd, Py_off_t offset, Py_off_t length) -/*[clinic end generated code: output=0cd702d2065c79db input=d7a2ef0ab2ca52fb]*/ +/*[clinic end generated code: output=8ae5f7837004d454 input=d7a2ef0ab2ca52fb]*/ { int result; int async_err = 0; @@ -12809,48 +9029,9 @@ POSIX_FADV_RANDOM, POSIX_FADV_NOREUSE, P POSIX_FADV_DONTNEED. [clinic start generated code]*/ -PyDoc_STRVAR(os_posix_fadvise__doc__, -"posix_fadvise($module, fd, offset, length, advice, /)\n" -"--\n" -"\n" -"Announce an intention to access data in a specific pattern.\n" -"\n" -"Announce an intention to access data in a specific pattern, thus allowing\n" -"the kernel to make optimizations.\n" -"The advice applies to the region of the file specified by fd starting at\n" -"offset and continuing for length bytes.\n" -"advice is one of POSIX_FADV_NORMAL, POSIX_FADV_SEQUENTIAL,\n" -"POSIX_FADV_RANDOM, POSIX_FADV_NOREUSE, POSIX_FADV_WILLNEED, or\n" -"POSIX_FADV_DONTNEED."); - -#define OS_POSIX_FADVISE_METHODDEF \ - {"posix_fadvise", (PyCFunction)os_posix_fadvise, METH_VARARGS, os_posix_fadvise__doc__}, - -static PyObject * -os_posix_fadvise_impl(PyModuleDef *module, int fd, Py_off_t offset, Py_off_t length, int advice); - -static PyObject * -os_posix_fadvise(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - Py_off_t offset; - Py_off_t length; - int advice; - - if (!PyArg_ParseTuple(args, - "iO&O&i:posix_fadvise", - &fd, Py_off_t_converter, &offset, Py_off_t_converter, &length, &advice)) - goto exit; - return_value = os_posix_fadvise_impl(module, fd, offset, length, advice); - -exit: - return return_value; -} - static PyObject * os_posix_fadvise_impl(PyModuleDef *module, int fd, Py_off_t offset, Py_off_t length, int advice) -/*[clinic end generated code: output=dad93f32c04dd4f7 input=0fbe554edc2f04b5]*/ +/*[clinic end generated code: output=0e3f09f651661257 input=0fbe554edc2f04b5]*/ { int result; int async_err = 0; @@ -12899,38 +9080,9 @@ os.putenv Change or add an environment variable. [clinic start generated code]*/ -PyDoc_STRVAR(os_putenv__doc__, -"putenv($module, name, value, /)\n" -"--\n" -"\n" -"Change or add an environment variable."); - -#define OS_PUTENV_METHODDEF \ - {"putenv", (PyCFunction)os_putenv, METH_VARARGS, os_putenv__doc__}, - -static PyObject * -os_putenv_impl(PyModuleDef *module, PyObject *name, PyObject *value); - -static PyObject * -os_putenv(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *name; - PyObject *value; - - if (!PyArg_ParseTuple(args, - "UU:putenv", - &name, &value)) - goto exit; - return_value = os_putenv_impl(module, name, value); - -exit: - return return_value; -} - static PyObject * os_putenv_impl(PyModuleDef *module, PyObject *name, PyObject *value) -/*[clinic end generated code: output=5ce9ef9b15606e7e input=ba586581c2e6105f]*/ +/*[clinic end generated code: output=a2438cf95e5a0c1c input=ba586581c2e6105f]*/ { wchar_t *env; @@ -12972,43 +9124,9 @@ os.putenv Change or add an environment variable. [clinic start generated code]*/ -PyDoc_STRVAR(os_putenv__doc__, -"putenv($module, name, value, /)\n" -"--\n" -"\n" -"Change or add an environment variable."); - -#define OS_PUTENV_METHODDEF \ - {"putenv", (PyCFunction)os_putenv, METH_VARARGS, os_putenv__doc__}, - -static PyObject * -os_putenv_impl(PyModuleDef *module, PyObject *name, PyObject *value); - -static PyObject * -os_putenv(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *name = NULL; - PyObject *value = NULL; - - if (!PyArg_ParseTuple(args, - "O&O&:putenv", - PyUnicode_FSConverter, &name, PyUnicode_FSConverter, &value)) - goto exit; - return_value = os_putenv_impl(module, name, value); - -exit: - /* Cleanup for name */ - Py_XDECREF(name); - /* Cleanup for value */ - Py_XDECREF(value); - - return return_value; -} - static PyObject * os_putenv_impl(PyModuleDef *module, PyObject *name, PyObject *value) -/*[clinic end generated code: output=85ab223393dc7afd input=a97bc6152f688d31]*/ +/*[clinic end generated code: output=a2438cf95e5a0c1c input=a97bc6152f688d31]*/ { PyObject *bytes = NULL; char *env; @@ -13043,40 +9161,9 @@ os.unsetenv Delete an environment variable. [clinic start generated code]*/ -PyDoc_STRVAR(os_unsetenv__doc__, -"unsetenv($module, name, /)\n" -"--\n" -"\n" -"Delete an environment variable."); - -#define OS_UNSETENV_METHODDEF \ - {"unsetenv", (PyCFunction)os_unsetenv, METH_VARARGS, os_unsetenv__doc__}, - -static PyObject * -os_unsetenv_impl(PyModuleDef *module, PyObject *name); - -static PyObject * -os_unsetenv(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *name = NULL; - - if (!PyArg_ParseTuple(args, - "O&:unsetenv", - PyUnicode_FSConverter, &name)) - goto exit; - return_value = os_unsetenv_impl(module, name); - -exit: - /* Cleanup for name */ - Py_XDECREF(name); - - return return_value; -} - static PyObject * os_unsetenv_impl(PyModuleDef *module, PyObject *name) -/*[clinic end generated code: output=91318c995f9a0767 input=2bb5288a599c7107]*/ +/*[clinic end generated code: output=25994b57016a2dc9 input=2bb5288a599c7107]*/ { #ifndef HAVE_BROKEN_UNSETENV int err; @@ -13113,37 +9200,9 @@ os.strerror Translate an error code to a message string. [clinic start generated code]*/ -PyDoc_STRVAR(os_strerror__doc__, -"strerror($module, code, /)\n" -"--\n" -"\n" -"Translate an error code to a message string."); - -#define OS_STRERROR_METHODDEF \ - {"strerror", (PyCFunction)os_strerror, METH_VARARGS, os_strerror__doc__}, - -static PyObject * -os_strerror_impl(PyModuleDef *module, int code); - -static PyObject * -os_strerror(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int code; - - if (!PyArg_ParseTuple(args, - "i:strerror", - &code)) - goto exit; - return_value = os_strerror_impl(module, code); - -exit: - return return_value; -} - static PyObject * os_strerror_impl(PyModuleDef *module, int code) -/*[clinic end generated code: output=8665c70bb2ca4720 input=75a8673d97915a91]*/ +/*[clinic end generated code: output=0280c6af51e5c9fe input=75a8673d97915a91]*/ { char *message = strerror(code); if (message == NULL) { @@ -13166,41 +9225,9 @@ os.WCOREDUMP -> bool Return True if the process returning status was dumped to a core file. [clinic start generated code]*/ -PyDoc_STRVAR(os_WCOREDUMP__doc__, -"WCOREDUMP($module, status, /)\n" -"--\n" -"\n" -"Return True if the process returning status was dumped to a core file."); - -#define OS_WCOREDUMP_METHODDEF \ - {"WCOREDUMP", (PyCFunction)os_WCOREDUMP, METH_VARARGS, os_WCOREDUMP__doc__}, - -static int -os_WCOREDUMP_impl(PyModuleDef *module, int status); - -static PyObject * -os_WCOREDUMP(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int status; - int _return_value; - - if (!PyArg_ParseTuple(args, - "i:WCOREDUMP", - &status)) - goto exit; - _return_value = os_WCOREDUMP_impl(module, status); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyBool_FromLong((long)_return_value); - -exit: - return return_value; -} - static int os_WCOREDUMP_impl(PyModuleDef *module, int status) -/*[clinic end generated code: output=e04d55c09c299828 input=8b05e7ab38528d04]*/ +/*[clinic end generated code: output=134f70bbe63fbf41 input=8b05e7ab38528d04]*/ { WAIT_TYPE wait_status; WAIT_STATUS_INT(wait_status) = status; @@ -13221,45 +9248,9 @@ Return True if the process returning sta job control stop. [clinic start generated code]*/ -PyDoc_STRVAR(os_WIFCONTINUED__doc__, -"WIFCONTINUED($module, /, status)\n" -"--\n" -"\n" -"Return True if a particular process was continued from a job control stop.\n" -"\n" -"Return True if the process returning status was continued from a\n" -"job control stop."); - -#define OS_WIFCONTINUED_METHODDEF \ - {"WIFCONTINUED", (PyCFunction)os_WIFCONTINUED, METH_VARARGS|METH_KEYWORDS, os_WIFCONTINUED__doc__}, - -static int -os_WIFCONTINUED_impl(PyModuleDef *module, int status); - -static PyObject * -os_WIFCONTINUED(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"status", NULL}; - int status; - int _return_value; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:WIFCONTINUED", _keywords, - &status)) - goto exit; - _return_value = os_WIFCONTINUED_impl(module, status); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyBool_FromLong((long)_return_value); - -exit: - return return_value; -} - static int os_WIFCONTINUED_impl(PyModuleDef *module, int status) -/*[clinic end generated code: output=9c4e6105a4520ab5 input=e777e7d38eb25bd9]*/ +/*[clinic end generated code: output=9cdd26543ebb6dcd input=e777e7d38eb25bd9]*/ { WAIT_TYPE wait_status; WAIT_STATUS_INT(wait_status) = status; @@ -13277,42 +9268,9 @@ os.WIFSTOPPED -> bool Return True if the process returning status was stopped. [clinic start generated code]*/ -PyDoc_STRVAR(os_WIFSTOPPED__doc__, -"WIFSTOPPED($module, /, status)\n" -"--\n" -"\n" -"Return True if the process returning status was stopped."); - -#define OS_WIFSTOPPED_METHODDEF \ - {"WIFSTOPPED", (PyCFunction)os_WIFSTOPPED, METH_VARARGS|METH_KEYWORDS, os_WIFSTOPPED__doc__}, - -static int -os_WIFSTOPPED_impl(PyModuleDef *module, int status); - -static PyObject * -os_WIFSTOPPED(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"status", NULL}; - int status; - int _return_value; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:WIFSTOPPED", _keywords, - &status)) - goto exit; - _return_value = os_WIFSTOPPED_impl(module, status); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyBool_FromLong((long)_return_value); - -exit: - return return_value; -} - static int os_WIFSTOPPED_impl(PyModuleDef *module, int status) -/*[clinic end generated code: output=e0de2da8ec9593ff input=043cb7f1289ef904]*/ +/*[clinic end generated code: output=73bf35e44994a724 input=043cb7f1289ef904]*/ { WAIT_TYPE wait_status; WAIT_STATUS_INT(wait_status) = status; @@ -13330,42 +9288,9 @@ os.WIFSIGNALED -> bool Return True if the process returning status was terminated by a signal. [clinic start generated code]*/ -PyDoc_STRVAR(os_WIFSIGNALED__doc__, -"WIFSIGNALED($module, /, status)\n" -"--\n" -"\n" -"Return True if the process returning status was terminated by a signal."); - -#define OS_WIFSIGNALED_METHODDEF \ - {"WIFSIGNALED", (PyCFunction)os_WIFSIGNALED, METH_VARARGS|METH_KEYWORDS, os_WIFSIGNALED__doc__}, - -static int -os_WIFSIGNALED_impl(PyModuleDef *module, int status); - -static PyObject * -os_WIFSIGNALED(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"status", NULL}; - int status; - int _return_value; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:WIFSIGNALED", _keywords, - &status)) - goto exit; - _return_value = os_WIFSIGNALED_impl(module, status); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyBool_FromLong((long)_return_value); - -exit: - return return_value; -} - static int os_WIFSIGNALED_impl(PyModuleDef *module, int status) -/*[clinic end generated code: output=f14d106558f406be input=d55ba7cc9ce5dc43]*/ +/*[clinic end generated code: output=2697975771872420 input=d55ba7cc9ce5dc43]*/ { WAIT_TYPE wait_status; WAIT_STATUS_INT(wait_status) = status; @@ -13383,42 +9308,9 @@ os.WIFEXITED -> bool Return True if the process returning status exited via the exit() system call. [clinic start generated code]*/ -PyDoc_STRVAR(os_WIFEXITED__doc__, -"WIFEXITED($module, /, status)\n" -"--\n" -"\n" -"Return True if the process returning status exited via the exit() system call."); - -#define OS_WIFEXITED_METHODDEF \ - {"WIFEXITED", (PyCFunction)os_WIFEXITED, METH_VARARGS|METH_KEYWORDS, os_WIFEXITED__doc__}, - -static int -os_WIFEXITED_impl(PyModuleDef *module, int status); - -static PyObject * -os_WIFEXITED(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"status", NULL}; - int status; - int _return_value; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:WIFEXITED", _keywords, - &status)) - goto exit; - _return_value = os_WIFEXITED_impl(module, status); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyBool_FromLong((long)_return_value); - -exit: - return return_value; -} - static int os_WIFEXITED_impl(PyModuleDef *module, int status) -/*[clinic end generated code: output=2f76087d53721255 input=d63775a6791586c0]*/ +/*[clinic end generated code: output=ca8f8c61f0b8532e input=d63775a6791586c0]*/ { WAIT_TYPE wait_status; WAIT_STATUS_INT(wait_status) = status; @@ -13436,42 +9328,9 @@ os.WEXITSTATUS -> int Return the process return code from status. [clinic start generated code]*/ -PyDoc_STRVAR(os_WEXITSTATUS__doc__, -"WEXITSTATUS($module, /, status)\n" -"--\n" -"\n" -"Return the process return code from status."); - -#define OS_WEXITSTATUS_METHODDEF \ - {"WEXITSTATUS", (PyCFunction)os_WEXITSTATUS, METH_VARARGS|METH_KEYWORDS, os_WEXITSTATUS__doc__}, - -static int -os_WEXITSTATUS_impl(PyModuleDef *module, int status); - -static PyObject * -os_WEXITSTATUS(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"status", NULL}; - int status; - int _return_value; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:WEXITSTATUS", _keywords, - &status)) - goto exit; - _return_value = os_WEXITSTATUS_impl(module, status); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromLong((long)_return_value); - -exit: - return return_value; -} - static int os_WEXITSTATUS_impl(PyModuleDef *module, int status) -/*[clinic end generated code: output=13b6c270e2a326b1 input=e1fb4944e377585b]*/ +/*[clinic end generated code: output=ea54da23d9e0f6af input=e1fb4944e377585b]*/ { WAIT_TYPE wait_status; WAIT_STATUS_INT(wait_status) = status; @@ -13489,42 +9348,9 @@ os.WTERMSIG -> int Return the signal that terminated the process that provided the status value. [clinic start generated code]*/ -PyDoc_STRVAR(os_WTERMSIG__doc__, -"WTERMSIG($module, /, status)\n" -"--\n" -"\n" -"Return the signal that terminated the process that provided the status value."); - -#define OS_WTERMSIG_METHODDEF \ - {"WTERMSIG", (PyCFunction)os_WTERMSIG, METH_VARARGS|METH_KEYWORDS, os_WTERMSIG__doc__}, - -static int -os_WTERMSIG_impl(PyModuleDef *module, int status); - -static PyObject * -os_WTERMSIG(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"status", NULL}; - int status; - int _return_value; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:WTERMSIG", _keywords, - &status)) - goto exit; - _return_value = os_WTERMSIG_impl(module, status); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromLong((long)_return_value); - -exit: - return return_value; -} - static int os_WTERMSIG_impl(PyModuleDef *module, int status) -/*[clinic end generated code: output=bf1fd4b002d0a9ed input=727fd7f84ec3f243]*/ +/*[clinic end generated code: output=4d25367026cb852c input=727fd7f84ec3f243]*/ { WAIT_TYPE wait_status; WAIT_STATUS_INT(wait_status) = status; @@ -13542,42 +9368,9 @@ os.WSTOPSIG -> int Return the signal that stopped the process that provided the status value. [clinic start generated code]*/ -PyDoc_STRVAR(os_WSTOPSIG__doc__, -"WSTOPSIG($module, /, status)\n" -"--\n" -"\n" -"Return the signal that stopped the process that provided the status value."); - -#define OS_WSTOPSIG_METHODDEF \ - {"WSTOPSIG", (PyCFunction)os_WSTOPSIG, METH_VARARGS|METH_KEYWORDS, os_WSTOPSIG__doc__}, - -static int -os_WSTOPSIG_impl(PyModuleDef *module, int status); - -static PyObject * -os_WSTOPSIG(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"status", NULL}; - int status; - int _return_value; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:WSTOPSIG", _keywords, - &status)) - goto exit; - _return_value = os_WSTOPSIG_impl(module, status); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromLong((long)_return_value); - -exit: - return return_value; -} - static int os_WSTOPSIG_impl(PyModuleDef *module, int status) -/*[clinic end generated code: output=92e1647d29ee0549 input=46ebf1d1b293c5c1]*/ +/*[clinic end generated code: output=54eb9c13b001adb4 input=46ebf1d1b293c5c1]*/ { WAIT_TYPE wait_status; WAIT_STATUS_INT(wait_status) = status; @@ -13587,39 +9380,6 @@ os_WSTOPSIG_impl(PyModuleDef *module, in #endif /* HAVE_SYS_WAIT_H */ -#ifndef OS_WCOREDUMP_METHODDEF -#define OS_WCOREDUMP_METHODDEF -#endif /* OS_WCOREDUMP_METHODDEF */ - -#ifndef OS_WIFCONTINUED_METHODDEF -#define OS_WIFCONTINUED_METHODDEF -#endif /* OS_WIFCONTINUED_METHODDEF */ - -#ifndef OS_WIFSTOPPED_METHODDEF -#define OS_WIFSTOPPED_METHODDEF -#endif /* OS_WIFSTOPPED_METHODDEF */ - -#ifndef OS_WIFSIGNALED_METHODDEF -#define OS_WIFSIGNALED_METHODDEF -#endif /* OS_WIFSIGNALED_METHODDEF */ - -#ifndef OS_WIFEXITED_METHODDEF -#define OS_WIFEXITED_METHODDEF -#endif /* OS_WIFEXITED_METHODDEF */ - -#ifndef OS_WEXITSTATUS_METHODDEF -#define OS_WEXITSTATUS_METHODDEF -#endif /* OS_WEXITSTATUS_METHODDEF */ - -#ifndef OS_WTERMSIG_METHODDEF -#define OS_WTERMSIG_METHODDEF -#endif /* OS_WTERMSIG_METHODDEF */ - -#ifndef OS_WSTOPSIG_METHODDEF -#define OS_WSTOPSIG_METHODDEF -#endif /* OS_WSTOPSIG_METHODDEF */ - - #if defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H) #ifdef _SCO_DS /* SCO OpenServer 5.0 and later requires _SVID3 before it reveals the @@ -13682,39 +9442,9 @@ Perform an fstatvfs system call on the g Equivalent to statvfs(fd). [clinic start generated code]*/ -PyDoc_STRVAR(os_fstatvfs__doc__, -"fstatvfs($module, fd, /)\n" -"--\n" -"\n" -"Perform an fstatvfs system call on the given fd.\n" -"\n" -"Equivalent to statvfs(fd)."); - -#define OS_FSTATVFS_METHODDEF \ - {"fstatvfs", (PyCFunction)os_fstatvfs, METH_VARARGS, os_fstatvfs__doc__}, - -static PyObject * -os_fstatvfs_impl(PyModuleDef *module, int fd); - -static PyObject * -os_fstatvfs(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - - if (!PyArg_ParseTuple(args, - "i:fstatvfs", - &fd)) - goto exit; - return_value = os_fstatvfs_impl(module, fd); - -exit: - return return_value; -} - static PyObject * os_fstatvfs_impl(PyModuleDef *module, int fd) -/*[clinic end generated code: output=0e32bf07f946ec0d input=d8122243ac50975e]*/ +/*[clinic end generated code: output=584a94a754497ac0 input=d8122243ac50975e]*/ { int result; int async_err = 0; @@ -13748,45 +9478,9 @@ On some platforms, path may also be spec If this functionality is unavailable, using it raises an exception. [clinic start generated code]*/ -PyDoc_STRVAR(os_statvfs__doc__, -"statvfs($module, /, path)\n" -"--\n" -"\n" -"Perform a statvfs system call on the given path.\n" -"\n" -"path may always be specified as a string.\n" -"On some platforms, path may also be specified as an open file descriptor.\n" -" If this functionality is unavailable, using it raises an exception."); - -#define OS_STATVFS_METHODDEF \ - {"statvfs", (PyCFunction)os_statvfs, METH_VARARGS|METH_KEYWORDS, os_statvfs__doc__}, - -static PyObject * -os_statvfs_impl(PyModuleDef *module, path_t *path); - -static PyObject * -os_statvfs(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", NULL}; - path_t path = PATH_T_INITIALIZE("statvfs", "path", 0, PATH_HAVE_FSTATVFS); - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&:statvfs", _keywords, - path_converter, &path)) - goto exit; - return_value = os_statvfs_impl(module, &path); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_statvfs_impl(PyModuleDef *module, path_t *path) -/*[clinic end generated code: output=00ff54983360b446 input=3f5c35791c669bd9]*/ +/*[clinic end generated code: output=5ced07a2cf931f41 input=3f5c35791c669bd9]*/ { int result; struct statvfs st; @@ -13826,38 +9520,9 @@ os._getdiskusage Return disk usage statistics about the given path as a (total, free) tuple. [clinic start generated code]*/ -PyDoc_STRVAR(os__getdiskusage__doc__, -"_getdiskusage($module, /, path)\n" -"--\n" -"\n" -"Return disk usage statistics about the given path as a (total, free) tuple."); - -#define OS__GETDISKUSAGE_METHODDEF \ - {"_getdiskusage", (PyCFunction)os__getdiskusage, METH_VARARGS|METH_KEYWORDS, os__getdiskusage__doc__}, - -static PyObject * -os__getdiskusage_impl(PyModuleDef *module, Py_UNICODE *path); - -static PyObject * -os__getdiskusage(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", NULL}; - Py_UNICODE *path; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "u:_getdiskusage", _keywords, - &path)) - goto exit; - return_value = os__getdiskusage_impl(module, path); - -exit: - return return_value; -} - static PyObject * os__getdiskusage_impl(PyModuleDef *module, Py_UNICODE *path) -/*[clinic end generated code: output=054c972179b13708 input=6458133aed893c78]*/ +/*[clinic end generated code: output=60a9cf33449db1dd input=6458133aed893c78]*/ { BOOL retval; ULARGE_INTEGER _, total, free; @@ -14041,44 +9706,9 @@ Return the configuration limit name for If there is no limit, return -1. [clinic start generated code]*/ -PyDoc_STRVAR(os_fpathconf__doc__, -"fpathconf($module, fd, name, /)\n" -"--\n" -"\n" -"Return the configuration limit name for the file descriptor fd.\n" -"\n" -"If there is no limit, return -1."); - -#define OS_FPATHCONF_METHODDEF \ - {"fpathconf", (PyCFunction)os_fpathconf, METH_VARARGS, os_fpathconf__doc__}, - -static long -os_fpathconf_impl(PyModuleDef *module, int fd, int name); - -static PyObject * -os_fpathconf(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - int name; - long _return_value; - - if (!PyArg_ParseTuple(args, - "iO&:fpathconf", - &fd, conv_path_confname, &name)) - goto exit; - _return_value = os_fpathconf_impl(module, fd, name); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromLong(_return_value); - -exit: - return return_value; -} - static long os_fpathconf_impl(PyModuleDef *module, int fd, int name) -/*[clinic end generated code: output=3bf04b40e0523a8c input=5942a024d3777810]*/ +/*[clinic end generated code: output=082b2922d4441de7 input=5942a024d3777810]*/ { long limit; @@ -14105,50 +9735,9 @@ On some platforms, path may also be spec If this functionality is unavailable, using it raises an exception. [clinic start generated code]*/ -PyDoc_STRVAR(os_pathconf__doc__, -"pathconf($module, /, path, name)\n" -"--\n" -"\n" -"Return the configuration limit name for the file or directory path.\n" -"\n" -"If there is no limit, return -1.\n" -"On some platforms, path may also be specified as an open file descriptor.\n" -" If this functionality is unavailable, using it raises an exception."); - -#define OS_PATHCONF_METHODDEF \ - {"pathconf", (PyCFunction)os_pathconf, METH_VARARGS|METH_KEYWORDS, os_pathconf__doc__}, - -static long -os_pathconf_impl(PyModuleDef *module, path_t *path, int name); - -static PyObject * -os_pathconf(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "name", NULL}; - path_t path = PATH_T_INITIALIZE("pathconf", "path", 0, PATH_HAVE_FPATHCONF); - int name; - long _return_value; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&O&:pathconf", _keywords, - path_converter, &path, conv_path_confname, &name)) - goto exit; - _return_value = os_pathconf_impl(module, &path, name); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromLong(_return_value); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static long os_pathconf_impl(PyModuleDef *module, path_t *path, int name) -/*[clinic end generated code: output=1a53e125b6cf63e4 input=bc3e2a985af27e5e]*/ +/*[clinic end generated code: output=3713029e9501f5ab input=bc3e2a985af27e5e]*/ { long limit; @@ -14343,37 +9932,9 @@ os.confstr Return a string-valued system configuration variable. [clinic start generated code]*/ -PyDoc_STRVAR(os_confstr__doc__, -"confstr($module, name, /)\n" -"--\n" -"\n" -"Return a string-valued system configuration variable."); - -#define OS_CONFSTR_METHODDEF \ - {"confstr", (PyCFunction)os_confstr, METH_VARARGS, os_confstr__doc__}, - -static PyObject * -os_confstr_impl(PyModuleDef *module, int name); - -static PyObject * -os_confstr(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int name; - - if (!PyArg_ParseTuple(args, - "O&:confstr", - conv_confstr_confname, &name)) - goto exit; - return_value = os_confstr_impl(module, name); - -exit: - return return_value; -} - static PyObject * os_confstr_impl(PyModuleDef *module, int name) -/*[clinic end generated code: output=3f5e8aba9f8e3174 input=18fb4d0567242e65]*/ +/*[clinic end generated code: output=6ff79c9eed8c2daf input=18fb4d0567242e65]*/ { PyObject *result = NULL; char buffer[255]; @@ -14912,6 +10473,8 @@ conv_sysconf_confname(PyObject *arg, int / sizeof(struct constdef)); } +#include "clinic/posixmodule.c.h" + /*[clinic input] os.sysconf -> long @@ -14921,41 +10484,9 @@ os.sysconf -> long Return an integer-valued system configuration variable. [clinic start generated code]*/ -PyDoc_STRVAR(os_sysconf__doc__, -"sysconf($module, name, /)\n" -"--\n" -"\n" -"Return an integer-valued system configuration variable."); - -#define OS_SYSCONF_METHODDEF \ - {"sysconf", (PyCFunction)os_sysconf, METH_VARARGS, os_sysconf__doc__}, - -static long -os_sysconf_impl(PyModuleDef *module, int name); - -static PyObject * -os_sysconf(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int name; - long _return_value; - - if (!PyArg_ParseTuple(args, - "O&:sysconf", - conv_sysconf_confname, &name)) - goto exit; - _return_value = os_sysconf_impl(module, name); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyLong_FromLong(_return_value); - -exit: - return return_value; -} - static long os_sysconf_impl(PyModuleDef *module, int name) -/*[clinic end generated code: output=7b06dfdc472431e4 input=279e3430a33f29e4]*/ +/*[clinic end generated code: output=ed567306f58d69c4 input=279e3430a33f29e4]*/ { long value; @@ -15051,30 +10582,9 @@ This function 'dumps core' or otherwise on the hosting operating system. This function never returns. [clinic start generated code]*/ -PyDoc_STRVAR(os_abort__doc__, -"abort($module, /)\n" -"--\n" -"\n" -"Abort the interpreter immediately.\n" -"\n" -"This function \'dumps core\' or otherwise fails in the hardest way possible\n" -"on the hosting operating system. This function never returns."); - -#define OS_ABORT_METHODDEF \ - {"abort", (PyCFunction)os_abort, METH_NOARGS, os_abort__doc__}, - -static PyObject * -os_abort_impl(PyModuleDef *module); - -static PyObject * -os_abort(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_abort_impl(module); -} - static PyObject * os_abort_impl(PyModuleDef *module) -/*[clinic end generated code: output=cded2cc8c5453d3a input=cf2c7d98bc504047]*/ +/*[clinic end generated code: output=486bb96647c299b3 input=cf2c7d98bc504047]*/ { abort(); /*NOTREACHED*/ @@ -15230,31 +10740,9 @@ the last 1, 5, and 15 minutes as a tuple Raises OSError if the load average was unobtainable. [clinic start generated code]*/ -PyDoc_STRVAR(os_getloadavg__doc__, -"getloadavg($module, /)\n" -"--\n" -"\n" -"Return average recent system load information.\n" -"\n" -"Return the number of processes in the system run queue averaged over\n" -"the last 1, 5, and 15 minutes as a tuple of three floats.\n" -"Raises OSError if the load average was unobtainable."); - -#define OS_GETLOADAVG_METHODDEF \ - {"getloadavg", (PyCFunction)os_getloadavg, METH_NOARGS, os_getloadavg__doc__}, - -static PyObject * -os_getloadavg_impl(PyModuleDef *module); - -static PyObject * -os_getloadavg(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getloadavg_impl(module); -} - static PyObject * os_getloadavg_impl(PyModuleDef *module) -/*[clinic end generated code: output=67593a92457d55af input=3d6d826b76d8a34e]*/ +/*[clinic end generated code: output=2b64c5b675d74c14 input=3d6d826b76d8a34e]*/ { double loadavg[3]; if (getloadavg(loadavg, 3)!=3) { @@ -15276,41 +10764,9 @@ The file descriptor must be attached to If the device is not a terminal, return None. [clinic start generated code]*/ -PyDoc_STRVAR(os_device_encoding__doc__, -"device_encoding($module, /, fd)\n" -"--\n" -"\n" -"Return a string describing the encoding of a terminal\'s file descriptor.\n" -"\n" -"The file descriptor must be attached to a terminal.\n" -"If the device is not a terminal, return None."); - -#define OS_DEVICE_ENCODING_METHODDEF \ - {"device_encoding", (PyCFunction)os_device_encoding, METH_VARARGS|METH_KEYWORDS, os_device_encoding__doc__}, - -static PyObject * -os_device_encoding_impl(PyModuleDef *module, int fd); - -static PyObject * -os_device_encoding(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"fd", NULL}; - int fd; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:device_encoding", _keywords, - &fd)) - goto exit; - return_value = os_device_encoding_impl(module, fd); - -exit: - return return_value; -} - static PyObject * os_device_encoding_impl(PyModuleDef *module, int fd) -/*[clinic end generated code: output=e9f8274d42f5cce3 input=9e1d4a42b66df312]*/ +/*[clinic end generated code: output=34f14e33468419c1 input=9e1d4a42b66df312]*/ { return _Py_device_encoding(fd); } @@ -15328,39 +10784,9 @@ os.setresuid Set the current process's real, effective, and saved user ids. [clinic start generated code]*/ -PyDoc_STRVAR(os_setresuid__doc__, -"setresuid($module, ruid, euid, suid, /)\n" -"--\n" -"\n" -"Set the current process\'s real, effective, and saved user ids."); - -#define OS_SETRESUID_METHODDEF \ - {"setresuid", (PyCFunction)os_setresuid, METH_VARARGS, os_setresuid__doc__}, - -static PyObject * -os_setresuid_impl(PyModuleDef *module, uid_t ruid, uid_t euid, uid_t suid); - -static PyObject * -os_setresuid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - uid_t ruid; - uid_t euid; - uid_t suid; - - if (!PyArg_ParseTuple(args, - "O&O&O&:setresuid", - _Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid, _Py_Uid_Converter, &suid)) - goto exit; - return_value = os_setresuid_impl(module, ruid, euid, suid); - -exit: - return return_value; -} - static PyObject * os_setresuid_impl(PyModuleDef *module, uid_t ruid, uid_t euid, uid_t suid) -/*[clinic end generated code: output=2e3457cfe7cd1f94 input=9e33cb79a82792f3]*/ +/*[clinic end generated code: output=92cc330812c6ed0f input=9e33cb79a82792f3]*/ { if (setresuid(ruid, euid, suid) < 0) return posix_error(); @@ -15381,39 +10807,9 @@ os.setresgid Set the current process's real, effective, and saved group ids. [clinic start generated code]*/ -PyDoc_STRVAR(os_setresgid__doc__, -"setresgid($module, rgid, egid, sgid, /)\n" -"--\n" -"\n" -"Set the current process\'s real, effective, and saved group ids."); - -#define OS_SETRESGID_METHODDEF \ - {"setresgid", (PyCFunction)os_setresgid, METH_VARARGS, os_setresgid__doc__}, - -static PyObject * -os_setresgid_impl(PyModuleDef *module, gid_t rgid, gid_t egid, gid_t sgid); - -static PyObject * -os_setresgid(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - gid_t rgid; - gid_t egid; - gid_t sgid; - - if (!PyArg_ParseTuple(args, - "O&O&O&:setresgid", - _Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid, _Py_Gid_Converter, &sgid)) - goto exit; - return_value = os_setresgid_impl(module, rgid, egid, sgid); - -exit: - return return_value; -} - static PyObject * os_setresgid_impl(PyModuleDef *module, gid_t rgid, gid_t egid, gid_t sgid) -/*[clinic end generated code: output=8a7ee6c1f2482362 input=33e9e0785ef426b1]*/ +/*[clinic end generated code: output=e91dc4842a604429 input=33e9e0785ef426b1]*/ { if (setresgid(rgid, egid, sgid) < 0) return posix_error(); @@ -15429,27 +10825,9 @@ os.getresuid Return a tuple of the current process's real, effective, and saved user ids. [clinic start generated code]*/ -PyDoc_STRVAR(os_getresuid__doc__, -"getresuid($module, /)\n" -"--\n" -"\n" -"Return a tuple of the current process\'s real, effective, and saved user ids."); - -#define OS_GETRESUID_METHODDEF \ - {"getresuid", (PyCFunction)os_getresuid, METH_NOARGS, os_getresuid__doc__}, - -static PyObject * -os_getresuid_impl(PyModuleDef *module); - -static PyObject * -os_getresuid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getresuid_impl(module); -} - static PyObject * os_getresuid_impl(PyModuleDef *module) -/*[clinic end generated code: output=d0786686a6ef1320 input=41ccfa8e1f6517ad]*/ +/*[clinic end generated code: output=9ddef62faae8e477 input=41ccfa8e1f6517ad]*/ { uid_t ruid, euid, suid; if (getresuid(&ruid, &euid, &suid) < 0) @@ -15468,27 +10846,9 @@ os.getresgid Return a tuple of the current process's real, effective, and saved group ids. [clinic start generated code]*/ -PyDoc_STRVAR(os_getresgid__doc__, -"getresgid($module, /)\n" -"--\n" -"\n" -"Return a tuple of the current process\'s real, effective, and saved group ids."); - -#define OS_GETRESGID_METHODDEF \ - {"getresgid", (PyCFunction)os_getresgid, METH_NOARGS, os_getresgid__doc__}, - -static PyObject * -os_getresgid_impl(PyModuleDef *module); - -static PyObject * -os_getresgid(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_getresgid_impl(module); -} - static PyObject * os_getresgid_impl(PyModuleDef *module) -/*[clinic end generated code: output=05249ac795fa759f input=517e68db9ca32df6]*/ +/*[clinic end generated code: output=e1a553cbcf16234c input=517e68db9ca32df6]*/ { gid_t rgid, egid, sgid; if (getresgid(&rgid, &egid, &sgid) < 0) @@ -15518,50 +10878,9 @@ If follow_symlinks is False, and the las [clinic start generated code]*/ -PyDoc_STRVAR(os_getxattr__doc__, -"getxattr($module, /, path, attribute, *, follow_symlinks=True)\n" -"--\n" -"\n" -"Return the value of extended attribute attribute on path.\n" -"\n" -"path may be either a string or an open file descriptor.\n" -"If follow_symlinks is False, and the last element of the path is a symbolic\n" -" link, getxattr will examine the symbolic link itself instead of the file\n" -" the link points to."); - -#define OS_GETXATTR_METHODDEF \ - {"getxattr", (PyCFunction)os_getxattr, METH_VARARGS|METH_KEYWORDS, os_getxattr__doc__}, - -static PyObject * -os_getxattr_impl(PyModuleDef *module, path_t *path, path_t *attribute, int follow_symlinks); - -static PyObject * -os_getxattr(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "attribute", "follow_symlinks", NULL}; - path_t path = PATH_T_INITIALIZE("getxattr", "path", 0, 1); - path_t attribute = PATH_T_INITIALIZE("getxattr", "attribute", 0, 0); - int follow_symlinks = 1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&O&|$p:getxattr", _keywords, - path_converter, &path, path_converter, &attribute, &follow_symlinks)) - goto exit; - return_value = os_getxattr_impl(module, &path, &attribute, follow_symlinks); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - /* Cleanup for attribute */ - path_cleanup(&attribute); - - return return_value; -} - static PyObject * os_getxattr_impl(PyModuleDef *module, path_t *path, path_t *attribute, int follow_symlinks) -/*[clinic end generated code: output=bbc9454fe2b9ea86 input=8c8ea3bab78d89c2]*/ +/*[clinic end generated code: output=d90086b314859f8b input=8c8ea3bab78d89c2]*/ { Py_ssize_t i; PyObject *buffer = NULL; @@ -15630,56 +10949,9 @@ If follow_symlinks is False, and the las [clinic start generated code]*/ -PyDoc_STRVAR(os_setxattr__doc__, -"setxattr($module, /, path, attribute, value, flags=0, *,\n" -" follow_symlinks=True)\n" -"--\n" -"\n" -"Set extended attribute attribute on path to value.\n" -"\n" -"path may be either a string or an open file descriptor.\n" -"If follow_symlinks is False, and the last element of the path is a symbolic\n" -" link, setxattr will modify the symbolic link itself instead of the file\n" -" the link points to."); - -#define OS_SETXATTR_METHODDEF \ - {"setxattr", (PyCFunction)os_setxattr, METH_VARARGS|METH_KEYWORDS, os_setxattr__doc__}, - -static PyObject * -os_setxattr_impl(PyModuleDef *module, path_t *path, path_t *attribute, Py_buffer *value, int flags, int follow_symlinks); - -static PyObject * -os_setxattr(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "attribute", "value", "flags", "follow_symlinks", NULL}; - path_t path = PATH_T_INITIALIZE("setxattr", "path", 0, 1); - path_t attribute = PATH_T_INITIALIZE("setxattr", "attribute", 0, 0); - Py_buffer value = {NULL, NULL}; - int flags = 0; - int follow_symlinks = 1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&O&y*|i$p:setxattr", _keywords, - path_converter, &path, path_converter, &attribute, &value, &flags, &follow_symlinks)) - goto exit; - return_value = os_setxattr_impl(module, &path, &attribute, &value, flags, follow_symlinks); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - /* Cleanup for attribute */ - path_cleanup(&attribute); - /* Cleanup for value */ - if (value.obj) - PyBuffer_Release(&value); - - return return_value; -} - static PyObject * os_setxattr_impl(PyModuleDef *module, path_t *path, path_t *attribute, Py_buffer *value, int flags, int follow_symlinks) -/*[clinic end generated code: output=2ff845d8e024b218 input=f0d26833992015c2]*/ +/*[clinic end generated code: output=e3defa5c4b1ad0ae input=f0d26833992015c2]*/ { ssize_t result; @@ -15724,50 +10996,9 @@ If follow_symlinks is False, and the las [clinic start generated code]*/ -PyDoc_STRVAR(os_removexattr__doc__, -"removexattr($module, /, path, attribute, *, follow_symlinks=True)\n" -"--\n" -"\n" -"Remove extended attribute attribute on path.\n" -"\n" -"path may be either a string or an open file descriptor.\n" -"If follow_symlinks is False, and the last element of the path is a symbolic\n" -" link, removexattr will modify the symbolic link itself instead of the file\n" -" the link points to."); - -#define OS_REMOVEXATTR_METHODDEF \ - {"removexattr", (PyCFunction)os_removexattr, METH_VARARGS|METH_KEYWORDS, os_removexattr__doc__}, - -static PyObject * -os_removexattr_impl(PyModuleDef *module, path_t *path, path_t *attribute, int follow_symlinks); - -static PyObject * -os_removexattr(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "attribute", "follow_symlinks", NULL}; - path_t path = PATH_T_INITIALIZE("removexattr", "path", 0, 1); - path_t attribute = PATH_T_INITIALIZE("removexattr", "attribute", 0, 0); - int follow_symlinks = 1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O&O&|$p:removexattr", _keywords, - path_converter, &path, path_converter, &attribute, &follow_symlinks)) - goto exit; - return_value = os_removexattr_impl(module, &path, &attribute, follow_symlinks); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - /* Cleanup for attribute */ - path_cleanup(&attribute); - - return return_value; -} - static PyObject * os_removexattr_impl(PyModuleDef *module, path_t *path, path_t *attribute, int follow_symlinks) -/*[clinic end generated code: output=8dfc715bf607c4cf input=cdb54834161e3329]*/ +/*[clinic end generated code: output=4870ec90249af875 input=cdb54834161e3329]*/ { ssize_t result; @@ -15807,48 +11038,9 @@ If follow_symlinks is False, and the las the link points to. [clinic start generated code]*/ -PyDoc_STRVAR(os_listxattr__doc__, -"listxattr($module, /, path=None, *, follow_symlinks=True)\n" -"--\n" -"\n" -"Return a list of extended attributes on path.\n" -"\n" -"path may be either None, a string, or an open file descriptor.\n" -"if path is None, listxattr will examine the current directory.\n" -"If follow_symlinks is False, and the last element of the path is a symbolic\n" -" link, listxattr will examine the symbolic link itself instead of the file\n" -" the link points to."); - -#define OS_LISTXATTR_METHODDEF \ - {"listxattr", (PyCFunction)os_listxattr, METH_VARARGS|METH_KEYWORDS, os_listxattr__doc__}, - -static PyObject * -os_listxattr_impl(PyModuleDef *module, path_t *path, int follow_symlinks); - -static PyObject * -os_listxattr(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"path", "follow_symlinks", NULL}; - path_t path = PATH_T_INITIALIZE("listxattr", "path", 1, 1); - int follow_symlinks = 1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|O&$p:listxattr", _keywords, - path_converter, &path, &follow_symlinks)) - goto exit; - return_value = os_listxattr_impl(module, &path, follow_symlinks); - -exit: - /* Cleanup for path */ - path_cleanup(&path); - - return return_value; -} - static PyObject * os_listxattr_impl(PyModuleDef *module, path_t *path, int follow_symlinks) -/*[clinic end generated code: output=3104cafda1a3d887 input=08cca53ac0b07c13]*/ +/*[clinic end generated code: output=a87ad6ce56e42a4f input=08cca53ac0b07c13]*/ { Py_ssize_t i; PyObject *result = NULL; @@ -15940,37 +11132,9 @@ os.urandom Return a bytes object containing random bytes suitable for cryptographic use. [clinic start generated code]*/ -PyDoc_STRVAR(os_urandom__doc__, -"urandom($module, size, /)\n" -"--\n" -"\n" -"Return a bytes object containing random bytes suitable for cryptographic use."); - -#define OS_URANDOM_METHODDEF \ - {"urandom", (PyCFunction)os_urandom, METH_VARARGS, os_urandom__doc__}, - -static PyObject * -os_urandom_impl(PyModuleDef *module, Py_ssize_t size); - -static PyObject * -os_urandom(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - Py_ssize_t size; - - if (!PyArg_ParseTuple(args, - "n:urandom", - &size)) - goto exit; - return_value = os_urandom_impl(module, size); - -exit: - return return_value; -} - static PyObject * os_urandom_impl(PyModuleDef *module, Py_ssize_t size) -/*[clinic end generated code: output=5dbff582cab94cb9 input=4067cdb1b6776c29]*/ +/*[clinic end generated code: output=e0011f021501f03b input=4067cdb1b6776c29]*/ { PyObject *bytes; int result; @@ -16105,27 +11269,9 @@ os.cpu_count Return the number of CPUs in the system; return None if indeterminable. [clinic start generated code]*/ -PyDoc_STRVAR(os_cpu_count__doc__, -"cpu_count($module, /)\n" -"--\n" -"\n" -"Return the number of CPUs in the system; return None if indeterminable."); - -#define OS_CPU_COUNT_METHODDEF \ - {"cpu_count", (PyCFunction)os_cpu_count, METH_NOARGS, os_cpu_count__doc__}, - -static PyObject * -os_cpu_count_impl(PyModuleDef *module); - -static PyObject * -os_cpu_count(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return os_cpu_count_impl(module); -} - static PyObject * os_cpu_count_impl(PyModuleDef *module) -/*[clinic end generated code: output=92e2a4a729eb7740 input=d55e2f8f3823a628]*/ +/*[clinic end generated code: output=c59ee7f6bce832b8 input=d55e2f8f3823a628]*/ { int ncpu = 0; #ifdef MS_WINDOWS @@ -16164,41 +11310,9 @@ os.get_inheritable -> bool Get the close-on-exe flag of the specified file descriptor. [clinic start generated code]*/ -PyDoc_STRVAR(os_get_inheritable__doc__, -"get_inheritable($module, fd, /)\n" -"--\n" -"\n" -"Get the close-on-exe flag of the specified file descriptor."); - -#define OS_GET_INHERITABLE_METHODDEF \ - {"get_inheritable", (PyCFunction)os_get_inheritable, METH_VARARGS, os_get_inheritable__doc__}, - -static int -os_get_inheritable_impl(PyModuleDef *module, int fd); - -static PyObject * -os_get_inheritable(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - int _return_value; - - if (!PyArg_ParseTuple(args, - "i:get_inheritable", - &fd)) - goto exit; - _return_value = os_get_inheritable_impl(module, fd); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyBool_FromLong((long)_return_value); - -exit: - return return_value; -} - static int os_get_inheritable_impl(PyModuleDef *module, int fd) -/*[clinic end generated code: output=261d1dd2b0dbdc35 input=89ac008dc9ab6b95]*/ +/*[clinic end generated code: output=36110bb36efaa21e input=89ac008dc9ab6b95]*/ { if (!_PyVerify_fd(fd)){ posix_error(); @@ -16218,38 +11332,9 @@ os.set_inheritable Set the inheritable flag of the specified file descriptor. [clinic start generated code]*/ -PyDoc_STRVAR(os_set_inheritable__doc__, -"set_inheritable($module, fd, inheritable, /)\n" -"--\n" -"\n" -"Set the inheritable flag of the specified file descriptor."); - -#define OS_SET_INHERITABLE_METHODDEF \ - {"set_inheritable", (PyCFunction)os_set_inheritable, METH_VARARGS, os_set_inheritable__doc__}, - -static PyObject * -os_set_inheritable_impl(PyModuleDef *module, int fd, int inheritable); - -static PyObject * -os_set_inheritable(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int fd; - int inheritable; - - if (!PyArg_ParseTuple(args, - "ii:set_inheritable", - &fd, &inheritable)) - goto exit; - return_value = os_set_inheritable_impl(module, fd, inheritable); - -exit: - return return_value; -} - static PyObject * os_set_inheritable_impl(PyModuleDef *module, int fd, int inheritable) -/*[clinic end generated code: output=64dfe5e15c906539 input=9ceaead87a1e2402]*/ +/*[clinic end generated code: output=2ac5c6ce8623f045 input=9ceaead87a1e2402]*/ { if (!_PyVerify_fd(fd)) return posix_error(); @@ -16269,41 +11354,9 @@ os.get_handle_inheritable -> bool Get the close-on-exe flag of the specified file descriptor. [clinic start generated code]*/ -PyDoc_STRVAR(os_get_handle_inheritable__doc__, -"get_handle_inheritable($module, handle, /)\n" -"--\n" -"\n" -"Get the close-on-exe flag of the specified file descriptor."); - -#define OS_GET_HANDLE_INHERITABLE_METHODDEF \ - {"get_handle_inheritable", (PyCFunction)os_get_handle_inheritable, METH_VARARGS, os_get_handle_inheritable__doc__}, - -static int -os_get_handle_inheritable_impl(PyModuleDef *module, Py_intptr_t handle); - -static PyObject * -os_get_handle_inheritable(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - Py_intptr_t handle; - int _return_value; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_INTPTR ":get_handle_inheritable", - &handle)) - goto exit; - _return_value = os_get_handle_inheritable_impl(module, handle); - if ((_return_value == -1) && PyErr_Occurred()) - goto exit; - return_value = PyBool_FromLong((long)_return_value); - -exit: - return return_value; -} - static int os_get_handle_inheritable_impl(PyModuleDef *module, Py_intptr_t handle) -/*[clinic end generated code: output=d5bf9d86900bf457 input=5f7759443aae3dc5]*/ +/*[clinic end generated code: output=3b7b3e1b43f312b6 input=5f7759443aae3dc5]*/ { DWORD flags; @@ -16325,38 +11378,9 @@ os.set_handle_inheritable Set the inheritable flag of the specified handle. [clinic start generated code]*/ -PyDoc_STRVAR(os_set_handle_inheritable__doc__, -"set_handle_inheritable($module, handle, inheritable, /)\n" -"--\n" -"\n" -"Set the inheritable flag of the specified handle."); - -#define OS_SET_HANDLE_INHERITABLE_METHODDEF \ - {"set_handle_inheritable", (PyCFunction)os_set_handle_inheritable, METH_VARARGS, os_set_handle_inheritable__doc__}, - -static PyObject * -os_set_handle_inheritable_impl(PyModuleDef *module, Py_intptr_t handle, int inheritable); - -static PyObject * -os_set_handle_inheritable(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - Py_intptr_t handle; - int inheritable; - - if (!PyArg_ParseTuple(args, - "" _Py_PARSE_INTPTR "p:set_handle_inheritable", - &handle, &inheritable)) - goto exit; - return_value = os_set_handle_inheritable_impl(module, handle, inheritable); - -exit: - return return_value; -} - static PyObject * os_set_handle_inheritable_impl(PyModuleDef *module, Py_intptr_t handle, int inheritable) -/*[clinic end generated code: output=ee5fcc6d9f0d4f8b input=e64b2b2730469def]*/ +/*[clinic end generated code: output=627aa5b158b69338 input=e64b2b2730469def]*/ { DWORD flags = inheritable ? HANDLE_FLAG_INHERIT : 0; if (!SetHandleInformation((HANDLE)handle, HANDLE_FLAG_INHERIT, flags)) { @@ -16420,483 +11444,7 @@ posix_set_blocking(PyObject *self, PyObj /*[clinic input] dump buffer [clinic start generated code]*/ - -#ifndef OS_TTYNAME_METHODDEF - #define OS_TTYNAME_METHODDEF -#endif /* !defined(OS_TTYNAME_METHODDEF) */ - -#ifndef OS_CTERMID_METHODDEF - #define OS_CTERMID_METHODDEF -#endif /* !defined(OS_CTERMID_METHODDEF) */ - -#ifndef OS_FCHDIR_METHODDEF - #define OS_FCHDIR_METHODDEF -#endif /* !defined(OS_FCHDIR_METHODDEF) */ - -#ifndef OS_FCHMOD_METHODDEF - #define OS_FCHMOD_METHODDEF -#endif /* !defined(OS_FCHMOD_METHODDEF) */ - -#ifndef OS_LCHMOD_METHODDEF - #define OS_LCHMOD_METHODDEF -#endif /* !defined(OS_LCHMOD_METHODDEF) */ - -#ifndef OS_CHFLAGS_METHODDEF - #define OS_CHFLAGS_METHODDEF -#endif /* !defined(OS_CHFLAGS_METHODDEF) */ - -#ifndef OS_LCHFLAGS_METHODDEF - #define OS_LCHFLAGS_METHODDEF -#endif /* !defined(OS_LCHFLAGS_METHODDEF) */ - -#ifndef OS_CHROOT_METHODDEF - #define OS_CHROOT_METHODDEF -#endif /* !defined(OS_CHROOT_METHODDEF) */ - -#ifndef OS_FSYNC_METHODDEF - #define OS_FSYNC_METHODDEF -#endif /* !defined(OS_FSYNC_METHODDEF) */ - -#ifndef OS_SYNC_METHODDEF - #define OS_SYNC_METHODDEF -#endif /* !defined(OS_SYNC_METHODDEF) */ - -#ifndef OS_FDATASYNC_METHODDEF - #define OS_FDATASYNC_METHODDEF -#endif /* !defined(OS_FDATASYNC_METHODDEF) */ - -#ifndef OS_CHOWN_METHODDEF - #define OS_CHOWN_METHODDEF -#endif /* !defined(OS_CHOWN_METHODDEF) */ - -#ifndef OS_FCHOWN_METHODDEF - #define OS_FCHOWN_METHODDEF -#endif /* !defined(OS_FCHOWN_METHODDEF) */ - -#ifndef OS_LCHOWN_METHODDEF - #define OS_LCHOWN_METHODDEF -#endif /* !defined(OS_LCHOWN_METHODDEF) */ - -#ifndef OS_LINK_METHODDEF - #define OS_LINK_METHODDEF -#endif /* !defined(OS_LINK_METHODDEF) */ - -#ifndef OS__GETFINALPATHNAME_METHODDEF - #define OS__GETFINALPATHNAME_METHODDEF -#endif /* !defined(OS__GETFINALPATHNAME_METHODDEF) */ - -#ifndef OS__GETVOLUMEPATHNAME_METHODDEF - #define OS__GETVOLUMEPATHNAME_METHODDEF -#endif /* !defined(OS__GETVOLUMEPATHNAME_METHODDEF) */ - -#ifndef OS_NICE_METHODDEF - #define OS_NICE_METHODDEF -#endif /* !defined(OS_NICE_METHODDEF) */ - -#ifndef OS_GETPRIORITY_METHODDEF - #define OS_GETPRIORITY_METHODDEF -#endif /* !defined(OS_GETPRIORITY_METHODDEF) */ - -#ifndef OS_SETPRIORITY_METHODDEF - #define OS_SETPRIORITY_METHODDEF -#endif /* !defined(OS_SETPRIORITY_METHODDEF) */ - -#ifndef OS_SYSTEM_METHODDEF - #define OS_SYSTEM_METHODDEF -#endif /* !defined(OS_SYSTEM_METHODDEF) */ - -#ifndef OS_SYSTEM_METHODDEF - #define OS_SYSTEM_METHODDEF -#endif /* !defined(OS_SYSTEM_METHODDEF) */ - -#ifndef OS_UNAME_METHODDEF - #define OS_UNAME_METHODDEF -#endif /* !defined(OS_UNAME_METHODDEF) */ - -#ifndef OS_EXECV_METHODDEF - #define OS_EXECV_METHODDEF -#endif /* !defined(OS_EXECV_METHODDEF) */ - -#ifndef OS_EXECVE_METHODDEF - #define OS_EXECVE_METHODDEF -#endif /* !defined(OS_EXECVE_METHODDEF) */ - -#ifndef OS_SPAWNV_METHODDEF - #define OS_SPAWNV_METHODDEF -#endif /* !defined(OS_SPAWNV_METHODDEF) */ - -#ifndef OS_SPAWNVE_METHODDEF - #define OS_SPAWNVE_METHODDEF -#endif /* !defined(OS_SPAWNVE_METHODDEF) */ - -#ifndef OS_FORK1_METHODDEF - #define OS_FORK1_METHODDEF -#endif /* !defined(OS_FORK1_METHODDEF) */ - -#ifndef OS_FORK_METHODDEF - #define OS_FORK_METHODDEF -#endif /* !defined(OS_FORK_METHODDEF) */ - -#ifndef OS_SCHED_GET_PRIORITY_MAX_METHODDEF - #define OS_SCHED_GET_PRIORITY_MAX_METHODDEF -#endif /* !defined(OS_SCHED_GET_PRIORITY_MAX_METHODDEF) */ - -#ifndef OS_SCHED_GET_PRIORITY_MIN_METHODDEF - #define OS_SCHED_GET_PRIORITY_MIN_METHODDEF -#endif /* !defined(OS_SCHED_GET_PRIORITY_MIN_METHODDEF) */ - -#ifndef OS_SCHED_GETSCHEDULER_METHODDEF - #define OS_SCHED_GETSCHEDULER_METHODDEF -#endif /* !defined(OS_SCHED_GETSCHEDULER_METHODDEF) */ - -#ifndef OS_SCHED_SETSCHEDULER_METHODDEF - #define OS_SCHED_SETSCHEDULER_METHODDEF -#endif /* !defined(OS_SCHED_SETSCHEDULER_METHODDEF) */ - -#ifndef OS_SCHED_GETPARAM_METHODDEF - #define OS_SCHED_GETPARAM_METHODDEF -#endif /* !defined(OS_SCHED_GETPARAM_METHODDEF) */ - -#ifndef OS_SCHED_SETPARAM_METHODDEF - #define OS_SCHED_SETPARAM_METHODDEF -#endif /* !defined(OS_SCHED_SETPARAM_METHODDEF) */ - -#ifndef OS_SCHED_RR_GET_INTERVAL_METHODDEF - #define OS_SCHED_RR_GET_INTERVAL_METHODDEF -#endif /* !defined(OS_SCHED_RR_GET_INTERVAL_METHODDEF) */ - -#ifndef OS_SCHED_YIELD_METHODDEF - #define OS_SCHED_YIELD_METHODDEF -#endif /* !defined(OS_SCHED_YIELD_METHODDEF) */ - -#ifndef OS_SCHED_SETAFFINITY_METHODDEF - #define OS_SCHED_SETAFFINITY_METHODDEF -#endif /* !defined(OS_SCHED_SETAFFINITY_METHODDEF) */ - -#ifndef OS_SCHED_GETAFFINITY_METHODDEF - #define OS_SCHED_GETAFFINITY_METHODDEF -#endif /* !defined(OS_SCHED_GETAFFINITY_METHODDEF) */ - -#ifndef OS_OPENPTY_METHODDEF - #define OS_OPENPTY_METHODDEF -#endif /* !defined(OS_OPENPTY_METHODDEF) */ - -#ifndef OS_FORKPTY_METHODDEF - #define OS_FORKPTY_METHODDEF -#endif /* !defined(OS_FORKPTY_METHODDEF) */ - -#ifndef OS_GETEGID_METHODDEF - #define OS_GETEGID_METHODDEF -#endif /* !defined(OS_GETEGID_METHODDEF) */ - -#ifndef OS_GETEUID_METHODDEF - #define OS_GETEUID_METHODDEF -#endif /* !defined(OS_GETEUID_METHODDEF) */ - -#ifndef OS_GETGID_METHODDEF - #define OS_GETGID_METHODDEF -#endif /* !defined(OS_GETGID_METHODDEF) */ - -#ifndef OS_GETGROUPS_METHODDEF - #define OS_GETGROUPS_METHODDEF -#endif /* !defined(OS_GETGROUPS_METHODDEF) */ - -#ifndef OS_GETPGID_METHODDEF - #define OS_GETPGID_METHODDEF -#endif /* !defined(OS_GETPGID_METHODDEF) */ - -#ifndef OS_GETPGRP_METHODDEF - #define OS_GETPGRP_METHODDEF -#endif /* !defined(OS_GETPGRP_METHODDEF) */ - -#ifndef OS_SETPGRP_METHODDEF - #define OS_SETPGRP_METHODDEF -#endif /* !defined(OS_SETPGRP_METHODDEF) */ - -#ifndef OS_GETPPID_METHODDEF - #define OS_GETPPID_METHODDEF -#endif /* !defined(OS_GETPPID_METHODDEF) */ - -#ifndef OS_GETLOGIN_METHODDEF - #define OS_GETLOGIN_METHODDEF -#endif /* !defined(OS_GETLOGIN_METHODDEF) */ - -#ifndef OS_GETUID_METHODDEF - #define OS_GETUID_METHODDEF -#endif /* !defined(OS_GETUID_METHODDEF) */ - -#ifndef OS_KILL_METHODDEF - #define OS_KILL_METHODDEF -#endif /* !defined(OS_KILL_METHODDEF) */ - -#ifndef OS_KILLPG_METHODDEF - #define OS_KILLPG_METHODDEF -#endif /* !defined(OS_KILLPG_METHODDEF) */ - -#ifndef OS_PLOCK_METHODDEF - #define OS_PLOCK_METHODDEF -#endif /* !defined(OS_PLOCK_METHODDEF) */ - -#ifndef OS_SETUID_METHODDEF - #define OS_SETUID_METHODDEF -#endif /* !defined(OS_SETUID_METHODDEF) */ - -#ifndef OS_SETEUID_METHODDEF - #define OS_SETEUID_METHODDEF -#endif /* !defined(OS_SETEUID_METHODDEF) */ - -#ifndef OS_SETEGID_METHODDEF - #define OS_SETEGID_METHODDEF -#endif /* !defined(OS_SETEGID_METHODDEF) */ - -#ifndef OS_SETREUID_METHODDEF - #define OS_SETREUID_METHODDEF -#endif /* !defined(OS_SETREUID_METHODDEF) */ - -#ifndef OS_SETREGID_METHODDEF - #define OS_SETREGID_METHODDEF -#endif /* !defined(OS_SETREGID_METHODDEF) */ - -#ifndef OS_SETGID_METHODDEF - #define OS_SETGID_METHODDEF -#endif /* !defined(OS_SETGID_METHODDEF) */ - -#ifndef OS_SETGROUPS_METHODDEF - #define OS_SETGROUPS_METHODDEF -#endif /* !defined(OS_SETGROUPS_METHODDEF) */ - -#ifndef OS_WAIT3_METHODDEF - #define OS_WAIT3_METHODDEF -#endif /* !defined(OS_WAIT3_METHODDEF) */ - -#ifndef OS_WAIT4_METHODDEF - #define OS_WAIT4_METHODDEF -#endif /* !defined(OS_WAIT4_METHODDEF) */ - -#ifndef OS_WAITID_METHODDEF - #define OS_WAITID_METHODDEF -#endif /* !defined(OS_WAITID_METHODDEF) */ - -#ifndef OS_WAITPID_METHODDEF - #define OS_WAITPID_METHODDEF -#endif /* !defined(OS_WAITPID_METHODDEF) */ - -#ifndef OS_WAITPID_METHODDEF - #define OS_WAITPID_METHODDEF -#endif /* !defined(OS_WAITPID_METHODDEF) */ - -#ifndef OS_WAIT_METHODDEF - #define OS_WAIT_METHODDEF -#endif /* !defined(OS_WAIT_METHODDEF) */ - -#ifndef OS_SYMLINK_METHODDEF - #define OS_SYMLINK_METHODDEF -#endif /* !defined(OS_SYMLINK_METHODDEF) */ - -#ifndef OS_TIMES_METHODDEF - #define OS_TIMES_METHODDEF -#endif /* !defined(OS_TIMES_METHODDEF) */ - -#ifndef OS_GETSID_METHODDEF - #define OS_GETSID_METHODDEF -#endif /* !defined(OS_GETSID_METHODDEF) */ - -#ifndef OS_SETSID_METHODDEF - #define OS_SETSID_METHODDEF -#endif /* !defined(OS_SETSID_METHODDEF) */ - -#ifndef OS_SETPGID_METHODDEF - #define OS_SETPGID_METHODDEF -#endif /* !defined(OS_SETPGID_METHODDEF) */ - -#ifndef OS_TCGETPGRP_METHODDEF - #define OS_TCGETPGRP_METHODDEF -#endif /* !defined(OS_TCGETPGRP_METHODDEF) */ - -#ifndef OS_TCSETPGRP_METHODDEF - #define OS_TCSETPGRP_METHODDEF -#endif /* !defined(OS_TCSETPGRP_METHODDEF) */ - -#ifndef OS_LOCKF_METHODDEF - #define OS_LOCKF_METHODDEF -#endif /* !defined(OS_LOCKF_METHODDEF) */ - -#ifndef OS_READV_METHODDEF - #define OS_READV_METHODDEF -#endif /* !defined(OS_READV_METHODDEF) */ - -#ifndef OS_PREAD_METHODDEF - #define OS_PREAD_METHODDEF -#endif /* !defined(OS_PREAD_METHODDEF) */ - -#ifndef OS_PIPE_METHODDEF - #define OS_PIPE_METHODDEF -#endif /* !defined(OS_PIPE_METHODDEF) */ - -#ifndef OS_PIPE2_METHODDEF - #define OS_PIPE2_METHODDEF -#endif /* !defined(OS_PIPE2_METHODDEF) */ - -#ifndef OS_WRITEV_METHODDEF - #define OS_WRITEV_METHODDEF -#endif /* !defined(OS_WRITEV_METHODDEF) */ - -#ifndef OS_PWRITE_METHODDEF - #define OS_PWRITE_METHODDEF -#endif /* !defined(OS_PWRITE_METHODDEF) */ - -#ifndef OS_MKFIFO_METHODDEF - #define OS_MKFIFO_METHODDEF -#endif /* !defined(OS_MKFIFO_METHODDEF) */ - -#ifndef OS_MKNOD_METHODDEF - #define OS_MKNOD_METHODDEF -#endif /* !defined(OS_MKNOD_METHODDEF) */ - -#ifndef OS_MAJOR_METHODDEF - #define OS_MAJOR_METHODDEF -#endif /* !defined(OS_MAJOR_METHODDEF) */ - -#ifndef OS_MINOR_METHODDEF - #define OS_MINOR_METHODDEF -#endif /* !defined(OS_MINOR_METHODDEF) */ - -#ifndef OS_MAKEDEV_METHODDEF - #define OS_MAKEDEV_METHODDEF -#endif /* !defined(OS_MAKEDEV_METHODDEF) */ - -#ifndef OS_FTRUNCATE_METHODDEF - #define OS_FTRUNCATE_METHODDEF -#endif /* !defined(OS_FTRUNCATE_METHODDEF) */ - -#ifndef OS_TRUNCATE_METHODDEF - #define OS_TRUNCATE_METHODDEF -#endif /* !defined(OS_TRUNCATE_METHODDEF) */ - -#ifndef OS_POSIX_FALLOCATE_METHODDEF - #define OS_POSIX_FALLOCATE_METHODDEF -#endif /* !defined(OS_POSIX_FALLOCATE_METHODDEF) */ - -#ifndef OS_POSIX_FADVISE_METHODDEF - #define OS_POSIX_FADVISE_METHODDEF -#endif /* !defined(OS_POSIX_FADVISE_METHODDEF) */ - -#ifndef OS_PUTENV_METHODDEF - #define OS_PUTENV_METHODDEF -#endif /* !defined(OS_PUTENV_METHODDEF) */ - -#ifndef OS_PUTENV_METHODDEF - #define OS_PUTENV_METHODDEF -#endif /* !defined(OS_PUTENV_METHODDEF) */ - -#ifndef OS_UNSETENV_METHODDEF - #define OS_UNSETENV_METHODDEF -#endif /* !defined(OS_UNSETENV_METHODDEF) */ - -#ifndef OS_WCOREDUMP_METHODDEF - #define OS_WCOREDUMP_METHODDEF -#endif /* !defined(OS_WCOREDUMP_METHODDEF) */ - -#ifndef OS_WIFCONTINUED_METHODDEF - #define OS_WIFCONTINUED_METHODDEF -#endif /* !defined(OS_WIFCONTINUED_METHODDEF) */ - -#ifndef OS_WIFSTOPPED_METHODDEF - #define OS_WIFSTOPPED_METHODDEF -#endif /* !defined(OS_WIFSTOPPED_METHODDEF) */ - -#ifndef OS_WIFSIGNALED_METHODDEF - #define OS_WIFSIGNALED_METHODDEF -#endif /* !defined(OS_WIFSIGNALED_METHODDEF) */ - -#ifndef OS_WIFEXITED_METHODDEF - #define OS_WIFEXITED_METHODDEF -#endif /* !defined(OS_WIFEXITED_METHODDEF) */ - -#ifndef OS_WEXITSTATUS_METHODDEF - #define OS_WEXITSTATUS_METHODDEF -#endif /* !defined(OS_WEXITSTATUS_METHODDEF) */ - -#ifndef OS_WTERMSIG_METHODDEF - #define OS_WTERMSIG_METHODDEF -#endif /* !defined(OS_WTERMSIG_METHODDEF) */ - -#ifndef OS_WSTOPSIG_METHODDEF - #define OS_WSTOPSIG_METHODDEF -#endif /* !defined(OS_WSTOPSIG_METHODDEF) */ - -#ifndef OS_FSTATVFS_METHODDEF - #define OS_FSTATVFS_METHODDEF -#endif /* !defined(OS_FSTATVFS_METHODDEF) */ - -#ifndef OS_STATVFS_METHODDEF - #define OS_STATVFS_METHODDEF -#endif /* !defined(OS_STATVFS_METHODDEF) */ - -#ifndef OS__GETDISKUSAGE_METHODDEF - #define OS__GETDISKUSAGE_METHODDEF -#endif /* !defined(OS__GETDISKUSAGE_METHODDEF) */ - -#ifndef OS_FPATHCONF_METHODDEF - #define OS_FPATHCONF_METHODDEF -#endif /* !defined(OS_FPATHCONF_METHODDEF) */ - -#ifndef OS_PATHCONF_METHODDEF - #define OS_PATHCONF_METHODDEF -#endif /* !defined(OS_PATHCONF_METHODDEF) */ - -#ifndef OS_CONFSTR_METHODDEF - #define OS_CONFSTR_METHODDEF -#endif /* !defined(OS_CONFSTR_METHODDEF) */ - -#ifndef OS_SYSCONF_METHODDEF - #define OS_SYSCONF_METHODDEF -#endif /* !defined(OS_SYSCONF_METHODDEF) */ - -#ifndef OS_GETLOADAVG_METHODDEF - #define OS_GETLOADAVG_METHODDEF -#endif /* !defined(OS_GETLOADAVG_METHODDEF) */ - -#ifndef OS_SETRESUID_METHODDEF - #define OS_SETRESUID_METHODDEF -#endif /* !defined(OS_SETRESUID_METHODDEF) */ - -#ifndef OS_SETRESGID_METHODDEF - #define OS_SETRESGID_METHODDEF -#endif /* !defined(OS_SETRESGID_METHODDEF) */ - -#ifndef OS_GETRESUID_METHODDEF - #define OS_GETRESUID_METHODDEF -#endif /* !defined(OS_GETRESUID_METHODDEF) */ - -#ifndef OS_GETRESGID_METHODDEF - #define OS_GETRESGID_METHODDEF -#endif /* !defined(OS_GETRESGID_METHODDEF) */ - -#ifndef OS_GETXATTR_METHODDEF - #define OS_GETXATTR_METHODDEF -#endif /* !defined(OS_GETXATTR_METHODDEF) */ - -#ifndef OS_SETXATTR_METHODDEF - #define OS_SETXATTR_METHODDEF -#endif /* !defined(OS_SETXATTR_METHODDEF) */ - -#ifndef OS_REMOVEXATTR_METHODDEF - #define OS_REMOVEXATTR_METHODDEF -#endif /* !defined(OS_REMOVEXATTR_METHODDEF) */ - -#ifndef OS_LISTXATTR_METHODDEF - #define OS_LISTXATTR_METHODDEF -#endif /* !defined(OS_LISTXATTR_METHODDEF) */ - -#ifndef OS_GET_HANDLE_INHERITABLE_METHODDEF - #define OS_GET_HANDLE_INHERITABLE_METHODDEF -#endif /* !defined(OS_GET_HANDLE_INHERITABLE_METHODDEF) */ - -#ifndef OS_SET_HANDLE_INHERITABLE_METHODDEF - #define OS_SET_HANDLE_INHERITABLE_METHODDEF -#endif /* !defined(OS_SET_HANDLE_INHERITABLE_METHODDEF) */ -/*[clinic end generated code: output=52a6140b0b052ce6 input=524ce2e021e4eba6]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=524ce2e021e4eba6]*/ static PyMethodDef posix_methods[] = { diff -r a824c40e8fc0 Modules/pyexpat.c --- a/Modules/pyexpat.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/pyexpat.c Sun Feb 22 11:52:48 2015 +0200 @@ -68,6 +68,8 @@ typedef struct { PyObject **handlers; } xmlparseobject; +#include "clinic/pyexpat.c.h" + #define CHARACTER_DATA_BUFFER_SIZE 8192 static PyTypeObject Xmlparsetype; @@ -713,40 +715,9 @@ Parse XML data. `isfinal' should be true at end of input. [clinic start generated code]*/ -PyDoc_STRVAR(pyexpat_xmlparser_Parse__doc__, -"Parse($self, data, isFinal=0, /)\n" -"--\n" -"\n" -"Parse XML data.\n" -"\n" -"`isfinal\' should be true at end of input."); - -#define PYEXPAT_XMLPARSER_PARSE_METHODDEF \ - {"Parse", (PyCFunction)pyexpat_xmlparser_Parse, METH_VARARGS, pyexpat_xmlparser_Parse__doc__}, - -static PyObject * -pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyObject *data, int isFinal); - -static PyObject * -pyexpat_xmlparser_Parse(xmlparseobject *self, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *data; - int isFinal = 0; - - if (!PyArg_ParseTuple(args, - "O|i:Parse", - &data, &isFinal)) - goto exit; - return_value = pyexpat_xmlparser_Parse_impl(self, data, isFinal); - -exit: - return return_value; -} - static PyObject * pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyObject *data, int isFinal) -/*[clinic end generated code: output=65b1652b01f20856 input=e37b81b8948ca7e0]*/ +/*[clinic end generated code: output=2d4dc77f4d434854 input=e37b81b8948ca7e0]*/ { const char *s; Py_ssize_t slen; @@ -836,18 +807,9 @@ pyexpat.xmlparser.ParseFile Parse XML data from file-like object. [clinic start generated code]*/ -PyDoc_STRVAR(pyexpat_xmlparser_ParseFile__doc__, -"ParseFile($self, file, /)\n" -"--\n" -"\n" -"Parse XML data from file-like object."); - -#define PYEXPAT_XMLPARSER_PARSEFILE_METHODDEF \ - {"ParseFile", (PyCFunction)pyexpat_xmlparser_ParseFile, METH_O, pyexpat_xmlparser_ParseFile__doc__}, - static PyObject * pyexpat_xmlparser_ParseFile(xmlparseobject *self, PyObject *file) -/*[clinic end generated code: output=2e13803c3d8c22b2 input=fbb5a12b6038d735]*/ +/*[clinic end generated code: output=2adc6a13100cc42b input=fbb5a12b6038d735]*/ { int rv = 1; PyObject *readmethod = NULL; @@ -894,37 +856,9 @@ pyexpat.xmlparser.SetBase Set the base URL for the parser. [clinic start generated code]*/ -PyDoc_STRVAR(pyexpat_xmlparser_SetBase__doc__, -"SetBase($self, base, /)\n" -"--\n" -"\n" -"Set the base URL for the parser."); - -#define PYEXPAT_XMLPARSER_SETBASE_METHODDEF \ - {"SetBase", (PyCFunction)pyexpat_xmlparser_SetBase, METH_VARARGS, pyexpat_xmlparser_SetBase__doc__}, - -static PyObject * -pyexpat_xmlparser_SetBase_impl(xmlparseobject *self, const char *base); - -static PyObject * -pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *args) -{ - PyObject *return_value = NULL; - const char *base; - - if (!PyArg_ParseTuple(args, - "s:SetBase", - &base)) - goto exit; - return_value = pyexpat_xmlparser_SetBase_impl(self, base); - -exit: - return return_value; -} - static PyObject * pyexpat_xmlparser_SetBase_impl(xmlparseobject *self, const char *base) -/*[clinic end generated code: output=5bdb49f6689a5f93 input=c684e5de895ee1a8]*/ +/*[clinic end generated code: output=c212ddceb607b539 input=c684e5de895ee1a8]*/ { if (!XML_SetBase(self->itself, base)) { return PyErr_NoMemory(); @@ -938,27 +872,9 @@ pyexpat.xmlparser.GetBase Return base URL string for the parser. [clinic start generated code]*/ -PyDoc_STRVAR(pyexpat_xmlparser_GetBase__doc__, -"GetBase($self, /)\n" -"--\n" -"\n" -"Return base URL string for the parser."); - -#define PYEXPAT_XMLPARSER_GETBASE_METHODDEF \ - {"GetBase", (PyCFunction)pyexpat_xmlparser_GetBase, METH_NOARGS, pyexpat_xmlparser_GetBase__doc__}, - -static PyObject * -pyexpat_xmlparser_GetBase_impl(xmlparseobject *self); - -static PyObject * -pyexpat_xmlparser_GetBase(xmlparseobject *self, PyObject *Py_UNUSED(ignored)) -{ - return pyexpat_xmlparser_GetBase_impl(self); -} - static PyObject * pyexpat_xmlparser_GetBase_impl(xmlparseobject *self) -/*[clinic end generated code: output=ef6046ee28f2b8ee input=918d71c38009620e]*/ +/*[clinic end generated code: output=2886cb21f9a8739a input=918d71c38009620e]*/ { return Py_BuildValue("z", XML_GetBase(self->itself)); } @@ -972,30 +888,9 @@ If the event was generated by a large am for an element with many attributes), not all of the text may be available. [clinic start generated code]*/ -PyDoc_STRVAR(pyexpat_xmlparser_GetInputContext__doc__, -"GetInputContext($self, /)\n" -"--\n" -"\n" -"Return the untranslated text of the input that caused the current event.\n" -"\n" -"If the event was generated by a large amount of text (such as a start tag\n" -"for an element with many attributes), not all of the text may be available."); - -#define PYEXPAT_XMLPARSER_GETINPUTCONTEXT_METHODDEF \ - {"GetInputContext", (PyCFunction)pyexpat_xmlparser_GetInputContext, METH_NOARGS, pyexpat_xmlparser_GetInputContext__doc__}, - -static PyObject * -pyexpat_xmlparser_GetInputContext_impl(xmlparseobject *self); - -static PyObject * -pyexpat_xmlparser_GetInputContext(xmlparseobject *self, PyObject *Py_UNUSED(ignored)) -{ - return pyexpat_xmlparser_GetInputContext_impl(self); -} - static PyObject * pyexpat_xmlparser_GetInputContext_impl(xmlparseobject *self) -/*[clinic end generated code: output=62ff03390f074cd2 input=034df8712db68379]*/ +/*[clinic end generated code: output=a88026d683fc22cc input=034df8712db68379]*/ { if (self->in_callback) { int offset, size; @@ -1022,38 +917,9 @@ pyexpat.xmlparser.ExternalEntityParserCr Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler. [clinic start generated code]*/ -PyDoc_STRVAR(pyexpat_xmlparser_ExternalEntityParserCreate__doc__, -"ExternalEntityParserCreate($self, context, encoding=None, /)\n" -"--\n" -"\n" -"Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler."); - -#define PYEXPAT_XMLPARSER_EXTERNALENTITYPARSERCREATE_METHODDEF \ - {"ExternalEntityParserCreate", (PyCFunction)pyexpat_xmlparser_ExternalEntityParserCreate, METH_VARARGS, pyexpat_xmlparser_ExternalEntityParserCreate__doc__}, - -static PyObject * -pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self, const char *context, const char *encoding); - -static PyObject * -pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args) -{ - PyObject *return_value = NULL; - const char *context; - const char *encoding = NULL; - - if (!PyArg_ParseTuple(args, - "z|s:ExternalEntityParserCreate", - &context, &encoding)) - goto exit; - return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, context, encoding); - -exit: - return return_value; -} - static PyObject * pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self, const char *context, const char *encoding) -/*[clinic end generated code: output=4948c35f3dd01133 input=283206575d960272]*/ +/*[clinic end generated code: output=942f300ed0e56054 input=283206575d960272]*/ { xmlparseobject *new_parser; int i; @@ -1127,42 +993,9 @@ XML_PARAM_ENTITY_PARSING_ALWAYS. Returns was successful. [clinic start generated code]*/ -PyDoc_STRVAR(pyexpat_xmlparser_SetParamEntityParsing__doc__, -"SetParamEntityParsing($self, flag, /)\n" -"--\n" -"\n" -"Controls parsing of parameter entities (including the external DTD subset).\n" -"\n" -"Possible flag values are XML_PARAM_ENTITY_PARSING_NEVER,\n" -"XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE and\n" -"XML_PARAM_ENTITY_PARSING_ALWAYS. Returns true if setting the flag\n" -"was successful."); - -#define PYEXPAT_XMLPARSER_SETPARAMENTITYPARSING_METHODDEF \ - {"SetParamEntityParsing", (PyCFunction)pyexpat_xmlparser_SetParamEntityParsing, METH_VARARGS, pyexpat_xmlparser_SetParamEntityParsing__doc__}, - -static PyObject * -pyexpat_xmlparser_SetParamEntityParsing_impl(xmlparseobject *self, int flag); - -static PyObject * -pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int flag; - - if (!PyArg_ParseTuple(args, - "i:SetParamEntityParsing", - &flag)) - goto exit; - return_value = pyexpat_xmlparser_SetParamEntityParsing_impl(self, flag); - -exit: - return return_value; -} - static PyObject * pyexpat_xmlparser_SetParamEntityParsing_impl(xmlparseobject *self, int flag) -/*[clinic end generated code: output=0f820882bc7768cc input=8aea19b4b15e9af1]*/ +/*[clinic end generated code: output=18668ee8e760d64c input=8aea19b4b15e9af1]*/ { flag = XML_SetParamEntityParsing(self->itself, flag); return PyLong_FromLong(flag); @@ -1183,41 +1016,9 @@ application, while still getting the adv information to the parser. 'flag' defaults to True if not provided. [clinic start generated code]*/ -PyDoc_STRVAR(pyexpat_xmlparser_UseForeignDTD__doc__, -"UseForeignDTD($self, flag=True, /)\n" -"--\n" -"\n" -"Allows the application to provide an artificial external subset if one is not specified as part of the document instance.\n" -"\n" -"This readily allows the use of a \'default\' document type controlled by the\n" -"application, while still getting the advantage of providing document type\n" -"information to the parser. \'flag\' defaults to True if not provided."); - -#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF \ - {"UseForeignDTD", (PyCFunction)pyexpat_xmlparser_UseForeignDTD, METH_VARARGS, pyexpat_xmlparser_UseForeignDTD__doc__}, - -static PyObject * -pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, int flag); - -static PyObject * -pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int flag = 1; - - if (!PyArg_ParseTuple(args, - "|p:UseForeignDTD", - &flag)) - goto exit; - return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, flag); - -exit: - return return_value; -} - static PyObject * pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, int flag) -/*[clinic end generated code: output=22e924ae6cad67d6 input=78144c519d116a6e]*/ +/*[clinic end generated code: output=cfaa9aa50bb0f65c input=78144c519d116a6e]*/ { enum XML_Error rc; @@ -1234,25 +1035,9 @@ pyexpat_xmlparser_UseForeignDTD_impl(xml pyexpat.xmlparser.__dir__ [clinic start generated code]*/ -PyDoc_STRVAR(pyexpat_xmlparser___dir____doc__, -"__dir__($self, /)\n" -"--"); - -#define PYEXPAT_XMLPARSER___DIR___METHODDEF \ - {"__dir__", (PyCFunction)pyexpat_xmlparser___dir__, METH_NOARGS, pyexpat_xmlparser___dir____doc__}, - -static PyObject * -pyexpat_xmlparser___dir___impl(xmlparseobject *self); - -static PyObject * -pyexpat_xmlparser___dir__(xmlparseobject *self, PyObject *Py_UNUSED(ignored)) -{ - return pyexpat_xmlparser___dir___impl(self); -} - static PyObject * pyexpat_xmlparser___dir___impl(xmlparseobject *self) -/*[clinic end generated code: output=1ed6efe83bc304cc input=76aa455f2a661384]*/ +/*[clinic end generated code: output=bc22451efb9e4d17 input=76aa455f2a661384]*/ { #define APPEND(list, str) \ do { \ @@ -1765,41 +1550,9 @@ pyexpat.ParserCreate Return a new XML parser object. [clinic start generated code]*/ -PyDoc_STRVAR(pyexpat_ParserCreate__doc__, -"ParserCreate($module, /, encoding=None, namespace_separator=None,\n" -" intern=None)\n" -"--\n" -"\n" -"Return a new XML parser object."); - -#define PYEXPAT_PARSERCREATE_METHODDEF \ - {"ParserCreate", (PyCFunction)pyexpat_ParserCreate, METH_VARARGS|METH_KEYWORDS, pyexpat_ParserCreate__doc__}, - -static PyObject * -pyexpat_ParserCreate_impl(PyModuleDef *module, const char *encoding, const char *namespace_separator, PyObject *intern); - -static PyObject * -pyexpat_ParserCreate(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"encoding", "namespace_separator", "intern", NULL}; - const char *encoding = NULL; - const char *namespace_separator = NULL; - PyObject *intern = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|zzO:ParserCreate", _keywords, - &encoding, &namespace_separator, &intern)) - goto exit; - return_value = pyexpat_ParserCreate_impl(module, encoding, namespace_separator, intern); - -exit: - return return_value; -} - static PyObject * pyexpat_ParserCreate_impl(PyModuleDef *module, const char *encoding, const char *namespace_separator, PyObject *intern) -/*[clinic end generated code: output=4fc027dd33b7a2ac input=71b9f471aa6f8f86]*/ +/*[clinic end generated code: output=b839b60992d8ce71 input=71b9f471aa6f8f86]*/ { PyObject *result; int intern_decref = 0; @@ -1842,37 +1595,9 @@ pyexpat.ErrorString Returns string error for given number. [clinic start generated code]*/ -PyDoc_STRVAR(pyexpat_ErrorString__doc__, -"ErrorString($module, code, /)\n" -"--\n" -"\n" -"Returns string error for given number."); - -#define PYEXPAT_ERRORSTRING_METHODDEF \ - {"ErrorString", (PyCFunction)pyexpat_ErrorString, METH_VARARGS, pyexpat_ErrorString__doc__}, - -static PyObject * -pyexpat_ErrorString_impl(PyModuleDef *module, long code); - -static PyObject * -pyexpat_ErrorString(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - long code; - - if (!PyArg_ParseTuple(args, - "l:ErrorString", - &code)) - goto exit; - return_value = pyexpat_ErrorString_impl(module, code); - -exit: - return return_value; -} - static PyObject * pyexpat_ErrorString_impl(PyModuleDef *module, long code) -/*[clinic end generated code: output=c70f3cd82bfaf067 input=cc67de010d9e62b3]*/ +/*[clinic end generated code: output=d87668108b6868e5 input=cc67de010d9e62b3]*/ { return Py_BuildValue("z", XML_ErrorString((int)code)); } @@ -2262,8 +1987,4 @@ static struct HandlerInfo handler_info[] /*[clinic input] dump buffer [clinic start generated code]*/ - -#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF - #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF -#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */ -/*[clinic end generated code: output=a7880cb78bbd58ce input=524ce2e021e4eba6]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=524ce2e021e4eba6]*/ diff -r a824c40e8fc0 Modules/sha1module.c --- a/Modules/sha1module.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/sha1module.c Sun Feb 22 11:52:48 2015 +0200 @@ -53,6 +53,7 @@ typedef struct { struct sha1_state hash_state; } SHA1object; +#include "clinic/sha1module.c.h" /* ------------------------------------------------------------------------ * @@ -320,27 +321,9 @@ SHA1Type.copy Return a copy of the hash object. [clinic start generated code]*/ -PyDoc_STRVAR(SHA1Type_copy__doc__, -"copy($self, /)\n" -"--\n" -"\n" -"Return a copy of the hash object."); - -#define SHA1TYPE_COPY_METHODDEF \ - {"copy", (PyCFunction)SHA1Type_copy, METH_NOARGS, SHA1Type_copy__doc__}, - -static PyObject * -SHA1Type_copy_impl(SHA1object *self); - -static PyObject * -SHA1Type_copy(SHA1object *self, PyObject *Py_UNUSED(ignored)) -{ - return SHA1Type_copy_impl(self); -} - static PyObject * SHA1Type_copy_impl(SHA1object *self) -/*[clinic end generated code: output=1a320e75a7444098 input=b7eae10df6f89b36]*/ +/*[clinic end generated code: output=b4e001264620f02a input=b7eae10df6f89b36]*/ { SHA1object *newobj; @@ -357,27 +340,9 @@ SHA1Type.digest Return the digest value as a string of binary data. [clinic start generated code]*/ -PyDoc_STRVAR(SHA1Type_digest__doc__, -"digest($self, /)\n" -"--\n" -"\n" -"Return the digest value as a string of binary data."); - -#define SHA1TYPE_DIGEST_METHODDEF \ - {"digest", (PyCFunction)SHA1Type_digest, METH_NOARGS, SHA1Type_digest__doc__}, - -static PyObject * -SHA1Type_digest_impl(SHA1object *self); - -static PyObject * -SHA1Type_digest(SHA1object *self, PyObject *Py_UNUSED(ignored)) -{ - return SHA1Type_digest_impl(self); -} - static PyObject * SHA1Type_digest_impl(SHA1object *self) -/*[clinic end generated code: output=c4920f75228bfbfd input=205d47e1927fd009]*/ +/*[clinic end generated code: output=2f05302a7aa2b5cb input=205d47e1927fd009]*/ { unsigned char digest[SHA1_DIGESTSIZE]; struct sha1_state temp; @@ -393,27 +358,9 @@ SHA1Type.hexdigest Return the digest value as a string of hexadecimal digits. [clinic start generated code]*/ -PyDoc_STRVAR(SHA1Type_hexdigest__doc__, -"hexdigest($self, /)\n" -"--\n" -"\n" -"Return the digest value as a string of hexadecimal digits."); - -#define SHA1TYPE_HEXDIGEST_METHODDEF \ - {"hexdigest", (PyCFunction)SHA1Type_hexdigest, METH_NOARGS, SHA1Type_hexdigest__doc__}, - -static PyObject * -SHA1Type_hexdigest_impl(SHA1object *self); - -static PyObject * -SHA1Type_hexdigest(SHA1object *self, PyObject *Py_UNUSED(ignored)) -{ - return SHA1Type_hexdigest_impl(self); -} - static PyObject * SHA1Type_hexdigest_impl(SHA1object *self) -/*[clinic end generated code: output=6e345aac201887b2 input=97691055c0c74ab0]*/ +/*[clinic end generated code: output=4161fd71e68c6659 input=97691055c0c74ab0]*/ { unsigned char digest[SHA1_DIGESTSIZE]; struct sha1_state temp; @@ -454,18 +401,9 @@ SHA1Type.update Update this hash object's state with the provided string. [clinic start generated code]*/ -PyDoc_STRVAR(SHA1Type_update__doc__, -"update($self, obj, /)\n" -"--\n" -"\n" -"Update this hash object\'s state with the provided string."); - -#define SHA1TYPE_UPDATE_METHODDEF \ - {"update", (PyCFunction)SHA1Type_update, METH_O, SHA1Type_update__doc__}, - static PyObject * SHA1Type_update(SHA1object *self, PyObject *obj) -/*[clinic end generated code: output=ab20a86a25e7d255 input=aad8e07812edbba3]*/ +/*[clinic end generated code: output=d9902f0e5015e9ae input=aad8e07812edbba3]*/ { Py_buffer buf; @@ -566,38 +504,9 @@ static PyTypeObject SHA1type = { Return a new SHA1 hash object; optionally initialized with a string. [clinic start generated code]*/ -PyDoc_STRVAR(_sha1_sha1__doc__, -"sha1($module, /, string=b\'\')\n" -"--\n" -"\n" -"Return a new SHA1 hash object; optionally initialized with a string."); - -#define _SHA1_SHA1_METHODDEF \ - {"sha1", (PyCFunction)_sha1_sha1, METH_VARARGS|METH_KEYWORDS, _sha1_sha1__doc__}, - -static PyObject * -_sha1_sha1_impl(PyModuleDef *module, PyObject *string); - -static PyObject * -_sha1_sha1(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"string", NULL}; - PyObject *string = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|O:sha1", _keywords, - &string)) - goto exit; - return_value = _sha1_sha1_impl(module, string); - -exit: - return return_value; -} - static PyObject * _sha1_sha1_impl(PyModuleDef *module, PyObject *string) -/*[clinic end generated code: output=c9068552f07b8954 input=27ea54281d995ec2]*/ +/*[clinic end generated code: output=3e4e841386b9e8db input=27ea54281d995ec2]*/ { SHA1object *new; Py_buffer buf; diff -r a824c40e8fc0 Modules/sha256module.c --- a/Modules/sha256module.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/sha256module.c Sun Feb 22 11:52:48 2015 +0200 @@ -52,6 +52,8 @@ typedef struct { int digestsize; } SHAobject; +#include "clinic/sha256module.c.h" + /* When run on a little-endian CPU we need to perform byte reversal on an array of longwords. */ @@ -404,27 +406,9 @@ SHA256Type.copy Return a copy of the hash object. [clinic start generated code]*/ -PyDoc_STRVAR(SHA256Type_copy__doc__, -"copy($self, /)\n" -"--\n" -"\n" -"Return a copy of the hash object."); - -#define SHA256TYPE_COPY_METHODDEF \ - {"copy", (PyCFunction)SHA256Type_copy, METH_NOARGS, SHA256Type_copy__doc__}, - -static PyObject * -SHA256Type_copy_impl(SHAobject *self); - -static PyObject * -SHA256Type_copy(SHAobject *self, PyObject *Py_UNUSED(ignored)) -{ - return SHA256Type_copy_impl(self); -} - static PyObject * SHA256Type_copy_impl(SHAobject *self) -/*[clinic end generated code: output=f716c39d3f81c27c input=f58840a618d4f2a7]*/ +/*[clinic end generated code: output=1a8bbd66a0c9c168 input=f58840a618d4f2a7]*/ { SHAobject *newobj; @@ -446,27 +430,9 @@ SHA256Type.digest Return the digest value as a string of binary data. [clinic start generated code]*/ -PyDoc_STRVAR(SHA256Type_digest__doc__, -"digest($self, /)\n" -"--\n" -"\n" -"Return the digest value as a string of binary data."); - -#define SHA256TYPE_DIGEST_METHODDEF \ - {"digest", (PyCFunction)SHA256Type_digest, METH_NOARGS, SHA256Type_digest__doc__}, - -static PyObject * -SHA256Type_digest_impl(SHAobject *self); - -static PyObject * -SHA256Type_digest(SHAobject *self, PyObject *Py_UNUSED(ignored)) -{ - return SHA256Type_digest_impl(self); -} - static PyObject * SHA256Type_digest_impl(SHAobject *self) -/*[clinic end generated code: output=72d34723d7bb694c input=1fb752e58954157d]*/ +/*[clinic end generated code: output=46616a5e909fbc3d input=1fb752e58954157d]*/ { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; @@ -482,27 +448,9 @@ SHA256Type.hexdigest Return the digest value as a string of hexadecimal digits. [clinic start generated code]*/ -PyDoc_STRVAR(SHA256Type_hexdigest__doc__, -"hexdigest($self, /)\n" -"--\n" -"\n" -"Return the digest value as a string of hexadecimal digits."); - -#define SHA256TYPE_HEXDIGEST_METHODDEF \ - {"hexdigest", (PyCFunction)SHA256Type_hexdigest, METH_NOARGS, SHA256Type_hexdigest__doc__}, - -static PyObject * -SHA256Type_hexdigest_impl(SHAobject *self); - -static PyObject * -SHA256Type_hexdigest(SHAobject *self, PyObject *Py_UNUSED(ignored)) -{ - return SHA256Type_hexdigest_impl(self); -} - static PyObject * SHA256Type_hexdigest_impl(SHAobject *self) -/*[clinic end generated code: output=3687aa6183c7d27f input=0cc4c714693010d1]*/ +/*[clinic end generated code: output=725f8a7041ae97f3 input=0cc4c714693010d1]*/ { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; @@ -543,18 +491,9 @@ SHA256Type.update Update this hash object's state with the provided string. [clinic start generated code]*/ -PyDoc_STRVAR(SHA256Type_update__doc__, -"update($self, obj, /)\n" -"--\n" -"\n" -"Update this hash object\'s state with the provided string."); - -#define SHA256TYPE_UPDATE_METHODDEF \ - {"update", (PyCFunction)SHA256Type_update, METH_O, SHA256Type_update__doc__}, - static PyObject * SHA256Type_update(SHAobject *self, PyObject *obj) -/*[clinic end generated code: output=b47f53d7cbeabee4 input=b2d449d5b30f0f5a]*/ +/*[clinic end generated code: output=0967fb2860c66af7 input=b2d449d5b30f0f5a]*/ { Py_buffer buf; @@ -686,38 +625,9 @@ static PyTypeObject SHA256type = { Return a new SHA-256 hash object; optionally initialized with a string. [clinic start generated code]*/ -PyDoc_STRVAR(_sha256_sha256__doc__, -"sha256($module, /, string=b\'\')\n" -"--\n" -"\n" -"Return a new SHA-256 hash object; optionally initialized with a string."); - -#define _SHA256_SHA256_METHODDEF \ - {"sha256", (PyCFunction)_sha256_sha256, METH_VARARGS|METH_KEYWORDS, _sha256_sha256__doc__}, - -static PyObject * -_sha256_sha256_impl(PyModuleDef *module, PyObject *string); - -static PyObject * -_sha256_sha256(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"string", NULL}; - PyObject *string = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|O:sha256", _keywords, - &string)) - goto exit; - return_value = _sha256_sha256_impl(module, string); - -exit: - return return_value; -} - static PyObject * _sha256_sha256_impl(PyModuleDef *module, PyObject *string) -/*[clinic end generated code: output=4b1263d1e2fcdb98 input=09cce3fb855056b2]*/ +/*[clinic end generated code: output=d70e6e2d97112844 input=09cce3fb855056b2]*/ { SHAobject *new; Py_buffer buf; @@ -755,38 +665,9 @@ static PyObject * Return a new SHA-224 hash object; optionally initialized with a string. [clinic start generated code]*/ -PyDoc_STRVAR(_sha256_sha224__doc__, -"sha224($module, /, string=b\'\')\n" -"--\n" -"\n" -"Return a new SHA-224 hash object; optionally initialized with a string."); - -#define _SHA256_SHA224_METHODDEF \ - {"sha224", (PyCFunction)_sha256_sha224, METH_VARARGS|METH_KEYWORDS, _sha256_sha224__doc__}, - -static PyObject * -_sha256_sha224_impl(PyModuleDef *module, PyObject *string); - -static PyObject * -_sha256_sha224(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"string", NULL}; - PyObject *string = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|O:sha224", _keywords, - &string)) - goto exit; - return_value = _sha256_sha224_impl(module, string); - -exit: - return return_value; -} - static PyObject * _sha256_sha224_impl(PyModuleDef *module, PyObject *string) -/*[clinic end generated code: output=4dde0eb1cdaebc06 input=27a04ba24c353a73]*/ +/*[clinic end generated code: output=f2822bf28416b42a input=27a04ba24c353a73]*/ { SHAobject *new; Py_buffer buf; diff -r a824c40e8fc0 Modules/sha512module.c --- a/Modules/sha512module.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/sha512module.c Sun Feb 22 11:52:48 2015 +0200 @@ -55,6 +55,8 @@ typedef struct { int digestsize; } SHAobject; +#include "clinic/sha512module.c.h" + /* When run on a little-endian CPU we need to perform byte reversal on an array of longwords. */ @@ -471,27 +473,9 @@ SHA512Type.copy Return a copy of the hash object. [clinic start generated code]*/ -PyDoc_STRVAR(SHA512Type_copy__doc__, -"copy($self, /)\n" -"--\n" -"\n" -"Return a copy of the hash object."); - -#define SHA512TYPE_COPY_METHODDEF \ - {"copy", (PyCFunction)SHA512Type_copy, METH_NOARGS, SHA512Type_copy__doc__}, - -static PyObject * -SHA512Type_copy_impl(SHAobject *self); - -static PyObject * -SHA512Type_copy(SHAobject *self, PyObject *Py_UNUSED(ignored)) -{ - return SHA512Type_copy_impl(self); -} - static PyObject * SHA512Type_copy_impl(SHAobject *self) -/*[clinic end generated code: output=14f8e6ce9c61ece0 input=9f5f31e6c457776a]*/ +/*[clinic end generated code: output=adea896ed3164821 input=9f5f31e6c457776a]*/ { SHAobject *newobj; @@ -513,27 +497,9 @@ SHA512Type.digest Return the digest value as a string of binary data. [clinic start generated code]*/ -PyDoc_STRVAR(SHA512Type_digest__doc__, -"digest($self, /)\n" -"--\n" -"\n" -"Return the digest value as a string of binary data."); - -#define SHA512TYPE_DIGEST_METHODDEF \ - {"digest", (PyCFunction)SHA512Type_digest, METH_NOARGS, SHA512Type_digest__doc__}, - -static PyObject * -SHA512Type_digest_impl(SHAobject *self); - -static PyObject * -SHA512Type_digest(SHAobject *self, PyObject *Py_UNUSED(ignored)) -{ - return SHA512Type_digest_impl(self); -} - static PyObject * SHA512Type_digest_impl(SHAobject *self) -/*[clinic end generated code: output=be8de024b232977e input=60c2cede9e023018]*/ +/*[clinic end generated code: output=1080bbeeef7dde1b input=60c2cede9e023018]*/ { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; @@ -549,27 +515,9 @@ SHA512Type.hexdigest Return the digest value as a string of hexadecimal digits. [clinic start generated code]*/ -PyDoc_STRVAR(SHA512Type_hexdigest__doc__, -"hexdigest($self, /)\n" -"--\n" -"\n" -"Return the digest value as a string of hexadecimal digits."); - -#define SHA512TYPE_HEXDIGEST_METHODDEF \ - {"hexdigest", (PyCFunction)SHA512Type_hexdigest, METH_NOARGS, SHA512Type_hexdigest__doc__}, - -static PyObject * -SHA512Type_hexdigest_impl(SHAobject *self); - -static PyObject * -SHA512Type_hexdigest(SHAobject *self, PyObject *Py_UNUSED(ignored)) -{ - return SHA512Type_hexdigest_impl(self); -} - static PyObject * SHA512Type_hexdigest_impl(SHAobject *self) -/*[clinic end generated code: output=28a4ab2f9a1781b8 input=498b877b25cbe0a2]*/ +/*[clinic end generated code: output=7373305b8601e18b input=498b877b25cbe0a2]*/ { unsigned char digest[SHA_DIGESTSIZE]; SHAobject temp; @@ -610,18 +558,9 @@ SHA512Type.update Update this hash object's state with the provided string. [clinic start generated code]*/ -PyDoc_STRVAR(SHA512Type_update__doc__, -"update($self, obj, /)\n" -"--\n" -"\n" -"Update this hash object\'s state with the provided string."); - -#define SHA512TYPE_UPDATE_METHODDEF \ - {"update", (PyCFunction)SHA512Type_update, METH_O, SHA512Type_update__doc__}, - static PyObject * SHA512Type_update(SHAobject *self, PyObject *obj) -/*[clinic end generated code: output=6be574cdc3a9c52d input=ded2b46656566283]*/ +/*[clinic end generated code: output=1cf333e73995a79e input=ded2b46656566283]*/ { Py_buffer buf; @@ -636,23 +575,7 @@ SHA512Type_update(SHAobject *self, PyObj /*[clinic input] dump buffer [clinic start generated code]*/ - -#ifndef SHA512TYPE_COPY_METHODDEF - #define SHA512TYPE_COPY_METHODDEF -#endif /* !defined(SHA512TYPE_COPY_METHODDEF) */ - -#ifndef SHA512TYPE_DIGEST_METHODDEF - #define SHA512TYPE_DIGEST_METHODDEF -#endif /* !defined(SHA512TYPE_DIGEST_METHODDEF) */ - -#ifndef SHA512TYPE_HEXDIGEST_METHODDEF - #define SHA512TYPE_HEXDIGEST_METHODDEF -#endif /* !defined(SHA512TYPE_HEXDIGEST_METHODDEF) */ - -#ifndef SHA512TYPE_UPDATE_METHODDEF - #define SHA512TYPE_UPDATE_METHODDEF -#endif /* !defined(SHA512TYPE_UPDATE_METHODDEF) */ -/*[clinic end generated code: output=de713947d31130e9 input=524ce2e021e4eba6]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=524ce2e021e4eba6]*/ static PyMethodDef SHA_methods[] = { SHA512TYPE_COPY_METHODDEF @@ -773,38 +696,9 @@ static PyTypeObject SHA512type = { Return a new SHA-512 hash object; optionally initialized with a string. [clinic start generated code]*/ -PyDoc_STRVAR(_sha512_sha512__doc__, -"sha512($module, /, string=b\'\')\n" -"--\n" -"\n" -"Return a new SHA-512 hash object; optionally initialized with a string."); - -#define _SHA512_SHA512_METHODDEF \ - {"sha512", (PyCFunction)_sha512_sha512, METH_VARARGS|METH_KEYWORDS, _sha512_sha512__doc__}, - -static PyObject * -_sha512_sha512_impl(PyModuleDef *module, PyObject *string); - -static PyObject * -_sha512_sha512(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"string", NULL}; - PyObject *string = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|O:sha512", _keywords, - &string)) - goto exit; - return_value = _sha512_sha512_impl(module, string); - -exit: - return return_value; -} - static PyObject * _sha512_sha512_impl(PyModuleDef *module, PyObject *string) -/*[clinic end generated code: output=9e39b11115f36878 input=e69bad9ae9b6a308]*/ +/*[clinic end generated code: output=da13bc0a94da6de3 input=e69bad9ae9b6a308]*/ { SHAobject *new; Py_buffer buf; @@ -842,38 +736,9 @@ static PyObject * Return a new SHA-384 hash object; optionally initialized with a string. [clinic start generated code]*/ -PyDoc_STRVAR(_sha512_sha384__doc__, -"sha384($module, /, string=b\'\')\n" -"--\n" -"\n" -"Return a new SHA-384 hash object; optionally initialized with a string."); - -#define _SHA512_SHA384_METHODDEF \ - {"sha384", (PyCFunction)_sha512_sha384, METH_VARARGS|METH_KEYWORDS, _sha512_sha384__doc__}, - -static PyObject * -_sha512_sha384_impl(PyModuleDef *module, PyObject *string); - -static PyObject * -_sha512_sha384(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"string", NULL}; - PyObject *string = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|O:sha384", _keywords, - &string)) - goto exit; - return_value = _sha512_sha384_impl(module, string); - -exit: - return return_value; -} - static PyObject * _sha512_sha384_impl(PyModuleDef *module, PyObject *string) -/*[clinic end generated code: output=397c6fba3525b93a input=c9327788d4ea4545]*/ +/*[clinic end generated code: output=ac731aea5509174d input=c9327788d4ea4545]*/ { SHAobject *new; Py_buffer buf; @@ -907,15 +772,7 @@ static PyObject * /*[clinic input] dump buffer [clinic start generated code]*/ - -#ifndef _SHA512_SHA512_METHODDEF - #define _SHA512_SHA512_METHODDEF -#endif /* !defined(_SHA512_SHA512_METHODDEF) */ - -#ifndef _SHA512_SHA384_METHODDEF - #define _SHA512_SHA384_METHODDEF -#endif /* !defined(_SHA512_SHA384_METHODDEF) */ -/*[clinic end generated code: output=69d84aa9445b01d8 input=524ce2e021e4eba6]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=524ce2e021e4eba6]*/ /* List of functions exported by this module */ diff -r a824c40e8fc0 Modules/unicodedata.c --- a/Modules/unicodedata.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Modules/unicodedata.c Sun Feb 22 11:52:48 2015 +0200 @@ -73,6 +73,8 @@ typedef struct previous_version { Py_UCS4 (*normalization)(Py_UCS4); } PreviousDBVersion; +#include "clinic/unicodedata.c.h" + #define get_old_record(self, v) ((((PreviousDBVersion*)self)->getrecord)(v)) static PyMemberDef DB_members[] = { @@ -130,42 +132,9 @@ as integer. If no such value is defined, not given, ValueError is raised. [clinic start generated code]*/ -PyDoc_STRVAR(unicodedata_UCD_decimal__doc__, -"decimal($self, unichr, default=None, /)\n" -"--\n" -"\n" -"Converts a Unicode character into its equivalent decimal value.\n" -"\n" -"Returns the decimal value assigned to the Unicode character unichr\n" -"as integer. If no such value is defined, default is returned, or, if\n" -"not given, ValueError is raised."); - -#define UNICODEDATA_UCD_DECIMAL_METHODDEF \ - {"decimal", (PyCFunction)unicodedata_UCD_decimal, METH_VARARGS, unicodedata_UCD_decimal__doc__}, - -static PyObject * -unicodedata_UCD_decimal_impl(PreviousDBVersion *self, PyUnicodeObject *unichr, PyObject *default_value); - -static PyObject * -unicodedata_UCD_decimal(PreviousDBVersion *self, PyObject *args) -{ - PyObject *return_value = NULL; - PyUnicodeObject *unichr; - PyObject *default_value = NULL; - - if (!PyArg_ParseTuple(args, - "O!|O:decimal", - &PyUnicode_Type, &unichr, &default_value)) - goto exit; - return_value = unicodedata_UCD_decimal_impl(self, unichr, default_value); - -exit: - return return_value; -} - static PyObject * unicodedata_UCD_decimal_impl(PreviousDBVersion *self, PyUnicodeObject *unichr, PyObject *default_value) -/*[clinic end generated code: output=8689669896d293df input=c25c9d2b4de076b1]*/ +/*[clinic end generated code: output=d285215533b58b28 input=c25c9d2b4de076b1]*/ { int have_old = 0; long rc; diff -r a824c40e8fc0 Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Objects/bytearrayobject.c Sun Feb 22 11:52:48 2015 +0200 @@ -90,6 +90,8 @@ static int return 1; } +#include "clinic/bytearrayobject.c.h" + /* Direct API functions */ PyObject * @@ -1250,27 +1252,9 @@ bytearray.clear Remove all items from the bytearray. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_clear__doc__, -"clear($self, /)\n" -"--\n" -"\n" -"Remove all items from the bytearray."); - -#define BYTEARRAY_CLEAR_METHODDEF \ - {"clear", (PyCFunction)bytearray_clear, METH_NOARGS, bytearray_clear__doc__}, - -static PyObject * -bytearray_clear_impl(PyByteArrayObject *self); - -static PyObject * -bytearray_clear(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) -{ - return bytearray_clear_impl(self); -} - static PyObject * bytearray_clear_impl(PyByteArrayObject *self) -/*[clinic end generated code: output=5344093031e2f36c input=e524fd330abcdc18]*/ +/*[clinic end generated code: output=85c2fe6aede0956c input=e524fd330abcdc18]*/ { if (PyByteArray_Resize((PyObject *)self, 0) < 0) return NULL; @@ -1285,27 +1269,9 @@ bytearray.copy Return a copy of B. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_copy__doc__, -"copy($self, /)\n" -"--\n" -"\n" -"Return a copy of B."); - -#define BYTEARRAY_COPY_METHODDEF \ - {"copy", (PyCFunction)bytearray_copy, METH_NOARGS, bytearray_copy__doc__}, - -static PyObject * -bytearray_copy_impl(PyByteArrayObject *self); - -static PyObject * -bytearray_copy(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) -{ - return bytearray_copy_impl(self); -} - static PyObject * bytearray_copy_impl(PyByteArrayObject *self) -/*[clinic end generated code: output=8788ed299f7f2214 input=6d5d2975aa0f33f3]*/ +/*[clinic end generated code: output=68cfbcfed484c132 input=6d5d2975aa0f33f3]*/ { return PyByteArray_FromStringAndSize(PyByteArray_AS_STRING((PyObject *)self), PyByteArray_GET_SIZE(self)); @@ -1541,53 +1507,9 @@ All characters occurring in the optional The remaining characters are mapped through the given translation table. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_translate__doc__, -"translate(table, [deletechars])\n" -"Return a copy with each character mapped by the given translation table.\n" -"\n" -" table\n" -" Translation table, which must be a bytes object of length 256.\n" -"\n" -"All characters occurring in the optional argument deletechars are removed.\n" -"The remaining characters are mapped through the given translation table."); - -#define BYTEARRAY_TRANSLATE_METHODDEF \ - {"translate", (PyCFunction)bytearray_translate, METH_VARARGS, bytearray_translate__doc__}, - -static PyObject * -bytearray_translate_impl(PyByteArrayObject *self, PyObject *table, int group_right_1, PyObject *deletechars); - -static PyObject * -bytearray_translate(PyByteArrayObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *table; - int group_right_1 = 0; - PyObject *deletechars = NULL; - - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:translate", &table)) - goto exit; - break; - case 2: - if (!PyArg_ParseTuple(args, "OO:translate", &table, &deletechars)) - goto exit; - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "bytearray.translate requires 1 to 2 arguments"); - goto exit; - } - return_value = bytearray_translate_impl(self, table, group_right_1, deletechars); - -exit: - return return_value; -} - static PyObject * bytearray_translate_impl(PyByteArrayObject *self, PyObject *table, int group_right_1, PyObject *deletechars) -/*[clinic end generated code: output=a709df81d41db4b7 input=b749ad85f4860824]*/ +/*[clinic end generated code: output=fa3ea4f9a8d58bc7 input=b749ad85f4860824]*/ { char *input, *output; const char *table_chars; @@ -1692,50 +1614,9 @@ the same position in to. The bytes objects frm and to must be of the same length. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_maketrans__doc__, -"maketrans(frm, to, /)\n" -"--\n" -"\n" -"Return a translation table useable for the bytes or bytearray translate method.\n" -"\n" -"The returned table will be one where each byte in frm is mapped to the byte at\n" -"the same position in to.\n" -"\n" -"The bytes objects frm and to must be of the same length."); - -#define BYTEARRAY_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)bytearray_maketrans, METH_VARARGS|METH_STATIC, bytearray_maketrans__doc__}, - -static PyObject * -bytearray_maketrans_impl(Py_buffer *frm, Py_buffer *to); - -static PyObject * -bytearray_maketrans(void *null, PyObject *args) -{ - PyObject *return_value = NULL; - Py_buffer frm = {NULL, NULL}; - Py_buffer to = {NULL, NULL}; - - if (!PyArg_ParseTuple(args, - "y*y*:maketrans", - &frm, &to)) - goto exit; - return_value = bytearray_maketrans_impl(&frm, &to); - -exit: - /* Cleanup for frm */ - if (frm.obj) - PyBuffer_Release(&frm); - /* Cleanup for to */ - if (to.obj) - PyBuffer_Release(&to); - - return return_value; -} - static PyObject * bytearray_maketrans_impl(Py_buffer *frm, Py_buffer *to) -/*[clinic end generated code: output=d332622814c26f4b input=5925a81d2fbbf151]*/ +/*[clinic end generated code: output=1df267d99f56b15e input=5925a81d2fbbf151]*/ { return _Py_bytes_maketrans(frm, to); } @@ -2244,53 +2125,9 @@ If the optional argument count is given, replaced. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_replace__doc__, -"replace($self, old, new, count=-1, /)\n" -"--\n" -"\n" -"Return a copy with all occurrences of substring old replaced by new.\n" -"\n" -" count\n" -" Maximum number of occurrences to replace.\n" -" -1 (the default value) means replace all occurrences.\n" -"\n" -"If the optional argument count is given, only the first count occurrences are\n" -"replaced."); - -#define BYTEARRAY_REPLACE_METHODDEF \ - {"replace", (PyCFunction)bytearray_replace, METH_VARARGS, bytearray_replace__doc__}, - -static PyObject * -bytearray_replace_impl(PyByteArrayObject *self, Py_buffer *old, Py_buffer *new, Py_ssize_t count); - -static PyObject * -bytearray_replace(PyByteArrayObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - Py_buffer old = {NULL, NULL}; - Py_buffer new = {NULL, NULL}; - Py_ssize_t count = -1; - - if (!PyArg_ParseTuple(args, - "y*y*|n:replace", - &old, &new, &count)) - goto exit; - return_value = bytearray_replace_impl(self, &old, &new, count); - -exit: - /* Cleanup for old */ - if (old.obj) - PyBuffer_Release(&old); - /* Cleanup for new */ - if (new.obj) - PyBuffer_Release(&new); - - return return_value; -} - static PyObject * bytearray_replace_impl(PyByteArrayObject *self, Py_buffer *old, Py_buffer *new, Py_ssize_t count) -/*[clinic end generated code: output=9997fbbd5bac4883 input=aa379d988637c7fb]*/ +/*[clinic end generated code: output=3fc105c8232d7b3f input=aa379d988637c7fb]*/ { return (PyObject *)replace((PyByteArrayObject *) self, old->buf, old->len, @@ -2311,47 +2148,9 @@ bytearray.split Return a list of the sections in the bytearray, using sep as the delimiter. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_split__doc__, -"split($self, /, sep=None, maxsplit=-1)\n" -"--\n" -"\n" -"Return a list of the sections in the bytearray, using sep as the delimiter.\n" -"\n" -" sep\n" -" The delimiter according which to split the bytearray.\n" -" None (the default value) means split on ASCII whitespace characters\n" -" (space, tab, return, newline, formfeed, vertical tab).\n" -" maxsplit\n" -" Maximum number of splits to do.\n" -" -1 (the default value) means no limit."); - -#define BYTEARRAY_SPLIT_METHODDEF \ - {"split", (PyCFunction)bytearray_split, METH_VARARGS|METH_KEYWORDS, bytearray_split__doc__}, - -static PyObject * -bytearray_split_impl(PyByteArrayObject *self, PyObject *sep, Py_ssize_t maxsplit); - -static PyObject * -bytearray_split(PyByteArrayObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"sep", "maxsplit", NULL}; - PyObject *sep = Py_None; - Py_ssize_t maxsplit = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|On:split", _keywords, - &sep, &maxsplit)) - goto exit; - return_value = bytearray_split_impl(self, sep, maxsplit); - -exit: - return return_value; -} - static PyObject * bytearray_split_impl(PyByteArrayObject *self, PyObject *sep, Py_ssize_t maxsplit) -/*[clinic end generated code: output=062a3d87d6f918fa input=24f82669f41bf523]*/ +/*[clinic end generated code: output=cdccf5a29dbf7eb5 input=24f82669f41bf523]*/ { Py_ssize_t len = PyByteArray_GET_SIZE(self), n; const char *s = PyByteArray_AS_STRING(self), *sub; @@ -2393,25 +2192,9 @@ If the separator is not found, returns a bytearray object and two empty bytearray objects. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_partition__doc__, -"partition($self, sep, /)\n" -"--\n" -"\n" -"Partition the bytearray into three parts using the given separator.\n" -"\n" -"This will search for the separator sep in the bytearray. If the separator is\n" -"found, returns a 3-tuple containing the part before the separator, the\n" -"separator itself, and the part after it.\n" -"\n" -"If the separator is not found, returns a 3-tuple containing the original\n" -"bytearray object and two empty bytearray objects."); - -#define BYTEARRAY_PARTITION_METHODDEF \ - {"partition", (PyCFunction)bytearray_partition, METH_O, bytearray_partition__doc__}, - static PyObject * bytearray_partition(PyByteArrayObject *self, PyObject *sep) -/*[clinic end generated code: output=2645138221fe6f4d input=7d7fe37b1696d506]*/ +/*[clinic end generated code: output=45d2525ddd35f957 input=7d7fe37b1696d506]*/ { PyObject *bytesep, *result; @@ -2447,25 +2230,9 @@ If the separator is not found, returns a objects and the original bytearray object. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_rpartition__doc__, -"rpartition($self, sep, /)\n" -"--\n" -"\n" -"Partition the bytes into three parts using the given separator.\n" -"\n" -"This will search for the separator sep in the bytearray, starting and the end.\n" -"If the separator is found, returns a 3-tuple containing the part before the\n" -"separator, the separator itself, and the part after it.\n" -"\n" -"If the separator is not found, returns a 3-tuple containing two empty bytearray\n" -"objects and the original bytearray object."); - -#define BYTEARRAY_RPARTITION_METHODDEF \ - {"rpartition", (PyCFunction)bytearray_rpartition, METH_O, bytearray_rpartition__doc__}, - static PyObject * bytearray_rpartition(PyByteArrayObject *self, PyObject *sep) -/*[clinic end generated code: output=ed13e54605d007de input=9b8cd540c1b75853]*/ +/*[clinic end generated code: output=440de3c9426115e8 input=9b8cd540c1b75853]*/ { PyObject *bytesep, *result; @@ -2492,49 +2259,9 @@ Return a list of the sections in the byt Splitting is done starting at the end of the bytearray and working to the front. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_rsplit__doc__, -"rsplit($self, /, sep=None, maxsplit=-1)\n" -"--\n" -"\n" -"Return a list of the sections in the bytearray, using sep as the delimiter.\n" -"\n" -" sep\n" -" The delimiter according which to split the bytearray.\n" -" None (the default value) means split on ASCII whitespace characters\n" -" (space, tab, return, newline, formfeed, vertical tab).\n" -" maxsplit\n" -" Maximum number of splits to do.\n" -" -1 (the default value) means no limit.\n" -"\n" -"Splitting is done starting at the end of the bytearray and working to the front."); - -#define BYTEARRAY_RSPLIT_METHODDEF \ - {"rsplit", (PyCFunction)bytearray_rsplit, METH_VARARGS|METH_KEYWORDS, bytearray_rsplit__doc__}, - -static PyObject * -bytearray_rsplit_impl(PyByteArrayObject *self, PyObject *sep, Py_ssize_t maxsplit); - -static PyObject * -bytearray_rsplit(PyByteArrayObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"sep", "maxsplit", NULL}; - PyObject *sep = Py_None; - Py_ssize_t maxsplit = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|On:rsplit", _keywords, - &sep, &maxsplit)) - goto exit; - return_value = bytearray_rsplit_impl(self, sep, maxsplit); - -exit: - return return_value; -} - static PyObject * bytearray_rsplit_impl(PyByteArrayObject *self, PyObject *sep, Py_ssize_t maxsplit) -/*[clinic end generated code: output=affaf9fc2aae8d41 input=a68286e4dd692ffe]*/ +/*[clinic end generated code: output=4d648cf3ac65c9e9 input=a68286e4dd692ffe]*/ { Py_ssize_t len = PyByteArray_GET_SIZE(self), n; const char *s = PyByteArray_AS_STRING(self), *sub; @@ -2567,27 +2294,9 @@ bytearray.reverse Reverse the order of the values in B in place. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_reverse__doc__, -"reverse($self, /)\n" -"--\n" -"\n" -"Reverse the order of the values in B in place."); - -#define BYTEARRAY_REVERSE_METHODDEF \ - {"reverse", (PyCFunction)bytearray_reverse, METH_NOARGS, bytearray_reverse__doc__}, - -static PyObject * -bytearray_reverse_impl(PyByteArrayObject *self); - -static PyObject * -bytearray_reverse(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) -{ - return bytearray_reverse_impl(self); -} - static PyObject * bytearray_reverse_impl(PyByteArrayObject *self) -/*[clinic end generated code: output=5d5e5f0bfc67f476 input=7933a499b8597bd1]*/ +/*[clinic end generated code: output=9f7616f29ab309d3 input=7933a499b8597bd1]*/ { char swap, *head, *tail; Py_ssize_t i, j, n = Py_SIZE(self); @@ -2626,43 +2335,9 @@ bytearray.insert Insert a single item into the bytearray before the given index. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_insert__doc__, -"insert($self, index, item, /)\n" -"--\n" -"\n" -"Insert a single item into the bytearray before the given index.\n" -"\n" -" index\n" -" The index where the value is to be inserted.\n" -" item\n" -" The item to be inserted."); - -#define BYTEARRAY_INSERT_METHODDEF \ - {"insert", (PyCFunction)bytearray_insert, METH_VARARGS, bytearray_insert__doc__}, - -static PyObject * -bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item); - -static PyObject * -bytearray_insert(PyByteArrayObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - Py_ssize_t index; - int item; - - if (!PyArg_ParseTuple(args, - "nO&:insert", - &index, _getbytevalue, &item)) - goto exit; - return_value = bytearray_insert_impl(self, index, item); - -exit: - return return_value; -} - static PyObject * bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item) -/*[clinic end generated code: output=5ec9340d4ad19080 input=833766836ba30e1e]*/ +/*[clinic end generated code: output=76c775a70e7b07b7 input=833766836ba30e1e]*/ { Py_ssize_t n = Py_SIZE(self); char *buf; @@ -2700,40 +2375,9 @@ bytearray.append Append a single item to the end of the bytearray. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_append__doc__, -"append($self, item, /)\n" -"--\n" -"\n" -"Append a single item to the end of the bytearray.\n" -"\n" -" item\n" -" The item to be appended."); - -#define BYTEARRAY_APPEND_METHODDEF \ - {"append", (PyCFunction)bytearray_append, METH_VARARGS, bytearray_append__doc__}, - -static PyObject * -bytearray_append_impl(PyByteArrayObject *self, int item); - -static PyObject * -bytearray_append(PyByteArrayObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int item; - - if (!PyArg_ParseTuple(args, - "O&:append", - _getbytevalue, &item)) - goto exit; - return_value = bytearray_append_impl(self, item); - -exit: - return return_value; -} - static PyObject * bytearray_append_impl(PyByteArrayObject *self, int item) -/*[clinic end generated code: output=b5b3325bb3bbaf85 input=ae56ea87380407cc]*/ +/*[clinic end generated code: output=a154e19ed1886cb6 input=ae56ea87380407cc]*/ { Py_ssize_t n = Py_SIZE(self); @@ -2761,21 +2405,9 @@ bytearray.extend Append all the items from the iterator or sequence to the end of the bytearray. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_extend__doc__, -"extend($self, iterable_of_ints, /)\n" -"--\n" -"\n" -"Append all the items from the iterator or sequence to the end of the bytearray.\n" -"\n" -" iterable_of_ints\n" -" The iterable of items to append."); - -#define BYTEARRAY_EXTEND_METHODDEF \ - {"extend", (PyCFunction)bytearray_extend, METH_O, bytearray_extend__doc__}, - static PyObject * bytearray_extend(PyByteArrayObject *self, PyObject *iterable_of_ints) -/*[clinic end generated code: output=13b0c13ad5110dfb input=ce83a5d75b70d850]*/ +/*[clinic end generated code: output=98155dbe249170b1 input=ce83a5d75b70d850]*/ { PyObject *it, *item, *bytearray_obj; Py_ssize_t buf_size = 0, len = 0; @@ -2861,43 +2493,9 @@ Remove and return a single item from B. If no index argument is given, will pop the last item. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_pop__doc__, -"pop($self, index=-1, /)\n" -"--\n" -"\n" -"Remove and return a single item from B.\n" -"\n" -" index\n" -" The index from where to remove the item.\n" -" -1 (the default value) means remove the last item.\n" -"\n" -"If no index argument is given, will pop the last item."); - -#define BYTEARRAY_POP_METHODDEF \ - {"pop", (PyCFunction)bytearray_pop, METH_VARARGS, bytearray_pop__doc__}, - -static PyObject * -bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index); - -static PyObject * -bytearray_pop(PyByteArrayObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - Py_ssize_t index = -1; - - if (!PyArg_ParseTuple(args, - "|n:pop", - &index)) - goto exit; - return_value = bytearray_pop_impl(self, index); - -exit: - return return_value; -} - static PyObject * bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index) -/*[clinic end generated code: output=3b763e548e79af96 input=0797e6c0ca9d5a85]*/ +/*[clinic end generated code: output=e0ccd401f8021da8 input=0797e6c0ca9d5a85]*/ { int value; Py_ssize_t n = Py_SIZE(self); @@ -2937,40 +2535,9 @@ bytearray.remove Remove the first occurrence of a value in the bytearray. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_remove__doc__, -"remove($self, value, /)\n" -"--\n" -"\n" -"Remove the first occurrence of a value in the bytearray.\n" -"\n" -" value\n" -" The value to remove."); - -#define BYTEARRAY_REMOVE_METHODDEF \ - {"remove", (PyCFunction)bytearray_remove, METH_VARARGS, bytearray_remove__doc__}, - -static PyObject * -bytearray_remove_impl(PyByteArrayObject *self, int value); - -static PyObject * -bytearray_remove(PyByteArrayObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int value; - - if (!PyArg_ParseTuple(args, - "O&:remove", - _getbytevalue, &value)) - goto exit; - return_value = bytearray_remove_impl(self, value); - -exit: - return return_value; -} - static PyObject * bytearray_remove_impl(PyByteArrayObject *self, int value) -/*[clinic end generated code: output=c71c8bcf4703abfc input=47560b11fd856c24]*/ +/*[clinic end generated code: output=d659e37866709c13 input=47560b11fd856c24]*/ { Py_ssize_t where, n = Py_SIZE(self); char *buf = PyByteArray_AS_STRING(self); @@ -3026,39 +2593,9 @@ Strip leading and trailing bytes contain If the argument is omitted or None, strip leading and trailing ASCII whitespace. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_strip__doc__, -"strip($self, bytes=None, /)\n" -"--\n" -"\n" -"Strip leading and trailing bytes contained in the argument.\n" -"\n" -"If the argument is omitted or None, strip leading and trailing ASCII whitespace."); - -#define BYTEARRAY_STRIP_METHODDEF \ - {"strip", (PyCFunction)bytearray_strip, METH_VARARGS, bytearray_strip__doc__}, - -static PyObject * -bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes); - -static PyObject * -bytearray_strip(PyByteArrayObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *bytes = Py_None; - - if (!PyArg_UnpackTuple(args, "strip", - 0, 1, - &bytes)) - goto exit; - return_value = bytearray_strip_impl(self, bytes); - -exit: - return return_value; -} - static PyObject * bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes) -/*[clinic end generated code: output=2e3d3358acc4c235 input=ef7bb59b09c21d62]*/ +/*[clinic end generated code: output=760412661a34ad5a input=ef7bb59b09c21d62]*/ { Py_ssize_t left, right, mysize, byteslen; char *myptr, *bytesptr; @@ -3097,39 +2634,9 @@ Strip leading bytes contained in the arg If the argument is omitted or None, strip leading ASCII whitespace. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_lstrip__doc__, -"lstrip($self, bytes=None, /)\n" -"--\n" -"\n" -"Strip leading bytes contained in the argument.\n" -"\n" -"If the argument is omitted or None, strip leading ASCII whitespace."); - -#define BYTEARRAY_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)bytearray_lstrip, METH_VARARGS, bytearray_lstrip__doc__}, - -static PyObject * -bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes); - -static PyObject * -bytearray_lstrip(PyByteArrayObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *bytes = Py_None; - - if (!PyArg_UnpackTuple(args, "lstrip", - 0, 1, - &bytes)) - goto exit; - return_value = bytearray_lstrip_impl(self, bytes); - -exit: - return return_value; -} - static PyObject * bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes) -/*[clinic end generated code: output=2599309808a9ec02 input=80843f975dd7c480]*/ +/*[clinic end generated code: output=d005c9d0ab909e66 input=80843f975dd7c480]*/ { Py_ssize_t left, right, mysize, byteslen; char *myptr, *bytesptr; @@ -3165,39 +2672,9 @@ Strip trailing bytes contained in the ar If the argument is omitted or None, strip trailing ASCII whitespace. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_rstrip__doc__, -"rstrip($self, bytes=None, /)\n" -"--\n" -"\n" -"Strip trailing bytes contained in the argument.\n" -"\n" -"If the argument is omitted or None, strip trailing ASCII whitespace."); - -#define BYTEARRAY_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)bytearray_rstrip, METH_VARARGS, bytearray_rstrip__doc__}, - -static PyObject * -bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes); - -static PyObject * -bytearray_rstrip(PyByteArrayObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *bytes = Py_None; - - if (!PyArg_UnpackTuple(args, "rstrip", - 0, 1, - &bytes)) - goto exit; - return_value = bytearray_rstrip_impl(self, bytes); - -exit: - return return_value; -} - static PyObject * bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes) -/*[clinic end generated code: output=b5ca6259f4f4f2a3 input=e728b994954cfd91]*/ +/*[clinic end generated code: output=030e2fbd2f7276bd input=e728b994954cfd91]*/ { Py_ssize_t right, mysize, byteslen; char *myptr, *bytesptr; @@ -3236,48 +2713,9 @@ bytearray.decode Decode the bytearray using the codec registered for encoding. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_decode__doc__, -"decode($self, /, encoding=\'utf-8\', errors=\'strict\')\n" -"--\n" -"\n" -"Decode the bytearray using the codec registered for encoding.\n" -"\n" -" encoding\n" -" The encoding with which to decode the bytearray.\n" -" errors\n" -" The error handling scheme to use for the handling of decoding errors.\n" -" The default is \'strict\' meaning that decoding errors raise a\n" -" UnicodeDecodeError. Other possible values are \'ignore\' and \'replace\'\n" -" as well as any other name registered with codecs.register_error that\n" -" can handle UnicodeDecodeErrors."); - -#define BYTEARRAY_DECODE_METHODDEF \ - {"decode", (PyCFunction)bytearray_decode, METH_VARARGS|METH_KEYWORDS, bytearray_decode__doc__}, - -static PyObject * -bytearray_decode_impl(PyByteArrayObject *self, const char *encoding, const char *errors); - -static PyObject * -bytearray_decode(PyByteArrayObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"encoding", "errors", NULL}; - const char *encoding = NULL; - const char *errors = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|ss:decode", _keywords, - &encoding, &errors)) - goto exit; - return_value = bytearray_decode_impl(self, encoding, errors); - -exit: - return return_value; -} - static PyObject * bytearray_decode_impl(PyByteArrayObject *self, const char *encoding, const char *errors) -/*[clinic end generated code: output=38b83681f1e38a6c input=f28d8f903020257b]*/ +/*[clinic end generated code: output=7e64e2cc91573b26 input=f28d8f903020257b]*/ { if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding(); @@ -3308,22 +2746,9 @@ The bytearray whose method is called is The result is returned as a new bytearray object. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_join__doc__, -"join($self, iterable_of_bytes, /)\n" -"--\n" -"\n" -"Concatenate any number of bytes/bytearray objects.\n" -"\n" -"The bytearray whose method is called is inserted in between each pair.\n" -"\n" -"The result is returned as a new bytearray object."); - -#define BYTEARRAY_JOIN_METHODDEF \ - {"join", (PyCFunction)bytearray_join, METH_O, bytearray_join__doc__}, - static PyObject * bytearray_join(PyByteArrayObject *self, PyObject *iterable_of_bytes) -/*[clinic end generated code: output=544e7430032dfdf4 input=aba6b1f9b30fcb8e]*/ +/*[clinic end generated code: output=a8516370bf68ae08 input=aba6b1f9b30fcb8e]*/ { return stringlib_bytes_join((PyObject*)self, iterable_of_bytes); } @@ -3339,41 +2764,9 @@ Line breaks are not included in the resu true. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_splitlines__doc__, -"splitlines($self, /, keepends=False)\n" -"--\n" -"\n" -"Return a list of the lines in the bytearray, breaking at line boundaries.\n" -"\n" -"Line breaks are not included in the resulting list unless keepends is given and\n" -"true."); - -#define BYTEARRAY_SPLITLINES_METHODDEF \ - {"splitlines", (PyCFunction)bytearray_splitlines, METH_VARARGS|METH_KEYWORDS, bytearray_splitlines__doc__}, - -static PyObject * -bytearray_splitlines_impl(PyByteArrayObject *self, int keepends); - -static PyObject * -bytearray_splitlines(PyByteArrayObject *self, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"keepends", NULL}; - int keepends = 0; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|i:splitlines", _keywords, - &keepends)) - goto exit; - return_value = bytearray_splitlines_impl(self, keepends); - -exit: - return return_value; -} - static PyObject * bytearray_splitlines_impl(PyByteArrayObject *self, int keepends) -/*[clinic end generated code: output=a837fd0512ad46ff input=36f0b25bc792f6c0]*/ +/*[clinic end generated code: output=4223c94b895f6ad9 input=36f0b25bc792f6c0]*/ { return stringlib_splitlines( (PyObject*) self, PyByteArray_AS_STRING(self), @@ -3411,40 +2804,9 @@ Spaces between two numbers are accepted. Example: bytearray.fromhex('B9 01EF') -> bytearray(b'\\xb9\\x01\\xef') [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_fromhex__doc__, -"fromhex($type, string, /)\n" -"--\n" -"\n" -"Create a bytearray object from a string of hexadecimal numbers.\n" -"\n" -"Spaces between two numbers are accepted.\n" -"Example: bytearray.fromhex(\'B9 01EF\') -> bytearray(b\'\\\\xb9\\\\x01\\\\xef\')"); - -#define BYTEARRAY_FROMHEX_METHODDEF \ - {"fromhex", (PyCFunction)bytearray_fromhex, METH_VARARGS|METH_CLASS, bytearray_fromhex__doc__}, - -static PyObject * -bytearray_fromhex_impl(PyObject*cls, PyObject *string); - -static PyObject * -bytearray_fromhex(PyTypeObject *cls, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *string; - - if (!PyArg_ParseTuple(args, - "U:fromhex", - &string)) - goto exit; - return_value = bytearray_fromhex_impl((PyObject*)cls, string); - -exit: - return return_value; -} - static PyObject * bytearray_fromhex_impl(PyObject*cls, PyObject *string) -/*[clinic end generated code: output=adc3c804a74e56d4 input=907bbd2d34d9367a]*/ +/*[clinic end generated code: output=df3da60129b3700c input=907bbd2d34d9367a]*/ { PyObject *newbytes; char *buf; @@ -3534,27 +2896,9 @@ bytearray.__reduce__ as bytearray_reduce Return state information for pickling. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_reduce__doc__, -"__reduce__($self, /)\n" -"--\n" -"\n" -"Return state information for pickling."); - -#define BYTEARRAY_REDUCE_METHODDEF \ - {"__reduce__", (PyCFunction)bytearray_reduce, METH_NOARGS, bytearray_reduce__doc__}, - -static PyObject * -bytearray_reduce_impl(PyByteArrayObject *self); - -static PyObject * -bytearray_reduce(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) -{ - return bytearray_reduce_impl(self); -} - static PyObject * bytearray_reduce_impl(PyByteArrayObject *self) -/*[clinic end generated code: output=b1b56fe87bf30fb0 input=fbb07de4d102a03a]*/ +/*[clinic end generated code: output=52bf304086464cab input=fbb07de4d102a03a]*/ { return _common_reduce(self, 2); } @@ -3569,37 +2913,9 @@ bytearray.__reduce_ex__ as bytearray_red Return state information for pickling. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_reduce_ex__doc__, -"__reduce_ex__($self, proto=0, /)\n" -"--\n" -"\n" -"Return state information for pickling."); - -#define BYTEARRAY_REDUCE_EX_METHODDEF \ - {"__reduce_ex__", (PyCFunction)bytearray_reduce_ex, METH_VARARGS, bytearray_reduce_ex__doc__}, - -static PyObject * -bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto); - -static PyObject * -bytearray_reduce_ex(PyByteArrayObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - int proto = 0; - - if (!PyArg_ParseTuple(args, - "|i:__reduce_ex__", - &proto)) - goto exit; - return_value = bytearray_reduce_ex_impl(self, proto); - -exit: - return return_value; -} - static PyObject * bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto) -/*[clinic end generated code: output=bbd9afb2f5953dc1 input=0e091a42ca6dbd91]*/ +/*[clinic end generated code: output=52eac33377197520 input=0e091a42ca6dbd91]*/ { return _common_reduce(self, proto); } @@ -3612,27 +2928,9 @@ bytearray.__sizeof__ as bytearray_sizeof Returns the size of the bytearray object in memory, in bytes. [clinic start generated code]*/ -PyDoc_STRVAR(bytearray_sizeof__doc__, -"__sizeof__($self, /)\n" -"--\n" -"\n" -"Returns the size of the bytearray object in memory, in bytes."); - -#define BYTEARRAY_SIZEOF_METHODDEF \ - {"__sizeof__", (PyCFunction)bytearray_sizeof, METH_NOARGS, bytearray_sizeof__doc__}, - -static PyObject * -bytearray_sizeof_impl(PyByteArrayObject *self); - -static PyObject * -bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) -{ - return bytearray_sizeof_impl(self); -} - static PyObject * bytearray_sizeof_impl(PyByteArrayObject *self) -/*[clinic end generated code: output=4a2254b0a85630c6 input=6b23d305362b462b]*/ +/*[clinic end generated code: output=738abdd17951c427 input=6b23d305362b462b]*/ { Py_ssize_t res; diff -r a824c40e8fc0 Objects/bytesobject.c --- a/Objects/bytesobject.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Objects/bytesobject.c Sun Feb 22 11:52:48 2015 +0200 @@ -12,6 +12,8 @@ class bytes "PyBytesObject*" "&PyBytes_T [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=1a1d9102afc1b00c]*/ +#include "clinic/bytesobject.c.h" + #ifdef COUNT_ALLOCS Py_ssize_t null_strings, one_strings; #endif @@ -1569,47 +1571,9 @@ bytes.split Return a list of the sections in the bytes, using sep as the delimiter. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_split__doc__, -"split($self, /, sep=None, maxsplit=-1)\n" -"--\n" -"\n" -"Return a list of the sections in the bytes, using sep as the delimiter.\n" -"\n" -" sep\n" -" The delimiter according which to split the bytes.\n" -" None (the default value) means split on ASCII whitespace characters\n" -" (space, tab, return, newline, formfeed, vertical tab).\n" -" maxsplit\n" -" Maximum number of splits to do.\n" -" -1 (the default value) means no limit."); - -#define BYTES_SPLIT_METHODDEF \ - {"split", (PyCFunction)bytes_split, METH_VARARGS|METH_KEYWORDS, bytes_split__doc__}, - -static PyObject * -bytes_split_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit); - -static PyObject * -bytes_split(PyBytesObject*self, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"sep", "maxsplit", NULL}; - PyObject *sep = Py_None; - Py_ssize_t maxsplit = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|On:split", _keywords, - &sep, &maxsplit)) - goto exit; - return_value = bytes_split_impl(self, sep, maxsplit); - -exit: - return return_value; -} - static PyObject * bytes_split_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit) -/*[clinic end generated code: output=c80a47afdd505975 input=8b809b39074abbfa]*/ +/*[clinic end generated code: output=8bde44dacb36ef2e input=8b809b39074abbfa]*/ { Py_ssize_t len = PyBytes_GET_SIZE(self), n; const char *s = PyBytes_AS_STRING(self), *sub; @@ -1647,48 +1611,9 @@ If the separator is not found, returns a object and two empty bytes objects. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_partition__doc__, -"partition($self, sep, /)\n" -"--\n" -"\n" -"Partition the bytes into three parts using the given separator.\n" -"\n" -"This will search for the separator sep in the bytes. If the separator is found,\n" -"returns a 3-tuple containing the part before the separator, the separator\n" -"itself, and the part after it.\n" -"\n" -"If the separator is not found, returns a 3-tuple containing the original bytes\n" -"object and two empty bytes objects."); - -#define BYTES_PARTITION_METHODDEF \ - {"partition", (PyCFunction)bytes_partition, METH_VARARGS, bytes_partition__doc__}, - -static PyObject * -bytes_partition_impl(PyBytesObject *self, Py_buffer *sep); - -static PyObject * -bytes_partition(PyBytesObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - Py_buffer sep = {NULL, NULL}; - - if (!PyArg_ParseTuple(args, - "y*:partition", - &sep)) - goto exit; - return_value = bytes_partition_impl(self, &sep); - -exit: - /* Cleanup for sep */ - if (sep.obj) - PyBuffer_Release(&sep); - - return return_value; -} - static PyObject * bytes_partition_impl(PyBytesObject *self, Py_buffer *sep) -/*[clinic end generated code: output=3006727cfbf83aa4 input=bc855dc63ca949de]*/ +/*[clinic end generated code: output=f532b392a17ff695 input=bc855dc63ca949de]*/ { return stringlib_partition( (PyObject*) self, @@ -1714,48 +1639,9 @@ If the separator is not found, returns a objects and the original bytes object. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_rpartition__doc__, -"rpartition($self, sep, /)\n" -"--\n" -"\n" -"Partition the bytes into three parts using the given separator.\n" -"\n" -"This will search for the separator sep in the bytes, starting and the end. If\n" -"the separator is found, returns a 3-tuple containing the part before the\n" -"separator, the separator itself, and the part after it.\n" -"\n" -"If the separator is not found, returns a 3-tuple containing two empty bytes\n" -"objects and the original bytes object."); - -#define BYTES_RPARTITION_METHODDEF \ - {"rpartition", (PyCFunction)bytes_rpartition, METH_VARARGS, bytes_rpartition__doc__}, - -static PyObject * -bytes_rpartition_impl(PyBytesObject *self, Py_buffer *sep); - -static PyObject * -bytes_rpartition(PyBytesObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - Py_buffer sep = {NULL, NULL}; - - if (!PyArg_ParseTuple(args, - "y*:rpartition", - &sep)) - goto exit; - return_value = bytes_rpartition_impl(self, &sep); - -exit: - /* Cleanup for sep */ - if (sep.obj) - PyBuffer_Release(&sep); - - return return_value; -} - static PyObject * bytes_rpartition_impl(PyBytesObject *self, Py_buffer *sep) -/*[clinic end generated code: output=57b169dc47fa90e8 input=6588fff262a9170e]*/ +/*[clinic end generated code: output=191b114cbb028e50 input=6588fff262a9170e]*/ { return stringlib_rpartition( (PyObject*) self, @@ -1772,49 +1658,9 @@ Return a list of the sections in the byt Splitting is done starting at the end of the bytes and working to the front. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_rsplit__doc__, -"rsplit($self, /, sep=None, maxsplit=-1)\n" -"--\n" -"\n" -"Return a list of the sections in the bytes, using sep as the delimiter.\n" -"\n" -" sep\n" -" The delimiter according which to split the bytes.\n" -" None (the default value) means split on ASCII whitespace characters\n" -" (space, tab, return, newline, formfeed, vertical tab).\n" -" maxsplit\n" -" Maximum number of splits to do.\n" -" -1 (the default value) means no limit.\n" -"\n" -"Splitting is done starting at the end of the bytes and working to the front."); - -#define BYTES_RSPLIT_METHODDEF \ - {"rsplit", (PyCFunction)bytes_rsplit, METH_VARARGS|METH_KEYWORDS, bytes_rsplit__doc__}, - -static PyObject * -bytes_rsplit_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit); - -static PyObject * -bytes_rsplit(PyBytesObject*self, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"sep", "maxsplit", NULL}; - PyObject *sep = Py_None; - Py_ssize_t maxsplit = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|On:rsplit", _keywords, - &sep, &maxsplit)) - goto exit; - return_value = bytes_rsplit_impl(self, sep, maxsplit); - -exit: - return return_value; -} - static PyObject * bytes_rsplit_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit) -/*[clinic end generated code: output=f86feddedbd7b26d input=0f86c9f28f7d7b7b]*/ +/*[clinic end generated code: output=0b6570b977911d88 input=0f86c9f28f7d7b7b]*/ { Py_ssize_t len = PyBytes_GET_SIZE(self), n; const char *s = PyBytes_AS_STRING(self), *sub; @@ -1851,24 +1697,9 @@ The result is returned as a new bytes ob Example: b'.'.join([b'ab', b'pq', b'rs']) -> b'ab.pq.rs'. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_join__doc__, -"join($self, iterable_of_bytes, /)\n" -"--\n" -"\n" -"Concatenate any number of bytes objects.\n" -"\n" -"The bytes whose method is called is inserted in between each pair.\n" -"\n" -"The result is returned as a new bytes object.\n" -"\n" -"Example: b\'.\'.join([b\'ab\', b\'pq\', b\'rs\']) -> b\'ab.pq.rs\'."); - -#define BYTES_JOIN_METHODDEF \ - {"join", (PyCFunction)bytes_join, METH_O, bytes_join__doc__}, - static PyObject * bytes_join(PyBytesObject*self, PyObject *iterable_of_bytes) -/*[clinic end generated code: output=e541a14a8da97908 input=7fe377b95bd549d2]*/ +/*[clinic end generated code: output=634aff14764ff997 input=7fe377b95bd549d2]*/ { return stringlib_bytes_join((PyObject*)self, iterable_of_bytes); } @@ -2109,39 +1940,9 @@ Strip leading and trailing bytes contain If the argument is omitted or None, strip leading and trailing ASCII whitespace. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_strip__doc__, -"strip($self, bytes=None, /)\n" -"--\n" -"\n" -"Strip leading and trailing bytes contained in the argument.\n" -"\n" -"If the argument is omitted or None, strip leading and trailing ASCII whitespace."); - -#define BYTES_STRIP_METHODDEF \ - {"strip", (PyCFunction)bytes_strip, METH_VARARGS, bytes_strip__doc__}, - -static PyObject * -bytes_strip_impl(PyBytesObject *self, PyObject *bytes); - -static PyObject * -bytes_strip(PyBytesObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *bytes = Py_None; - - if (!PyArg_UnpackTuple(args, "strip", - 0, 1, - &bytes)) - goto exit; - return_value = bytes_strip_impl(self, bytes); - -exit: - return return_value; -} - static PyObject * bytes_strip_impl(PyBytesObject *self, PyObject *bytes) -/*[clinic end generated code: output=c8234a599ba5ec35 input=37daa5fad1395d95]*/ +/*[clinic end generated code: output=c7c228d3bd104a1b input=37daa5fad1395d95]*/ { return do_argstrip(self, BOTHSTRIP, bytes); } @@ -2158,39 +1959,9 @@ Strip leading bytes contained in the arg If the argument is omitted or None, strip leading ASCII whitespace. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_lstrip__doc__, -"lstrip($self, bytes=None, /)\n" -"--\n" -"\n" -"Strip leading bytes contained in the argument.\n" -"\n" -"If the argument is omitted or None, strip leading ASCII whitespace."); - -#define BYTES_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)bytes_lstrip, METH_VARARGS, bytes_lstrip__doc__}, - -static PyObject * -bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes); - -static PyObject * -bytes_lstrip(PyBytesObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *bytes = Py_None; - - if (!PyArg_UnpackTuple(args, "lstrip", - 0, 1, - &bytes)) - goto exit; - return_value = bytes_lstrip_impl(self, bytes); - -exit: - return return_value; -} - static PyObject * bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes) -/*[clinic end generated code: output=529e8511ab6f1115 input=88811b09dfbc2988]*/ +/*[clinic end generated code: output=28602e586f524e82 input=88811b09dfbc2988]*/ { return do_argstrip(self, LEFTSTRIP, bytes); } @@ -2207,39 +1978,9 @@ Strip trailing bytes contained in the ar If the argument is omitted or None, strip trailing ASCII whitespace. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_rstrip__doc__, -"rstrip($self, bytes=None, /)\n" -"--\n" -"\n" -"Strip trailing bytes contained in the argument.\n" -"\n" -"If the argument is omitted or None, strip trailing ASCII whitespace."); - -#define BYTES_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)bytes_rstrip, METH_VARARGS, bytes_rstrip__doc__}, - -static PyObject * -bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes); - -static PyObject * -bytes_rstrip(PyBytesObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *bytes = Py_None; - - if (!PyArg_UnpackTuple(args, "rstrip", - 0, 1, - &bytes)) - goto exit; - return_value = bytes_rstrip_impl(self, bytes); - -exit: - return return_value; -} - static PyObject * bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes) -/*[clinic end generated code: output=e98730bd133e6593 input=8f93c9cd361f0140]*/ +/*[clinic end generated code: output=547e3815c95447da input=8f93c9cd361f0140]*/ { return do_argstrip(self, RIGHTSTRIP, bytes); } @@ -2310,53 +2051,9 @@ All characters occurring in the optional The remaining characters are mapped through the given translation table. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_translate__doc__, -"translate(table, [deletechars])\n" -"Return a copy with each character mapped by the given translation table.\n" -"\n" -" table\n" -" Translation table, which must be a bytes object of length 256.\n" -"\n" -"All characters occurring in the optional argument deletechars are removed.\n" -"The remaining characters are mapped through the given translation table."); - -#define BYTES_TRANSLATE_METHODDEF \ - {"translate", (PyCFunction)bytes_translate, METH_VARARGS, bytes_translate__doc__}, - -static PyObject * -bytes_translate_impl(PyBytesObject *self, PyObject *table, int group_right_1, PyObject *deletechars); - -static PyObject * -bytes_translate(PyBytesObject *self, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *table; - int group_right_1 = 0; - PyObject *deletechars = NULL; - - switch (PyTuple_GET_SIZE(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O:translate", &table)) - goto exit; - break; - case 2: - if (!PyArg_ParseTuple(args, "OO:translate", &table, &deletechars)) - goto exit; - group_right_1 = 1; - break; - default: - PyErr_SetString(PyExc_TypeError, "bytes.translate requires 1 to 2 arguments"); - goto exit; - } - return_value = bytes_translate_impl(self, table, group_right_1, deletechars); - -exit: - return return_value; -} - static PyObject * bytes_translate_impl(PyBytesObject *self, PyObject *table, int group_right_1, PyObject *deletechars) -/*[clinic end generated code: output=f0f29a57f41df5d8 input=d8fa5519d7cc4be7]*/ +/*[clinic end generated code: output=0ddd2cef4f4918f2 input=d8fa5519d7cc4be7]*/ { char *input, *output; Py_buffer table_view = {NULL, NULL}; @@ -2486,50 +2183,9 @@ the same position in to. The bytes objects frm and to must be of the same length. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_maketrans__doc__, -"maketrans(frm, to, /)\n" -"--\n" -"\n" -"Return a translation table useable for the bytes or bytearray translate method.\n" -"\n" -"The returned table will be one where each byte in frm is mapped to the byte at\n" -"the same position in to.\n" -"\n" -"The bytes objects frm and to must be of the same length."); - -#define BYTES_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)bytes_maketrans, METH_VARARGS|METH_STATIC, bytes_maketrans__doc__}, - -static PyObject * -bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to); - -static PyObject * -bytes_maketrans(void *null, PyObject *args) -{ - PyObject *return_value = NULL; - Py_buffer frm = {NULL, NULL}; - Py_buffer to = {NULL, NULL}; - - if (!PyArg_ParseTuple(args, - "y*y*:maketrans", - &frm, &to)) - goto exit; - return_value = bytes_maketrans_impl(&frm, &to); - -exit: - /* Cleanup for frm */ - if (frm.obj) - PyBuffer_Release(&frm); - /* Cleanup for to */ - if (to.obj) - PyBuffer_Release(&to); - - return return_value; -} - static PyObject * bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to) -/*[clinic end generated code: output=7df47390c476ac60 input=de7a8fc5632bb8f1]*/ +/*[clinic end generated code: output=a36f6399d4b77f6f input=de7a8fc5632bb8f1]*/ { return _Py_bytes_maketrans(frm, to); } @@ -3043,53 +2699,9 @@ If the optional argument count is given, replaced. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_replace__doc__, -"replace($self, old, new, count=-1, /)\n" -"--\n" -"\n" -"Return a copy with all occurrences of substring old replaced by new.\n" -"\n" -" count\n" -" Maximum number of occurrences to replace.\n" -" -1 (the default value) means replace all occurrences.\n" -"\n" -"If the optional argument count is given, only the first count occurrences are\n" -"replaced."); - -#define BYTES_REPLACE_METHODDEF \ - {"replace", (PyCFunction)bytes_replace, METH_VARARGS, bytes_replace__doc__}, - -static PyObject * -bytes_replace_impl(PyBytesObject*self, Py_buffer *old, Py_buffer *new, Py_ssize_t count); - -static PyObject * -bytes_replace(PyBytesObject*self, PyObject *args) -{ - PyObject *return_value = NULL; - Py_buffer old = {NULL, NULL}; - Py_buffer new = {NULL, NULL}; - Py_ssize_t count = -1; - - if (!PyArg_ParseTuple(args, - "y*y*|n:replace", - &old, &new, &count)) - goto exit; - return_value = bytes_replace_impl(self, &old, &new, count); - -exit: - /* Cleanup for old */ - if (old.obj) - PyBuffer_Release(&old); - /* Cleanup for new */ - if (new.obj) - PyBuffer_Release(&new); - - return return_value; -} - static PyObject * bytes_replace_impl(PyBytesObject*self, Py_buffer *old, Py_buffer *new, Py_ssize_t count) -/*[clinic end generated code: output=f07bd9ecf29ee8d8 input=b2fbbf0bf04de8e5]*/ +/*[clinic end generated code: output=3fe052c3c60cffc2 input=b2fbbf0bf04de8e5]*/ { return (PyObject *)replace((PyBytesObject *) self, (const char *)old->buf, old->len, @@ -3255,48 +2867,9 @@ bytes.decode Decode the bytes using the codec registered for encoding. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_decode__doc__, -"decode($self, /, encoding=\'utf-8\', errors=\'strict\')\n" -"--\n" -"\n" -"Decode the bytes using the codec registered for encoding.\n" -"\n" -" encoding\n" -" The encoding with which to decode the bytes.\n" -" errors\n" -" The error handling scheme to use for the handling of decoding errors.\n" -" The default is \'strict\' meaning that decoding errors raise a\n" -" UnicodeDecodeError. Other possible values are \'ignore\' and \'replace\'\n" -" as well as any other name registered with codecs.register_error that\n" -" can handle UnicodeDecodeErrors."); - -#define BYTES_DECODE_METHODDEF \ - {"decode", (PyCFunction)bytes_decode, METH_VARARGS|METH_KEYWORDS, bytes_decode__doc__}, - -static PyObject * -bytes_decode_impl(PyBytesObject*self, const char *encoding, const char *errors); - -static PyObject * -bytes_decode(PyBytesObject*self, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"encoding", "errors", NULL}; - const char *encoding = NULL; - const char *errors = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|ss:decode", _keywords, - &encoding, &errors)) - goto exit; - return_value = bytes_decode_impl(self, encoding, errors); - -exit: - return return_value; -} - static PyObject * bytes_decode_impl(PyBytesObject*self, const char *encoding, const char *errors) -/*[clinic end generated code: output=61a80290bbfce696 input=958174769d2a40ca]*/ +/*[clinic end generated code: output=8038751c823b9038 input=958174769d2a40ca]*/ { return PyUnicode_FromEncodedObject((PyObject*)self, encoding, errors); } @@ -3313,41 +2886,9 @@ Line breaks are not included in the resu true. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_splitlines__doc__, -"splitlines($self, /, keepends=False)\n" -"--\n" -"\n" -"Return a list of the lines in the bytes, breaking at line boundaries.\n" -"\n" -"Line breaks are not included in the resulting list unless keepends is given and\n" -"true."); - -#define BYTES_SPLITLINES_METHODDEF \ - {"splitlines", (PyCFunction)bytes_splitlines, METH_VARARGS|METH_KEYWORDS, bytes_splitlines__doc__}, - -static PyObject * -bytes_splitlines_impl(PyBytesObject*self, int keepends); - -static PyObject * -bytes_splitlines(PyBytesObject*self, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"keepends", NULL}; - int keepends = 0; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|i:splitlines", _keywords, - &keepends)) - goto exit; - return_value = bytes_splitlines_impl(self, keepends); - -exit: - return return_value; -} - static PyObject * bytes_splitlines_impl(PyBytesObject*self, int keepends) -/*[clinic end generated code: output=79da057d05d126de input=ddb93e3351080c8c]*/ +/*[clinic end generated code: output=995c3598f7833cad input=ddb93e3351080c8c]*/ { return stringlib_splitlines( (PyObject*) self, PyBytes_AS_STRING(self), @@ -3384,40 +2925,9 @@ Spaces between two numbers are accepted. Example: bytes.fromhex('B9 01EF') -> b'\\xb9\\x01\\xef'. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_fromhex__doc__, -"fromhex($type, string, /)\n" -"--\n" -"\n" -"Create a bytes object from a string of hexadecimal numbers.\n" -"\n" -"Spaces between two numbers are accepted.\n" -"Example: bytes.fromhex(\'B9 01EF\') -> b\'\\\\xb9\\\\x01\\\\xef\'."); - -#define BYTES_FROMHEX_METHODDEF \ - {"fromhex", (PyCFunction)bytes_fromhex, METH_VARARGS|METH_CLASS, bytes_fromhex__doc__}, - -static PyObject * -bytes_fromhex_impl(PyTypeObject *type, PyObject *string); - -static PyObject * -bytes_fromhex(PyTypeObject *type, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *string; - - if (!PyArg_ParseTuple(args, - "U:fromhex", - &string)) - goto exit; - return_value = bytes_fromhex_impl(type, string); - -exit: - return return_value; -} - static PyObject * bytes_fromhex_impl(PyTypeObject *type, PyObject *string) -/*[clinic end generated code: output=09e6cbef56cbbb65 input=bf4d1c361670acd3]*/ +/*[clinic end generated code: output=0973acc63661bb2e input=bf4d1c361670acd3]*/ { PyObject *newstring; char *buf; @@ -3471,27 +2981,9 @@ bytes.__sizeof__ as bytes_sizeof Returns the size of the bytes object in memory, in bytes. [clinic start generated code]*/ -PyDoc_STRVAR(bytes_sizeof__doc__, -"__sizeof__($self, /)\n" -"--\n" -"\n" -"Returns the size of the bytes object in memory, in bytes."); - -#define BYTES_SIZEOF_METHODDEF \ - {"__sizeof__", (PyCFunction)bytes_sizeof, METH_NOARGS, bytes_sizeof__doc__}, - -static PyObject * -bytes_sizeof_impl(PyBytesObject *self); - -static PyObject * -bytes_sizeof(PyBytesObject *self, PyObject *Py_UNUSED(ignored)) -{ - return bytes_sizeof_impl(self); -} - static PyObject * bytes_sizeof_impl(PyBytesObject *self) -/*[clinic end generated code: output=44933279343f24ae input=bee4c64bb42078ed]*/ +/*[clinic end generated code: output=c4ca2f057382c77a input=bee4c64bb42078ed]*/ { Py_ssize_t res; res = PyBytesObject_SIZE + Py_SIZE(self) * Py_TYPE(self)->tp_itemsize; diff -r a824c40e8fc0 Objects/clinic/bytearrayobject.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Objects/clinic/bytearrayobject.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,708 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(bytearray_clear__doc__, +"clear($self, /)\n" +"--\n" +"\n" +"Remove all items from the bytearray."); + +#define BYTEARRAY_CLEAR_METHODDEF \ + {"clear", (PyCFunction)bytearray_clear, METH_NOARGS, bytearray_clear__doc__}, + +static PyObject * +bytearray_clear_impl(PyByteArrayObject *self); + +static PyObject * +bytearray_clear(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) +{ + return bytearray_clear_impl(self); +} + +PyDoc_STRVAR(bytearray_copy__doc__, +"copy($self, /)\n" +"--\n" +"\n" +"Return a copy of B."); + +#define BYTEARRAY_COPY_METHODDEF \ + {"copy", (PyCFunction)bytearray_copy, METH_NOARGS, bytearray_copy__doc__}, + +static PyObject * +bytearray_copy_impl(PyByteArrayObject *self); + +static PyObject * +bytearray_copy(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) +{ + return bytearray_copy_impl(self); +} + +PyDoc_STRVAR(bytearray_translate__doc__, +"translate(table, [deletechars])\n" +"Return a copy with each character mapped by the given translation table.\n" +"\n" +" table\n" +" Translation table, which must be a bytes object of length 256.\n" +"\n" +"All characters occurring in the optional argument deletechars are removed.\n" +"The remaining characters are mapped through the given translation table."); + +#define BYTEARRAY_TRANSLATE_METHODDEF \ + {"translate", (PyCFunction)bytearray_translate, METH_VARARGS, bytearray_translate__doc__}, + +static PyObject * +bytearray_translate_impl(PyByteArrayObject *self, PyObject *table, int group_right_1, PyObject *deletechars); + +static PyObject * +bytearray_translate(PyByteArrayObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *table; + int group_right_1 = 0; + PyObject *deletechars = NULL; + + switch (PyTuple_GET_SIZE(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O:translate", &table)) + goto exit; + break; + case 2: + if (!PyArg_ParseTuple(args, "OO:translate", &table, &deletechars)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "bytearray.translate requires 1 to 2 arguments"); + goto exit; + } + return_value = bytearray_translate_impl(self, table, group_right_1, deletechars); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_maketrans__doc__, +"maketrans(frm, to, /)\n" +"--\n" +"\n" +"Return a translation table useable for the bytes or bytearray translate method.\n" +"\n" +"The returned table will be one where each byte in frm is mapped to the byte at\n" +"the same position in to.\n" +"\n" +"The bytes objects frm and to must be of the same length."); + +#define BYTEARRAY_MAKETRANS_METHODDEF \ + {"maketrans", (PyCFunction)bytearray_maketrans, METH_VARARGS|METH_STATIC, bytearray_maketrans__doc__}, + +static PyObject * +bytearray_maketrans_impl(Py_buffer *frm, Py_buffer *to); + +static PyObject * +bytearray_maketrans(void *null, PyObject *args) +{ + PyObject *return_value = NULL; + Py_buffer frm = {NULL, NULL}; + Py_buffer to = {NULL, NULL}; + + if (!PyArg_ParseTuple(args, + "y*y*:maketrans", + &frm, &to)) + goto exit; + return_value = bytearray_maketrans_impl(&frm, &to); + +exit: + /* Cleanup for frm */ + if (frm.obj) + PyBuffer_Release(&frm); + /* Cleanup for to */ + if (to.obj) + PyBuffer_Release(&to); + + return return_value; +} + +PyDoc_STRVAR(bytearray_replace__doc__, +"replace($self, old, new, count=-1, /)\n" +"--\n" +"\n" +"Return a copy with all occurrences of substring old replaced by new.\n" +"\n" +" count\n" +" Maximum number of occurrences to replace.\n" +" -1 (the default value) means replace all occurrences.\n" +"\n" +"If the optional argument count is given, only the first count occurrences are\n" +"replaced."); + +#define BYTEARRAY_REPLACE_METHODDEF \ + {"replace", (PyCFunction)bytearray_replace, METH_VARARGS, bytearray_replace__doc__}, + +static PyObject * +bytearray_replace_impl(PyByteArrayObject *self, Py_buffer *old, Py_buffer *new, Py_ssize_t count); + +static PyObject * +bytearray_replace(PyByteArrayObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + Py_buffer old = {NULL, NULL}; + Py_buffer new = {NULL, NULL}; + Py_ssize_t count = -1; + + if (!PyArg_ParseTuple(args, + "y*y*|n:replace", + &old, &new, &count)) + goto exit; + return_value = bytearray_replace_impl(self, &old, &new, count); + +exit: + /* Cleanup for old */ + if (old.obj) + PyBuffer_Release(&old); + /* Cleanup for new */ + if (new.obj) + PyBuffer_Release(&new); + + return return_value; +} + +PyDoc_STRVAR(bytearray_split__doc__, +"split($self, /, sep=None, maxsplit=-1)\n" +"--\n" +"\n" +"Return a list of the sections in the bytearray, using sep as the delimiter.\n" +"\n" +" sep\n" +" The delimiter according which to split the bytearray.\n" +" None (the default value) means split on ASCII whitespace characters\n" +" (space, tab, return, newline, formfeed, vertical tab).\n" +" maxsplit\n" +" Maximum number of splits to do.\n" +" -1 (the default value) means no limit."); + +#define BYTEARRAY_SPLIT_METHODDEF \ + {"split", (PyCFunction)bytearray_split, METH_VARARGS|METH_KEYWORDS, bytearray_split__doc__}, + +static PyObject * +bytearray_split_impl(PyByteArrayObject *self, PyObject *sep, Py_ssize_t maxsplit); + +static PyObject * +bytearray_split(PyByteArrayObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"sep", "maxsplit", NULL}; + PyObject *sep = Py_None; + Py_ssize_t maxsplit = -1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|On:split", _keywords, + &sep, &maxsplit)) + goto exit; + return_value = bytearray_split_impl(self, sep, maxsplit); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_partition__doc__, +"partition($self, sep, /)\n" +"--\n" +"\n" +"Partition the bytearray into three parts using the given separator.\n" +"\n" +"This will search for the separator sep in the bytearray. If the separator is\n" +"found, returns a 3-tuple containing the part before the separator, the\n" +"separator itself, and the part after it.\n" +"\n" +"If the separator is not found, returns a 3-tuple containing the original\n" +"bytearray object and two empty bytearray objects."); + +#define BYTEARRAY_PARTITION_METHODDEF \ + {"partition", (PyCFunction)bytearray_partition, METH_O, bytearray_partition__doc__}, + +PyDoc_STRVAR(bytearray_rpartition__doc__, +"rpartition($self, sep, /)\n" +"--\n" +"\n" +"Partition the bytes into three parts using the given separator.\n" +"\n" +"This will search for the separator sep in the bytearray, starting and the end.\n" +"If the separator is found, returns a 3-tuple containing the part before the\n" +"separator, the separator itself, and the part after it.\n" +"\n" +"If the separator is not found, returns a 3-tuple containing two empty bytearray\n" +"objects and the original bytearray object."); + +#define BYTEARRAY_RPARTITION_METHODDEF \ + {"rpartition", (PyCFunction)bytearray_rpartition, METH_O, bytearray_rpartition__doc__}, + +PyDoc_STRVAR(bytearray_rsplit__doc__, +"rsplit($self, /, sep=None, maxsplit=-1)\n" +"--\n" +"\n" +"Return a list of the sections in the bytearray, using sep as the delimiter.\n" +"\n" +" sep\n" +" The delimiter according which to split the bytearray.\n" +" None (the default value) means split on ASCII whitespace characters\n" +" (space, tab, return, newline, formfeed, vertical tab).\n" +" maxsplit\n" +" Maximum number of splits to do.\n" +" -1 (the default value) means no limit.\n" +"\n" +"Splitting is done starting at the end of the bytearray and working to the front."); + +#define BYTEARRAY_RSPLIT_METHODDEF \ + {"rsplit", (PyCFunction)bytearray_rsplit, METH_VARARGS|METH_KEYWORDS, bytearray_rsplit__doc__}, + +static PyObject * +bytearray_rsplit_impl(PyByteArrayObject *self, PyObject *sep, Py_ssize_t maxsplit); + +static PyObject * +bytearray_rsplit(PyByteArrayObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"sep", "maxsplit", NULL}; + PyObject *sep = Py_None; + Py_ssize_t maxsplit = -1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|On:rsplit", _keywords, + &sep, &maxsplit)) + goto exit; + return_value = bytearray_rsplit_impl(self, sep, maxsplit); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_reverse__doc__, +"reverse($self, /)\n" +"--\n" +"\n" +"Reverse the order of the values in B in place."); + +#define BYTEARRAY_REVERSE_METHODDEF \ + {"reverse", (PyCFunction)bytearray_reverse, METH_NOARGS, bytearray_reverse__doc__}, + +static PyObject * +bytearray_reverse_impl(PyByteArrayObject *self); + +static PyObject * +bytearray_reverse(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) +{ + return bytearray_reverse_impl(self); +} + +PyDoc_STRVAR(bytearray_insert__doc__, +"insert($self, index, item, /)\n" +"--\n" +"\n" +"Insert a single item into the bytearray before the given index.\n" +"\n" +" index\n" +" The index where the value is to be inserted.\n" +" item\n" +" The item to be inserted."); + +#define BYTEARRAY_INSERT_METHODDEF \ + {"insert", (PyCFunction)bytearray_insert, METH_VARARGS, bytearray_insert__doc__}, + +static PyObject * +bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item); + +static PyObject * +bytearray_insert(PyByteArrayObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + Py_ssize_t index; + int item; + + if (!PyArg_ParseTuple(args, + "nO&:insert", + &index, _getbytevalue, &item)) + goto exit; + return_value = bytearray_insert_impl(self, index, item); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_append__doc__, +"append($self, item, /)\n" +"--\n" +"\n" +"Append a single item to the end of the bytearray.\n" +"\n" +" item\n" +" The item to be appended."); + +#define BYTEARRAY_APPEND_METHODDEF \ + {"append", (PyCFunction)bytearray_append, METH_VARARGS, bytearray_append__doc__}, + +static PyObject * +bytearray_append_impl(PyByteArrayObject *self, int item); + +static PyObject * +bytearray_append(PyByteArrayObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int item; + + if (!PyArg_ParseTuple(args, + "O&:append", + _getbytevalue, &item)) + goto exit; + return_value = bytearray_append_impl(self, item); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_extend__doc__, +"extend($self, iterable_of_ints, /)\n" +"--\n" +"\n" +"Append all the items from the iterator or sequence to the end of the bytearray.\n" +"\n" +" iterable_of_ints\n" +" The iterable of items to append."); + +#define BYTEARRAY_EXTEND_METHODDEF \ + {"extend", (PyCFunction)bytearray_extend, METH_O, bytearray_extend__doc__}, + +PyDoc_STRVAR(bytearray_pop__doc__, +"pop($self, index=-1, /)\n" +"--\n" +"\n" +"Remove and return a single item from B.\n" +"\n" +" index\n" +" The index from where to remove the item.\n" +" -1 (the default value) means remove the last item.\n" +"\n" +"If no index argument is given, will pop the last item."); + +#define BYTEARRAY_POP_METHODDEF \ + {"pop", (PyCFunction)bytearray_pop, METH_VARARGS, bytearray_pop__doc__}, + +static PyObject * +bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index); + +static PyObject * +bytearray_pop(PyByteArrayObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + Py_ssize_t index = -1; + + if (!PyArg_ParseTuple(args, + "|n:pop", + &index)) + goto exit; + return_value = bytearray_pop_impl(self, index); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_remove__doc__, +"remove($self, value, /)\n" +"--\n" +"\n" +"Remove the first occurrence of a value in the bytearray.\n" +"\n" +" value\n" +" The value to remove."); + +#define BYTEARRAY_REMOVE_METHODDEF \ + {"remove", (PyCFunction)bytearray_remove, METH_VARARGS, bytearray_remove__doc__}, + +static PyObject * +bytearray_remove_impl(PyByteArrayObject *self, int value); + +static PyObject * +bytearray_remove(PyByteArrayObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int value; + + if (!PyArg_ParseTuple(args, + "O&:remove", + _getbytevalue, &value)) + goto exit; + return_value = bytearray_remove_impl(self, value); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_strip__doc__, +"strip($self, bytes=None, /)\n" +"--\n" +"\n" +"Strip leading and trailing bytes contained in the argument.\n" +"\n" +"If the argument is omitted or None, strip leading and trailing ASCII whitespace."); + +#define BYTEARRAY_STRIP_METHODDEF \ + {"strip", (PyCFunction)bytearray_strip, METH_VARARGS, bytearray_strip__doc__}, + +static PyObject * +bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes); + +static PyObject * +bytearray_strip(PyByteArrayObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *bytes = Py_None; + + if (!PyArg_UnpackTuple(args, "strip", + 0, 1, + &bytes)) + goto exit; + return_value = bytearray_strip_impl(self, bytes); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_lstrip__doc__, +"lstrip($self, bytes=None, /)\n" +"--\n" +"\n" +"Strip leading bytes contained in the argument.\n" +"\n" +"If the argument is omitted or None, strip leading ASCII whitespace."); + +#define BYTEARRAY_LSTRIP_METHODDEF \ + {"lstrip", (PyCFunction)bytearray_lstrip, METH_VARARGS, bytearray_lstrip__doc__}, + +static PyObject * +bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes); + +static PyObject * +bytearray_lstrip(PyByteArrayObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *bytes = Py_None; + + if (!PyArg_UnpackTuple(args, "lstrip", + 0, 1, + &bytes)) + goto exit; + return_value = bytearray_lstrip_impl(self, bytes); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_rstrip__doc__, +"rstrip($self, bytes=None, /)\n" +"--\n" +"\n" +"Strip trailing bytes contained in the argument.\n" +"\n" +"If the argument is omitted or None, strip trailing ASCII whitespace."); + +#define BYTEARRAY_RSTRIP_METHODDEF \ + {"rstrip", (PyCFunction)bytearray_rstrip, METH_VARARGS, bytearray_rstrip__doc__}, + +static PyObject * +bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes); + +static PyObject * +bytearray_rstrip(PyByteArrayObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *bytes = Py_None; + + if (!PyArg_UnpackTuple(args, "rstrip", + 0, 1, + &bytes)) + goto exit; + return_value = bytearray_rstrip_impl(self, bytes); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_decode__doc__, +"decode($self, /, encoding=\'utf-8\', errors=\'strict\')\n" +"--\n" +"\n" +"Decode the bytearray using the codec registered for encoding.\n" +"\n" +" encoding\n" +" The encoding with which to decode the bytearray.\n" +" errors\n" +" The error handling scheme to use for the handling of decoding errors.\n" +" The default is \'strict\' meaning that decoding errors raise a\n" +" UnicodeDecodeError. Other possible values are \'ignore\' and \'replace\'\n" +" as well as any other name registered with codecs.register_error that\n" +" can handle UnicodeDecodeErrors."); + +#define BYTEARRAY_DECODE_METHODDEF \ + {"decode", (PyCFunction)bytearray_decode, METH_VARARGS|METH_KEYWORDS, bytearray_decode__doc__}, + +static PyObject * +bytearray_decode_impl(PyByteArrayObject *self, const char *encoding, const char *errors); + +static PyObject * +bytearray_decode(PyByteArrayObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"encoding", "errors", NULL}; + const char *encoding = NULL; + const char *errors = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|ss:decode", _keywords, + &encoding, &errors)) + goto exit; + return_value = bytearray_decode_impl(self, encoding, errors); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_join__doc__, +"join($self, iterable_of_bytes, /)\n" +"--\n" +"\n" +"Concatenate any number of bytes/bytearray objects.\n" +"\n" +"The bytearray whose method is called is inserted in between each pair.\n" +"\n" +"The result is returned as a new bytearray object."); + +#define BYTEARRAY_JOIN_METHODDEF \ + {"join", (PyCFunction)bytearray_join, METH_O, bytearray_join__doc__}, + +PyDoc_STRVAR(bytearray_splitlines__doc__, +"splitlines($self, /, keepends=False)\n" +"--\n" +"\n" +"Return a list of the lines in the bytearray, breaking at line boundaries.\n" +"\n" +"Line breaks are not included in the resulting list unless keepends is given and\n" +"true."); + +#define BYTEARRAY_SPLITLINES_METHODDEF \ + {"splitlines", (PyCFunction)bytearray_splitlines, METH_VARARGS|METH_KEYWORDS, bytearray_splitlines__doc__}, + +static PyObject * +bytearray_splitlines_impl(PyByteArrayObject *self, int keepends); + +static PyObject * +bytearray_splitlines(PyByteArrayObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"keepends", NULL}; + int keepends = 0; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|i:splitlines", _keywords, + &keepends)) + goto exit; + return_value = bytearray_splitlines_impl(self, keepends); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_fromhex__doc__, +"fromhex($type, string, /)\n" +"--\n" +"\n" +"Create a bytearray object from a string of hexadecimal numbers.\n" +"\n" +"Spaces between two numbers are accepted.\n" +"Example: bytearray.fromhex(\'B9 01EF\') -> bytearray(b\'\\\\xb9\\\\x01\\\\xef\')"); + +#define BYTEARRAY_FROMHEX_METHODDEF \ + {"fromhex", (PyCFunction)bytearray_fromhex, METH_VARARGS|METH_CLASS, bytearray_fromhex__doc__}, + +static PyObject * +bytearray_fromhex_impl(PyObject*cls, PyObject *string); + +static PyObject * +bytearray_fromhex(PyTypeObject *cls, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *string; + + if (!PyArg_ParseTuple(args, + "U:fromhex", + &string)) + goto exit; + return_value = bytearray_fromhex_impl((PyObject*)cls, string); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_reduce__doc__, +"__reduce__($self, /)\n" +"--\n" +"\n" +"Return state information for pickling."); + +#define BYTEARRAY_REDUCE_METHODDEF \ + {"__reduce__", (PyCFunction)bytearray_reduce, METH_NOARGS, bytearray_reduce__doc__}, + +static PyObject * +bytearray_reduce_impl(PyByteArrayObject *self); + +static PyObject * +bytearray_reduce(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) +{ + return bytearray_reduce_impl(self); +} + +PyDoc_STRVAR(bytearray_reduce_ex__doc__, +"__reduce_ex__($self, proto=0, /)\n" +"--\n" +"\n" +"Return state information for pickling."); + +#define BYTEARRAY_REDUCE_EX_METHODDEF \ + {"__reduce_ex__", (PyCFunction)bytearray_reduce_ex, METH_VARARGS, bytearray_reduce_ex__doc__}, + +static PyObject * +bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto); + +static PyObject * +bytearray_reduce_ex(PyByteArrayObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int proto = 0; + + if (!PyArg_ParseTuple(args, + "|i:__reduce_ex__", + &proto)) + goto exit; + return_value = bytearray_reduce_ex_impl(self, proto); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytearray_sizeof__doc__, +"__sizeof__($self, /)\n" +"--\n" +"\n" +"Returns the size of the bytearray object in memory, in bytes."); + +#define BYTEARRAY_SIZEOF_METHODDEF \ + {"__sizeof__", (PyCFunction)bytearray_sizeof, METH_NOARGS, bytearray_sizeof__doc__}, + +static PyObject * +bytearray_sizeof_impl(PyByteArrayObject *self); + +static PyObject * +bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) +{ + return bytearray_sizeof_impl(self); +} +/*[clinic end generated code: output=70ea384faeca8d16 input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Objects/clinic/bytesobject.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Objects/clinic/bytesobject.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,514 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(bytes_split__doc__, +"split($self, /, sep=None, maxsplit=-1)\n" +"--\n" +"\n" +"Return a list of the sections in the bytes, using sep as the delimiter.\n" +"\n" +" sep\n" +" The delimiter according which to split the bytes.\n" +" None (the default value) means split on ASCII whitespace characters\n" +" (space, tab, return, newline, formfeed, vertical tab).\n" +" maxsplit\n" +" Maximum number of splits to do.\n" +" -1 (the default value) means no limit."); + +#define BYTES_SPLIT_METHODDEF \ + {"split", (PyCFunction)bytes_split, METH_VARARGS|METH_KEYWORDS, bytes_split__doc__}, + +static PyObject * +bytes_split_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit); + +static PyObject * +bytes_split(PyBytesObject*self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"sep", "maxsplit", NULL}; + PyObject *sep = Py_None; + Py_ssize_t maxsplit = -1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|On:split", _keywords, + &sep, &maxsplit)) + goto exit; + return_value = bytes_split_impl(self, sep, maxsplit); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytes_partition__doc__, +"partition($self, sep, /)\n" +"--\n" +"\n" +"Partition the bytes into three parts using the given separator.\n" +"\n" +"This will search for the separator sep in the bytes. If the separator is found,\n" +"returns a 3-tuple containing the part before the separator, the separator\n" +"itself, and the part after it.\n" +"\n" +"If the separator is not found, returns a 3-tuple containing the original bytes\n" +"object and two empty bytes objects."); + +#define BYTES_PARTITION_METHODDEF \ + {"partition", (PyCFunction)bytes_partition, METH_VARARGS, bytes_partition__doc__}, + +static PyObject * +bytes_partition_impl(PyBytesObject *self, Py_buffer *sep); + +static PyObject * +bytes_partition(PyBytesObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + Py_buffer sep = {NULL, NULL}; + + if (!PyArg_ParseTuple(args, + "y*:partition", + &sep)) + goto exit; + return_value = bytes_partition_impl(self, &sep); + +exit: + /* Cleanup for sep */ + if (sep.obj) + PyBuffer_Release(&sep); + + return return_value; +} + +PyDoc_STRVAR(bytes_rpartition__doc__, +"rpartition($self, sep, /)\n" +"--\n" +"\n" +"Partition the bytes into three parts using the given separator.\n" +"\n" +"This will search for the separator sep in the bytes, starting and the end. If\n" +"the separator is found, returns a 3-tuple containing the part before the\n" +"separator, the separator itself, and the part after it.\n" +"\n" +"If the separator is not found, returns a 3-tuple containing two empty bytes\n" +"objects and the original bytes object."); + +#define BYTES_RPARTITION_METHODDEF \ + {"rpartition", (PyCFunction)bytes_rpartition, METH_VARARGS, bytes_rpartition__doc__}, + +static PyObject * +bytes_rpartition_impl(PyBytesObject *self, Py_buffer *sep); + +static PyObject * +bytes_rpartition(PyBytesObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + Py_buffer sep = {NULL, NULL}; + + if (!PyArg_ParseTuple(args, + "y*:rpartition", + &sep)) + goto exit; + return_value = bytes_rpartition_impl(self, &sep); + +exit: + /* Cleanup for sep */ + if (sep.obj) + PyBuffer_Release(&sep); + + return return_value; +} + +PyDoc_STRVAR(bytes_rsplit__doc__, +"rsplit($self, /, sep=None, maxsplit=-1)\n" +"--\n" +"\n" +"Return a list of the sections in the bytes, using sep as the delimiter.\n" +"\n" +" sep\n" +" The delimiter according which to split the bytes.\n" +" None (the default value) means split on ASCII whitespace characters\n" +" (space, tab, return, newline, formfeed, vertical tab).\n" +" maxsplit\n" +" Maximum number of splits to do.\n" +" -1 (the default value) means no limit.\n" +"\n" +"Splitting is done starting at the end of the bytes and working to the front."); + +#define BYTES_RSPLIT_METHODDEF \ + {"rsplit", (PyCFunction)bytes_rsplit, METH_VARARGS|METH_KEYWORDS, bytes_rsplit__doc__}, + +static PyObject * +bytes_rsplit_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit); + +static PyObject * +bytes_rsplit(PyBytesObject*self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"sep", "maxsplit", NULL}; + PyObject *sep = Py_None; + Py_ssize_t maxsplit = -1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|On:rsplit", _keywords, + &sep, &maxsplit)) + goto exit; + return_value = bytes_rsplit_impl(self, sep, maxsplit); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytes_join__doc__, +"join($self, iterable_of_bytes, /)\n" +"--\n" +"\n" +"Concatenate any number of bytes objects.\n" +"\n" +"The bytes whose method is called is inserted in between each pair.\n" +"\n" +"The result is returned as a new bytes object.\n" +"\n" +"Example: b\'.\'.join([b\'ab\', b\'pq\', b\'rs\']) -> b\'ab.pq.rs\'."); + +#define BYTES_JOIN_METHODDEF \ + {"join", (PyCFunction)bytes_join, METH_O, bytes_join__doc__}, + +PyDoc_STRVAR(bytes_strip__doc__, +"strip($self, bytes=None, /)\n" +"--\n" +"\n" +"Strip leading and trailing bytes contained in the argument.\n" +"\n" +"If the argument is omitted or None, strip leading and trailing ASCII whitespace."); + +#define BYTES_STRIP_METHODDEF \ + {"strip", (PyCFunction)bytes_strip, METH_VARARGS, bytes_strip__doc__}, + +static PyObject * +bytes_strip_impl(PyBytesObject *self, PyObject *bytes); + +static PyObject * +bytes_strip(PyBytesObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *bytes = Py_None; + + if (!PyArg_UnpackTuple(args, "strip", + 0, 1, + &bytes)) + goto exit; + return_value = bytes_strip_impl(self, bytes); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytes_lstrip__doc__, +"lstrip($self, bytes=None, /)\n" +"--\n" +"\n" +"Strip leading bytes contained in the argument.\n" +"\n" +"If the argument is omitted or None, strip leading ASCII whitespace."); + +#define BYTES_LSTRIP_METHODDEF \ + {"lstrip", (PyCFunction)bytes_lstrip, METH_VARARGS, bytes_lstrip__doc__}, + +static PyObject * +bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes); + +static PyObject * +bytes_lstrip(PyBytesObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *bytes = Py_None; + + if (!PyArg_UnpackTuple(args, "lstrip", + 0, 1, + &bytes)) + goto exit; + return_value = bytes_lstrip_impl(self, bytes); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytes_rstrip__doc__, +"rstrip($self, bytes=None, /)\n" +"--\n" +"\n" +"Strip trailing bytes contained in the argument.\n" +"\n" +"If the argument is omitted or None, strip trailing ASCII whitespace."); + +#define BYTES_RSTRIP_METHODDEF \ + {"rstrip", (PyCFunction)bytes_rstrip, METH_VARARGS, bytes_rstrip__doc__}, + +static PyObject * +bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes); + +static PyObject * +bytes_rstrip(PyBytesObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *bytes = Py_None; + + if (!PyArg_UnpackTuple(args, "rstrip", + 0, 1, + &bytes)) + goto exit; + return_value = bytes_rstrip_impl(self, bytes); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytes_translate__doc__, +"translate(table, [deletechars])\n" +"Return a copy with each character mapped by the given translation table.\n" +"\n" +" table\n" +" Translation table, which must be a bytes object of length 256.\n" +"\n" +"All characters occurring in the optional argument deletechars are removed.\n" +"The remaining characters are mapped through the given translation table."); + +#define BYTES_TRANSLATE_METHODDEF \ + {"translate", (PyCFunction)bytes_translate, METH_VARARGS, bytes_translate__doc__}, + +static PyObject * +bytes_translate_impl(PyBytesObject *self, PyObject *table, int group_right_1, PyObject *deletechars); + +static PyObject * +bytes_translate(PyBytesObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *table; + int group_right_1 = 0; + PyObject *deletechars = NULL; + + switch (PyTuple_GET_SIZE(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O:translate", &table)) + goto exit; + break; + case 2: + if (!PyArg_ParseTuple(args, "OO:translate", &table, &deletechars)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "bytes.translate requires 1 to 2 arguments"); + goto exit; + } + return_value = bytes_translate_impl(self, table, group_right_1, deletechars); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytes_maketrans__doc__, +"maketrans(frm, to, /)\n" +"--\n" +"\n" +"Return a translation table useable for the bytes or bytearray translate method.\n" +"\n" +"The returned table will be one where each byte in frm is mapped to the byte at\n" +"the same position in to.\n" +"\n" +"The bytes objects frm and to must be of the same length."); + +#define BYTES_MAKETRANS_METHODDEF \ + {"maketrans", (PyCFunction)bytes_maketrans, METH_VARARGS|METH_STATIC, bytes_maketrans__doc__}, + +static PyObject * +bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to); + +static PyObject * +bytes_maketrans(void *null, PyObject *args) +{ + PyObject *return_value = NULL; + Py_buffer frm = {NULL, NULL}; + Py_buffer to = {NULL, NULL}; + + if (!PyArg_ParseTuple(args, + "y*y*:maketrans", + &frm, &to)) + goto exit; + return_value = bytes_maketrans_impl(&frm, &to); + +exit: + /* Cleanup for frm */ + if (frm.obj) + PyBuffer_Release(&frm); + /* Cleanup for to */ + if (to.obj) + PyBuffer_Release(&to); + + return return_value; +} + +PyDoc_STRVAR(bytes_replace__doc__, +"replace($self, old, new, count=-1, /)\n" +"--\n" +"\n" +"Return a copy with all occurrences of substring old replaced by new.\n" +"\n" +" count\n" +" Maximum number of occurrences to replace.\n" +" -1 (the default value) means replace all occurrences.\n" +"\n" +"If the optional argument count is given, only the first count occurrences are\n" +"replaced."); + +#define BYTES_REPLACE_METHODDEF \ + {"replace", (PyCFunction)bytes_replace, METH_VARARGS, bytes_replace__doc__}, + +static PyObject * +bytes_replace_impl(PyBytesObject*self, Py_buffer *old, Py_buffer *new, Py_ssize_t count); + +static PyObject * +bytes_replace(PyBytesObject*self, PyObject *args) +{ + PyObject *return_value = NULL; + Py_buffer old = {NULL, NULL}; + Py_buffer new = {NULL, NULL}; + Py_ssize_t count = -1; + + if (!PyArg_ParseTuple(args, + "y*y*|n:replace", + &old, &new, &count)) + goto exit; + return_value = bytes_replace_impl(self, &old, &new, count); + +exit: + /* Cleanup for old */ + if (old.obj) + PyBuffer_Release(&old); + /* Cleanup for new */ + if (new.obj) + PyBuffer_Release(&new); + + return return_value; +} + +PyDoc_STRVAR(bytes_decode__doc__, +"decode($self, /, encoding=\'utf-8\', errors=\'strict\')\n" +"--\n" +"\n" +"Decode the bytes using the codec registered for encoding.\n" +"\n" +" encoding\n" +" The encoding with which to decode the bytes.\n" +" errors\n" +" The error handling scheme to use for the handling of decoding errors.\n" +" The default is \'strict\' meaning that decoding errors raise a\n" +" UnicodeDecodeError. Other possible values are \'ignore\' and \'replace\'\n" +" as well as any other name registered with codecs.register_error that\n" +" can handle UnicodeDecodeErrors."); + +#define BYTES_DECODE_METHODDEF \ + {"decode", (PyCFunction)bytes_decode, METH_VARARGS|METH_KEYWORDS, bytes_decode__doc__}, + +static PyObject * +bytes_decode_impl(PyBytesObject*self, const char *encoding, const char *errors); + +static PyObject * +bytes_decode(PyBytesObject*self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"encoding", "errors", NULL}; + const char *encoding = NULL; + const char *errors = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|ss:decode", _keywords, + &encoding, &errors)) + goto exit; + return_value = bytes_decode_impl(self, encoding, errors); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytes_splitlines__doc__, +"splitlines($self, /, keepends=False)\n" +"--\n" +"\n" +"Return a list of the lines in the bytes, breaking at line boundaries.\n" +"\n" +"Line breaks are not included in the resulting list unless keepends is given and\n" +"true."); + +#define BYTES_SPLITLINES_METHODDEF \ + {"splitlines", (PyCFunction)bytes_splitlines, METH_VARARGS|METH_KEYWORDS, bytes_splitlines__doc__}, + +static PyObject * +bytes_splitlines_impl(PyBytesObject*self, int keepends); + +static PyObject * +bytes_splitlines(PyBytesObject*self, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"keepends", NULL}; + int keepends = 0; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|i:splitlines", _keywords, + &keepends)) + goto exit; + return_value = bytes_splitlines_impl(self, keepends); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytes_fromhex__doc__, +"fromhex($type, string, /)\n" +"--\n" +"\n" +"Create a bytes object from a string of hexadecimal numbers.\n" +"\n" +"Spaces between two numbers are accepted.\n" +"Example: bytes.fromhex(\'B9 01EF\') -> b\'\\\\xb9\\\\x01\\\\xef\'."); + +#define BYTES_FROMHEX_METHODDEF \ + {"fromhex", (PyCFunction)bytes_fromhex, METH_VARARGS|METH_CLASS, bytes_fromhex__doc__}, + +static PyObject * +bytes_fromhex_impl(PyTypeObject *type, PyObject *string); + +static PyObject * +bytes_fromhex(PyTypeObject *type, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *string; + + if (!PyArg_ParseTuple(args, + "U:fromhex", + &string)) + goto exit; + return_value = bytes_fromhex_impl(type, string); + +exit: + return return_value; +} + +PyDoc_STRVAR(bytes_sizeof__doc__, +"__sizeof__($self, /)\n" +"--\n" +"\n" +"Returns the size of the bytes object in memory, in bytes."); + +#define BYTES_SIZEOF_METHODDEF \ + {"__sizeof__", (PyCFunction)bytes_sizeof, METH_NOARGS, bytes_sizeof__doc__}, + +static PyObject * +bytes_sizeof_impl(PyBytesObject *self); + +static PyObject * +bytes_sizeof(PyBytesObject *self, PyObject *Py_UNUSED(ignored)) +{ + return bytes_sizeof_impl(self); +} +/*[clinic end generated code: output=e66847b2d5c048fe input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Objects/clinic/dictobject.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Objects/clinic/dictobject.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,42 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(dict_fromkeys__doc__, +"fromkeys($type, iterable, value=None, /)\n" +"--\n" +"\n" +"Returns a new dict with keys from iterable and values equal to value."); + +#define DICT_FROMKEYS_METHODDEF \ + {"fromkeys", (PyCFunction)dict_fromkeys, METH_VARARGS|METH_CLASS, dict_fromkeys__doc__}, + +static PyObject * +dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value); + +static PyObject * +dict_fromkeys(PyTypeObject *type, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *iterable; + PyObject *value = Py_None; + + if (!PyArg_UnpackTuple(args, "fromkeys", + 1, 2, + &iterable, &value)) + goto exit; + return_value = dict_fromkeys_impl(type, iterable, value); + +exit: + return return_value; +} + +PyDoc_STRVAR(dict___contains____doc__, +"__contains__($self, key, /)\n" +"--\n" +"\n" +"True if D has a key k, else False."); + +#define DICT___CONTAINS___METHODDEF \ + {"__contains__", (PyCFunction)dict___contains__, METH_O|METH_COEXIST, dict___contains____doc__}, +/*[clinic end generated code: output=fe74d676332fdba6 input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Objects/clinic/unicodeobject.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Objects/clinic/unicodeobject.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,42 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(unicode_maketrans__doc__, +"maketrans(x, y=None, z=None, /)\n" +"--\n" +"\n" +"Return a translation table usable for str.translate().\n" +"\n" +"If there is only one argument, it must be a dictionary mapping Unicode\n" +"ordinals (integers) or characters to Unicode ordinals, strings or None.\n" +"Character keys will be then converted to ordinals.\n" +"If there are two arguments, they must be strings of equal length, and\n" +"in the resulting dictionary, each character in x will be mapped to the\n" +"character at the same position in y. If there is a third argument, it\n" +"must be a string, whose characters will be mapped to None in the result."); + +#define UNICODE_MAKETRANS_METHODDEF \ + {"maketrans", (PyCFunction)unicode_maketrans, METH_VARARGS|METH_STATIC, unicode_maketrans__doc__}, + +static PyObject * +unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z); + +static PyObject * +unicode_maketrans(void *null, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *x; + PyObject *y = NULL; + PyObject *z = NULL; + + if (!PyArg_ParseTuple(args, + "O|UU:maketrans", + &x, &y, &z)) + goto exit; + return_value = unicode_maketrans_impl(x, y, z); + +exit: + return return_value; +} +/*[clinic end generated code: output=4670413843c53055 input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Objects/dictobject.c --- a/Objects/dictobject.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Objects/dictobject.c Sun Feb 22 11:52:48 2015 +0200 @@ -233,6 +233,8 @@ static int dictresize(PyDictObject *mp, static PyDictObject *free_list[PyDict_MAXFREELIST]; static int numfree = 0; +#include "clinic/dictobject.c.h" + int PyDict_ClearFreeList(void) { @@ -1757,38 +1759,9 @@ dict.fromkeys Returns a new dict with keys from iterable and values equal to value. [clinic start generated code]*/ -PyDoc_STRVAR(dict_fromkeys__doc__, -"fromkeys($type, iterable, value=None, /)\n" -"--\n" -"\n" -"Returns a new dict with keys from iterable and values equal to value."); - -#define DICT_FROMKEYS_METHODDEF \ - {"fromkeys", (PyCFunction)dict_fromkeys, METH_VARARGS|METH_CLASS, dict_fromkeys__doc__}, - -static PyObject * -dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value); - -static PyObject * -dict_fromkeys(PyTypeObject *type, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *iterable; - PyObject *value = Py_None; - - if (!PyArg_UnpackTuple(args, "fromkeys", - 1, 2, - &iterable, &value)) - goto exit; - return_value = dict_fromkeys_impl(type, iterable, value); - -exit: - return return_value; -} - static PyObject * dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value) -/*[clinic end generated code: output=55f8dc0ffa87406f input=b85a667f9bf4669d]*/ +/*[clinic end generated code: output=8fb98e4b10384999 input=b85a667f9bf4669d]*/ { PyObject *it; /* iter(seq) */ PyObject *key; @@ -2266,18 +2239,9 @@ dict.__contains__ True if D has a key k, else False. [clinic start generated code]*/ -PyDoc_STRVAR(dict___contains____doc__, -"__contains__($self, key, /)\n" -"--\n" -"\n" -"True if D has a key k, else False."); - -#define DICT___CONTAINS___METHODDEF \ - {"__contains__", (PyCFunction)dict___contains__, METH_O|METH_COEXIST, dict___contains____doc__}, - static PyObject * dict___contains__(PyDictObject *self, PyObject *key) -/*[clinic end generated code: output=3cf3f8aaf2cc5cc3 input=b852b2a19b51ab24]*/ +/*[clinic end generated code: output=a3d03db709ed6e6b input=b852b2a19b51ab24]*/ { register PyDictObject *mp = self; Py_hash_t hash; diff -r a824c40e8fc0 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Objects/unicodeobject.c Sun Feb 22 11:52:48 2015 +0200 @@ -290,6 +290,8 @@ static unsigned char ascii_linebreak[] = 0, 0, 0, 0, 0, 0, 0, 0 }; +#include "clinic/unicodeobject.c.h" + /* The max unicode value is always 0x10FFFF while using the PEP-393 API. This function is kept for backward compatibility with the old API. */ Py_UNICODE @@ -12920,47 +12922,9 @@ character at the same position in y. If must be a string, whose characters will be mapped to None in the result. [clinic start generated code]*/ -PyDoc_STRVAR(unicode_maketrans__doc__, -"maketrans(x, y=None, z=None, /)\n" -"--\n" -"\n" -"Return a translation table usable for str.translate().\n" -"\n" -"If there is only one argument, it must be a dictionary mapping Unicode\n" -"ordinals (integers) or characters to Unicode ordinals, strings or None.\n" -"Character keys will be then converted to ordinals.\n" -"If there are two arguments, they must be strings of equal length, and\n" -"in the resulting dictionary, each character in x will be mapped to the\n" -"character at the same position in y. If there is a third argument, it\n" -"must be a string, whose characters will be mapped to None in the result."); - -#define UNICODE_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)unicode_maketrans, METH_VARARGS|METH_STATIC, unicode_maketrans__doc__}, - -static PyObject * -unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z); - -static PyObject * -unicode_maketrans(void *null, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *x; - PyObject *y = NULL; - PyObject *z = NULL; - - if (!PyArg_ParseTuple(args, - "O|UU:maketrans", - &x, &y, &z)) - goto exit; - return_value = unicode_maketrans_impl(x, y, z); - -exit: - return return_value; -} - static PyObject * unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z) -/*[clinic end generated code: output=566edf630f77436a input=7bfbf529a293c6c5]*/ +/*[clinic end generated code: output=a925c89452bd5881 input=7bfbf529a293c6c5]*/ { PyObject *new = NULL, *key, *value; Py_ssize_t i = 0; diff -r a824c40e8fc0 Python/bltinmodule.c --- a/Python/bltinmodule.c Sat Feb 21 15:26:02 2015 -0800 +++ b/Python/bltinmodule.c Sun Feb 22 11:52:48 2015 +0200 @@ -46,6 +46,8 @@ int Py_HasFileSystemDefaultEncoding = 0; _Py_IDENTIFIER(stdout); _Py_IDENTIFIER(stderr); +#include "clinic/bltinmodule.c.h" + /* AC: cannot convert yet, waiting for *args support */ static PyObject * builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds) @@ -239,18 +241,9 @@ abs as builtin_abs Return the absolute value of the argument. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_abs__doc__, -"abs($module, x, /)\n" -"--\n" -"\n" -"Return the absolute value of the argument."); - -#define BUILTIN_ABS_METHODDEF \ - {"abs", (PyCFunction)builtin_abs, METH_O, builtin_abs__doc__}, - static PyObject * builtin_abs(PyModuleDef *module, PyObject *x) -/*[clinic end generated code: output=f85095528ce7e2e5 input=aa29cc07869b4732]*/ +/*[clinic end generated code: output=6833047c493ecea2 input=aa29cc07869b4732]*/ { return PyNumber_Absolute(x); } @@ -266,20 +259,9 @@ Return True if bool(x) is True for all v If the iterable is empty, return True. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_all__doc__, -"all($module, iterable, /)\n" -"--\n" -"\n" -"Return True if bool(x) is True for all values x in the iterable.\n" -"\n" -"If the iterable is empty, return True."); - -#define BUILTIN_ALL_METHODDEF \ - {"all", (PyCFunction)builtin_all, METH_O, builtin_all__doc__}, - static PyObject * builtin_all(PyModuleDef *module, PyObject *iterable) -/*[clinic end generated code: output=d001db739ba83b46 input=dd506dc9998d42bd]*/ +/*[clinic end generated code: output=089e6d1b7bde27b1 input=dd506dc9998d42bd]*/ { PyObject *it, *item; PyObject *(*iternext)(PyObject *); @@ -326,20 +308,9 @@ Return True if bool(x) is True for any x If the iterable is empty, return False. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_any__doc__, -"any($module, iterable, /)\n" -"--\n" -"\n" -"Return True if bool(x) is True for any x in the iterable.\n" -"\n" -"If the iterable is empty, return False."); - -#define BUILTIN_ANY_METHODDEF \ - {"any", (PyCFunction)builtin_any, METH_O, builtin_any__doc__}, - static PyObject * builtin_any(PyModuleDef *module, PyObject *iterable) -/*[clinic end generated code: output=3a4b6dbe6a0d6f61 input=8fe8460f3fbbced8]*/ +/*[clinic end generated code: output=1be994b2c2307492 input=8fe8460f3fbbced8]*/ { PyObject *it, *item; PyObject *(*iternext)(PyObject *); @@ -389,23 +360,9 @@ repr() using \\x, \\u or \\U escapes. Th to that returned by repr() in Python 2. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_ascii__doc__, -"ascii($module, obj, /)\n" -"--\n" -"\n" -"Return an ASCII-only representation of an object.\n" -"\n" -"As repr(), return a string containing a printable representation of an\n" -"object, but escape the non-ASCII characters in the string returned by\n" -"repr() using \\\\x, \\\\u or \\\\U escapes. This generates a string similar\n" -"to that returned by repr() in Python 2."); - -#define BUILTIN_ASCII_METHODDEF \ - {"ascii", (PyCFunction)builtin_ascii, METH_O, builtin_ascii__doc__}, - static PyObject * builtin_ascii(PyModuleDef *module, PyObject *obj) -/*[clinic end generated code: output=f0e6754154c2d30b input=0cbdc1420a306325]*/ +/*[clinic end generated code: output=d4e862c48af2a933 input=0cbdc1420a306325]*/ { return PyObject_ASCII(obj); } @@ -423,21 +380,9 @@ Return the binary representation of an i '0b1010101010101010101010' [clinic start generated code]*/ -PyDoc_STRVAR(builtin_bin__doc__, -"bin($module, number, /)\n" -"--\n" -"\n" -"Return the binary representation of an integer.\n" -"\n" -" >>> bin(2796202)\n" -" \'0b1010101010101010101010\'"); - -#define BUILTIN_BIN_METHODDEF \ - {"bin", (PyCFunction)builtin_bin, METH_O, builtin_bin__doc__}, - static PyObject * builtin_bin(PyModuleDef *module, PyObject *number) -/*[clinic end generated code: output=18fed0e943650da1 input=2a6362ae9a9c9203]*/ +/*[clinic end generated code: output=25ee26c6cf3bbb54 input=2a6362ae9a9c9203]*/ { return PyNumber_ToBase(number, 2); } @@ -455,21 +400,9 @@ Note that classes are callable, as are i __call__() method. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_callable__doc__, -"callable($module, obj, /)\n" -"--\n" -"\n" -"Return whether the object is callable (i.e., some kind of function).\n" -"\n" -"Note that classes are callable, as are instances of classes with a\n" -"__call__() method."); - -#define BUILTIN_CALLABLE_METHODDEF \ - {"callable", (PyCFunction)builtin_callable, METH_O, builtin_callable__doc__}, - static PyObject * builtin_callable(PyModuleDef *module, PyObject *obj) -/*[clinic end generated code: output=b3a92cbe635f32af input=bb3bb528fffdade4]*/ +/*[clinic end generated code: output=f4df2ce92364b656 input=bb3bb528fffdade4]*/ { return PyBool_FromLong((long)PyCallable_Check(obj)); } @@ -640,40 +573,9 @@ Return value.__format__(format_spec) format_spec defaults to the empty string [clinic start generated code]*/ -PyDoc_STRVAR(builtin_format__doc__, -"format($module, value, format_spec=\'\', /)\n" -"--\n" -"\n" -"Return value.__format__(format_spec)\n" -"\n" -"format_spec defaults to the empty string"); - -#define BUILTIN_FORMAT_METHODDEF \ - {"format", (PyCFunction)builtin_format, METH_VARARGS, builtin_format__doc__}, - -static PyObject * -builtin_format_impl(PyModuleDef *module, PyObject *value, PyObject *format_spec); - -static PyObject * -builtin_format(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *value; - PyObject *format_spec = NULL; - - if (!PyArg_ParseTuple(args, - "O|U:format", - &value, &format_spec)) - goto exit; - return_value = builtin_format_impl(module, value, format_spec); - -exit: - return return_value; -} - static PyObject * builtin_format_impl(PyModuleDef *module, PyObject *value, PyObject *format_spec) -/*[clinic end generated code: output=39723a58c72e8871 input=e23f2f11e0098c64]*/ +/*[clinic end generated code: output=fae3e927cc715466 input=e23f2f11e0098c64]*/ { return PyObject_Format(value, format_spec); } @@ -687,37 +589,9 @@ chr as builtin_chr Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_chr__doc__, -"chr($module, i, /)\n" -"--\n" -"\n" -"Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff."); - -#define BUILTIN_CHR_METHODDEF \ - {"chr", (PyCFunction)builtin_chr, METH_VARARGS, builtin_chr__doc__}, - -static PyObject * -builtin_chr_impl(PyModuleDef *module, int i); - -static PyObject * -builtin_chr(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - int i; - - if (!PyArg_ParseTuple(args, - "i:chr", - &i)) - goto exit; - return_value = builtin_chr_impl(module, i); - -exit: - return return_value; -} - static PyObject * builtin_chr_impl(PyModuleDef *module, int i) -/*[clinic end generated code: output=4d6bbe948f56e2ae input=9b1ced29615adf66]*/ +/*[clinic end generated code: output=67fe4d87e690f373 input=9b1ced29615adf66]*/ { return PyUnicode_FromOrdinal(i); } @@ -779,55 +653,9 @@ compile; if absent or zero these stateme in addition to any features explicitly specified. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_compile__doc__, -"compile($module, /, source, filename, mode, flags=0, dont_inherit=0,\n" -" optimize=-1)\n" -"--\n" -"\n" -"Compile source into a code object that can be executed by exec() or eval().\n" -"\n" -"The source code may represent a Python module, statement or expression.\n" -"The filename will be used for run-time error messages.\n" -"The mode must be \'exec\' to compile a module, \'single\' to compile a\n" -"single (interactive) statement, or \'eval\' to compile an expression.\n" -"The flags argument, if present, controls which future statements influence\n" -"the compilation of the code.\n" -"The dont_inherit argument, if non-zero, stops the compilation inheriting\n" -"the effects of any future statements in effect in the code calling\n" -"compile; if absent or zero these statements do influence the compilation,\n" -"in addition to any features explicitly specified."); - -#define BUILTIN_COMPILE_METHODDEF \ - {"compile", (PyCFunction)builtin_compile, METH_VARARGS|METH_KEYWORDS, builtin_compile__doc__}, - -static PyObject * -builtin_compile_impl(PyModuleDef *module, PyObject *source, PyObject *filename, const char *mode, int flags, int dont_inherit, int optimize); - -static PyObject * -builtin_compile(PyModuleDef *module, PyObject *args, PyObject *kwargs) -{ - PyObject *return_value = NULL; - static char *_keywords[] = {"source", "filename", "mode", "flags", "dont_inherit", "optimize", NULL}; - PyObject *source; - PyObject *filename; - const char *mode; - int flags = 0; - int dont_inherit = 0; - int optimize = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "OO&s|iii:compile", _keywords, - &source, PyUnicode_FSDecoder, &filename, &mode, &flags, &dont_inherit, &optimize)) - goto exit; - return_value = builtin_compile_impl(module, source, filename, mode, flags, dont_inherit, optimize); - -exit: - return return_value; -} - static PyObject * builtin_compile_impl(PyModuleDef *module, PyObject *source, PyObject *filename, const char *mode, int flags, int dont_inherit, int optimize) -/*[clinic end generated code: output=c72d197809d178fc input=c6212a9d21472f7e]*/ +/*[clinic end generated code: output=4f41a315386bab9f input=c6212a9d21472f7e]*/ { Py_buffer view = {NULL, NULL}; const char *str; @@ -951,38 +779,9 @@ divmod as builtin_divmod Return the tuple ((x-x%y)/y, x%y). Invariant: div*y + mod == x. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_divmod__doc__, -"divmod($module, x, y, /)\n" -"--\n" -"\n" -"Return the tuple ((x-x%y)/y, x%y). Invariant: div*y + mod == x."); - -#define BUILTIN_DIVMOD_METHODDEF \ - {"divmod", (PyCFunction)builtin_divmod, METH_VARARGS, builtin_divmod__doc__}, - -static PyObject * -builtin_divmod_impl(PyModuleDef *module, PyObject *x, PyObject *y); - -static PyObject * -builtin_divmod(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *x; - PyObject *y; - - if (!PyArg_UnpackTuple(args, "divmod", - 2, 2, - &x, &y)) - goto exit; - return_value = builtin_divmod_impl(module, x, y); - -exit: - return return_value; -} - static PyObject * builtin_divmod_impl(PyModuleDef *module, PyObject *x, PyObject *y) -/*[clinic end generated code: output=77e8d408b1338886 input=c9c617b7bb74c615]*/ +/*[clinic end generated code: output=9ad0076120ebf9ac input=c9c617b7bb74c615]*/ { return PyNumber_Divmod(x, y); } @@ -1005,45 +804,9 @@ defaulting to the current globals and lo If only globals is given, locals defaults to it. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_eval__doc__, -"eval($module, source, globals=None, locals=None, /)\n" -"--\n" -"\n" -"Evaluate the given source in the context of globals and locals.\n" -"\n" -"The source may be a string representing a Python expression\n" -"or a code object as returned by compile().\n" -"The globals must be a dictionary and locals can be any mapping,\n" -"defaulting to the current globals and locals.\n" -"If only globals is given, locals defaults to it."); - -#define BUILTIN_EVAL_METHODDEF \ - {"eval", (PyCFunction)builtin_eval, METH_VARARGS, builtin_eval__doc__}, - -static PyObject * -builtin_eval_impl(PyModuleDef *module, PyObject *source, PyObject *globals, PyObject *locals); - -static PyObject * -builtin_eval(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *source; - PyObject *globals = Py_None; - PyObject *locals = Py_None; - - if (!PyArg_UnpackTuple(args, "eval", - 1, 3, - &source, &globals, &locals)) - goto exit; - return_value = builtin_eval_impl(module, source, globals, locals); - -exit: - return return_value; -} - static PyObject * builtin_eval_impl(PyModuleDef *module, PyObject *source, PyObject *globals, PyObject *locals) -/*[clinic end generated code: output=644fd59012538ce6 input=31e42c1d2125b50b]*/ +/*[clinic end generated code: output=90642b79dd8b08d6 input=31e42c1d2125b50b]*/ { PyObject *result, *tmp = NULL; Py_buffer view = {NULL, NULL}; @@ -1125,45 +888,9 @@ defaulting to the current globals and lo If only globals is given, locals defaults to it. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_exec__doc__, -"exec($module, source, globals=None, locals=None, /)\n" -"--\n" -"\n" -"Execute the given source in the context of globals and locals.\n" -"\n" -"The source may be a string representing one or more Python statements\n" -"or a code object as returned by compile().\n" -"The globals must be a dictionary and locals can be any mapping,\n" -"defaulting to the current globals and locals.\n" -"If only globals is given, locals defaults to it."); - -#define BUILTIN_EXEC_METHODDEF \ - {"exec", (PyCFunction)builtin_exec, METH_VARARGS, builtin_exec__doc__}, - -static PyObject * -builtin_exec_impl(PyModuleDef *module, PyObject *source, PyObject *globals, PyObject *locals); - -static PyObject * -builtin_exec(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *source; - PyObject *globals = Py_None; - PyObject *locals = Py_None; - - if (!PyArg_UnpackTuple(args, "exec", - 1, 3, - &source, &globals, &locals)) - goto exit; - return_value = builtin_exec_impl(module, source, globals, locals); - -exit: - return return_value; -} - static PyObject * builtin_exec_impl(PyModuleDef *module, PyObject *source, PyObject *globals, PyObject *locals) -/*[clinic end generated code: output=0281b48bfa8e3c87 input=536e057b5e00d89e]*/ +/*[clinic end generated code: output=e8e0bbcde826a048 input=536e057b5e00d89e]*/ { PyObject *v; @@ -1275,30 +1002,9 @@ NOTE: Updates to this dictionary *will* global scope and vice-versa. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_globals__doc__, -"globals($module, /)\n" -"--\n" -"\n" -"Return the dictionary containing the current scope\'s global variables.\n" -"\n" -"NOTE: Updates to this dictionary *will* affect name lookups in the current\n" -"global scope and vice-versa."); - -#define BUILTIN_GLOBALS_METHODDEF \ - {"globals", (PyCFunction)builtin_globals, METH_NOARGS, builtin_globals__doc__}, - -static PyObject * -builtin_globals_impl(PyModuleDef *module); - -static PyObject * -builtin_globals(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return builtin_globals_impl(module); -} - static PyObject * builtin_globals_impl(PyModuleDef *module) -/*[clinic end generated code: output=048640f58b1f20ad input=9327576f92bb48ba]*/ +/*[clinic end generated code: output=4958645e96dd8138 input=9327576f92bb48ba]*/ { PyObject *d; @@ -1320,40 +1026,9 @@ Return whether the object has an attribu This is done by calling getattr(obj, name) and catching AttributeError. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_hasattr__doc__, -"hasattr($module, obj, name, /)\n" -"--\n" -"\n" -"Return whether the object has an attribute with the given name.\n" -"\n" -"This is done by calling getattr(obj, name) and catching AttributeError."); - -#define BUILTIN_HASATTR_METHODDEF \ - {"hasattr", (PyCFunction)builtin_hasattr, METH_VARARGS, builtin_hasattr__doc__}, - -static PyObject * -builtin_hasattr_impl(PyModuleDef *module, PyObject *obj, PyObject *name); - -static PyObject * -builtin_hasattr(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *obj; - PyObject *name; - - if (!PyArg_UnpackTuple(args, "hasattr", - 2, 2, - &obj, &name)) - goto exit; - return_value = builtin_hasattr_impl(module, obj, name); - -exit: - return return_value; -} - static PyObject * builtin_hasattr_impl(PyModuleDef *module, PyObject *obj, PyObject *name) -/*[clinic end generated code: output=e0bd996ef73d1217 input=b50bad5f739ea10d]*/ +/*[clinic end generated code: output=81154fdd63634696 input=b50bad5f739ea10d]*/ { PyObject *v; @@ -1392,21 +1067,9 @@ This is guaranteed to be unique among si (CPython uses the object's memory address.) [clinic start generated code]*/ -PyDoc_STRVAR(builtin_id__doc__, -"id($module, obj, /)\n" -"--\n" -"\n" -"Return the identity of an object.\n" -"\n" -"This is guaranteed to be unique among simultaneously existing objects.\n" -"(CPython uses the object\'s memory address.)"); - -#define BUILTIN_ID_METHODDEF \ - {"id", (PyCFunction)builtin_id, METH_O, builtin_id__doc__}, - static PyObject * builtin_id(PyModuleDef *self, PyObject *v) -/*[clinic end generated code: output=f54da09c91992e63 input=a1f988d98357341d]*/ +/*[clinic end generated code: output=0aa640785f697f65 input=a1f988d98357341d]*/ { return PyLong_FromVoidPtr(v); } @@ -1639,41 +1302,9 @@ Sets the named attribute on the given ob setattr(x, 'y', v) is equivalent to ``x.y = v'' [clinic start generated code]*/ -PyDoc_STRVAR(builtin_setattr__doc__, -"setattr($module, obj, name, value, /)\n" -"--\n" -"\n" -"Sets the named attribute on the given object to the specified value.\n" -"\n" -"setattr(x, \'y\', v) is equivalent to ``x.y = v\'\'"); - -#define BUILTIN_SETATTR_METHODDEF \ - {"setattr", (PyCFunction)builtin_setattr, METH_VARARGS, builtin_setattr__doc__}, - -static PyObject * -builtin_setattr_impl(PyModuleDef *module, PyObject *obj, PyObject *name, PyObject *value); - -static PyObject * -builtin_setattr(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *obj; - PyObject *name; - PyObject *value; - - if (!PyArg_UnpackTuple(args, "setattr", - 3, 3, - &obj, &name, &value)) - goto exit; - return_value = builtin_setattr_impl(module, obj, name, value); - -exit: - return return_value; -} - static PyObject * builtin_setattr_impl(PyModuleDef *module, PyObject *obj, PyObject *name, PyObject *value) -/*[clinic end generated code: output=4336dcbbf7691d2d input=fbe7e53403116b93]*/ +/*[clinic end generated code: output=c5e0a3a3971333ed input=fbe7e53403116b93]*/ { if (PyObject_SetAttr(obj, name, value) != 0) return NULL; @@ -1694,40 +1325,9 @@ Deletes the named attribute from the giv delattr(x, 'y') is equivalent to ``del x.y'' [clinic start generated code]*/ -PyDoc_STRVAR(builtin_delattr__doc__, -"delattr($module, obj, name, /)\n" -"--\n" -"\n" -"Deletes the named attribute from the given object.\n" -"\n" -"delattr(x, \'y\') is equivalent to ``del x.y\'\'"); - -#define BUILTIN_DELATTR_METHODDEF \ - {"delattr", (PyCFunction)builtin_delattr, METH_VARARGS, builtin_delattr__doc__}, - -static PyObject * -builtin_delattr_impl(PyModuleDef *module, PyObject *obj, PyObject *name); - -static PyObject * -builtin_delattr(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *obj; - PyObject *name; - - if (!PyArg_UnpackTuple(args, "delattr", - 2, 2, - &obj, &name)) - goto exit; - return_value = builtin_delattr_impl(module, obj, name); - -exit: - return return_value; -} - static PyObject * builtin_delattr_impl(PyModuleDef *module, PyObject *obj, PyObject *name) -/*[clinic end generated code: output=319c2d884aa769cf input=647af2ce9183a823]*/ +/*[clinic end generated code: output=ef653e698a0b4187 input=647af2ce9183a823]*/ { if (PyObject_SetAttr(obj, name, (PyObject *)NULL) != 0) return NULL; @@ -1748,21 +1348,9 @@ Two objects that compare equal must also reverse is not necessarily true. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_hash__doc__, -"hash($module, obj, /)\n" -"--\n" -"\n" -"Return the hash value for the given object.\n" -"\n" -"Two objects that compare equal must also have the same hash value, but the\n" -"reverse is not necessarily true."); - -#define BUILTIN_HASH_METHODDEF \ - {"hash", (PyCFunction)builtin_hash, METH_O, builtin_hash__doc__}, - static PyObject * builtin_hash(PyModuleDef *module, PyObject *obj) -/*[clinic end generated code: output=1ec467611c13468b input=ccc4d2b9a351df4e]*/ +/*[clinic end generated code: output=1f32ff154c1f751a input=ccc4d2b9a351df4e]*/ { Py_hash_t x; @@ -1785,21 +1373,9 @@ Return the hexadecimal representation of '0xc0ffee' [clinic start generated code]*/ -PyDoc_STRVAR(builtin_hex__doc__, -"hex($module, number, /)\n" -"--\n" -"\n" -"Return the hexadecimal representation of an integer.\n" -"\n" -" >>> hex(12648430)\n" -" \'0xc0ffee\'"); - -#define BUILTIN_HEX_METHODDEF \ - {"hex", (PyCFunction)builtin_hex, METH_O, builtin_hex__doc__}, - static PyObject * builtin_hex(PyModuleDef *module, PyObject *number) -/*[clinic end generated code: output=f18e9439aeaa2c6c input=e816200b0a728ebe]*/ +/*[clinic end generated code: output=618489ce3cbc5858 input=e816200b0a728ebe]*/ { return PyNumber_ToBase(number, 16); } @@ -1841,18 +1417,9 @@ len as builtin_len Return the number of items in a container. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_len__doc__, -"len($module, obj, /)\n" -"--\n" -"\n" -"Return the number of items in a container."); - -#define BUILTIN_LEN_METHODDEF \ - {"len", (PyCFunction)builtin_len, METH_O, builtin_len__doc__}, - static PyObject * builtin_len(PyModuleDef *module, PyObject *obj) -/*[clinic end generated code: output=5a38b0db40761705 input=2e5ff15db9a2de22]*/ +/*[clinic end generated code: output=8e5837b6f81d915b input=2e5ff15db9a2de22]*/ { Py_ssize_t res; @@ -1873,31 +1440,9 @@ the local scope and vice-versa is *imple covered by any backwards compatibility guarantees. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_locals__doc__, -"locals($module, /)\n" -"--\n" -"\n" -"Return a dictionary containing the current scope\'s local variables.\n" -"\n" -"NOTE: Whether or not updates to this dictionary will affect name lookups in\n" -"the local scope and vice-versa is *implementation dependent* and not\n" -"covered by any backwards compatibility guarantees."); - -#define BUILTIN_LOCALS_METHODDEF \ - {"locals", (PyCFunction)builtin_locals, METH_NOARGS, builtin_locals__doc__}, - -static PyObject * -builtin_locals_impl(PyModuleDef *module); - -static PyObject * -builtin_locals(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) -{ - return builtin_locals_impl(module); -} - static PyObject * builtin_locals_impl(PyModuleDef *module) -/*[clinic end generated code: output=8ac52522924346e2 input=7874018d478d5c4b]*/ +/*[clinic end generated code: output=8b5a41f12e19d13a input=7874018d478d5c4b]*/ { PyObject *d; @@ -2054,21 +1599,9 @@ Return the octal representation of an in '0o1234567' [clinic start generated code]*/ -PyDoc_STRVAR(builtin_oct__doc__, -"oct($module, number, /)\n" -"--\n" -"\n" -"Return the octal representation of an integer.\n" -"\n" -" >>> oct(342391)\n" -" \'0o1234567\'"); - -#define BUILTIN_OCT_METHODDEF \ - {"oct", (PyCFunction)builtin_oct, METH_O, builtin_oct__doc__}, - static PyObject * builtin_oct(PyModuleDef *module, PyObject *number) -/*[clinic end generated code: output=b99234d1d70a6673 input=a3a372b521b3dd13]*/ +/*[clinic end generated code: output=18f701bc6d8f804a input=a3a372b521b3dd13]*/ { return PyNumber_ToBase(number, 8); } @@ -2083,18 +1616,9 @@ ord as builtin_ord Return the Unicode code point for a one-character string. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_ord__doc__, -"ord($module, c, /)\n" -"--\n" -"\n" -"Return the Unicode code point for a one-character string."); - -#define BUILTIN_ORD_METHODDEF \ - {"ord", (PyCFunction)builtin_ord, METH_O, builtin_ord__doc__}, - static PyObject * builtin_ord(PyModuleDef *module, PyObject *c) -/*[clinic end generated code: output=a8466d23bd76db3f input=762355f87451efa3]*/ +/*[clinic end generated code: output=04fd27272d9462f6 input=762355f87451efa3]*/ { long ord; Py_ssize_t size; @@ -2152,42 +1676,9 @@ Some types, such as ints, are able to us invoked using the three argument form. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_pow__doc__, -"pow($module, x, y, z=None, /)\n" -"--\n" -"\n" -"Equivalent to x**y (with two arguments) or x**y % z (with three arguments)\n" -"\n" -"Some types, such as ints, are able to use a more efficient algorithm when\n" -"invoked using the three argument form."); - -#define BUILTIN_POW_METHODDEF \ - {"pow", (PyCFunction)builtin_pow, METH_VARARGS, builtin_pow__doc__}, - -static PyObject * -builtin_pow_impl(PyModuleDef *module, PyObject *x, PyObject *y, PyObject *z); - -static PyObject * -builtin_pow(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *x; - PyObject *y; - PyObject *z = Py_None; - - if (!PyArg_UnpackTuple(args, "pow", - 2, 3, - &x, &y, &z)) - goto exit; - return_value = builtin_pow_impl(module, x, y, z); - -exit: - return return_value; -} - static PyObject * builtin_pow_impl(PyModuleDef *module, PyObject *x, PyObject *y, PyObject *z) -/*[clinic end generated code: output=d0cdf314311dedba input=561a942d5f5c1899]*/ +/*[clinic end generated code: output=1fba268adba9b45f input=561a942d5f5c1899]*/ { return PyNumber_Power(x, y, z); } @@ -2304,43 +1795,9 @@ If the user hits EOF (*nix: Ctrl-D, Wind On *nix systems, readline is used if available. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_input__doc__, -"input($module, prompt=None, /)\n" -"--\n" -"\n" -"Read a string from standard input. The trailing newline is stripped.\n" -"\n" -"The prompt string, if given, is printed to standard output without a\n" -"trailing newline before reading input.\n" -"\n" -"If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.\n" -"On *nix systems, readline is used if available."); - -#define BUILTIN_INPUT_METHODDEF \ - {"input", (PyCFunction)builtin_input, METH_VARARGS, builtin_input__doc__}, - -static PyObject * -builtin_input_impl(PyModuleDef *module, PyObject *prompt); - -static PyObject * -builtin_input(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *prompt = NULL; - - if (!PyArg_UnpackTuple(args, "input", - 0, 1, - &prompt)) - goto exit; - return_value = builtin_input_impl(module, prompt); - -exit: - return return_value; -} - static PyObject * builtin_input_impl(PyModuleDef *module, PyObject *prompt) -/*[clinic end generated code: output=69323bf5695f7c9c input=5e8bb70c2908fe3c]*/ +/*[clinic end generated code: output=b77731f59e1515c4 input=5e8bb70c2908fe3c]*/ { PyObject *fin = _PySys_GetObjectId(&PyId_stdin); PyObject *fout = _PySys_GetObjectId(&PyId_stdout); @@ -2523,20 +1980,9 @@ Return the canonical string representati For many object types, including most builtins, eval(repr(obj)) == obj. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_repr__doc__, -"repr($module, obj, /)\n" -"--\n" -"\n" -"Return the canonical string representation of the object.\n" -"\n" -"For many object types, including most builtins, eval(repr(obj)) == obj."); - -#define BUILTIN_REPR_METHODDEF \ - {"repr", (PyCFunction)builtin_repr, METH_O, builtin_repr__doc__}, - static PyObject * builtin_repr(PyModuleDef *module, PyObject *obj) -/*[clinic end generated code: output=988980120f39e2fa input=a2bca0f38a5a924d]*/ +/*[clinic end generated code: output=dc41784fa4341834 input=a2bca0f38a5a924d]*/ { return PyObject_Repr(obj); } @@ -2704,42 +2150,9 @@ This function is intended specifically f reject non-numeric types. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_sum__doc__, -"sum($module, iterable, start=0, /)\n" -"--\n" -"\n" -"Return the sum of a \'start\' value (default: 0) plus an iterable of numbers\n" -"\n" -"When the iterable is empty, return the start value.\n" -"This function is intended specifically for use with numeric values and may\n" -"reject non-numeric types."); - -#define BUILTIN_SUM_METHODDEF \ - {"sum", (PyCFunction)builtin_sum, METH_VARARGS, builtin_sum__doc__}, - -static PyObject * -builtin_sum_impl(PyModuleDef *module, PyObject *iterable, PyObject *start); - -static PyObject * -builtin_sum(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *iterable; - PyObject *start = NULL; - - if (!PyArg_UnpackTuple(args, "sum", - 1, 2, - &iterable, &start)) - goto exit; - return_value = builtin_sum_impl(module, iterable, start); - -exit: - return return_value; -} - static PyObject * builtin_sum_impl(PyModuleDef *module, PyObject *iterable, PyObject *start) -/*[clinic end generated code: output=b42652a0d5f64f6b input=90ae7a242cfcf025]*/ +/*[clinic end generated code: output=33655b248b21d581 input=90ae7a242cfcf025]*/ { PyObject *result = start; PyObject *temp, *item, *iter; @@ -2914,42 +2327,9 @@ check against. This is equivalent to ``i or ...`` etc. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_isinstance__doc__, -"isinstance($module, obj, class_or_tuple, /)\n" -"--\n" -"\n" -"Return whether an object is an instance of a class or of a subclass thereof.\n" -"\n" -"A tuple, as in ``isinstance(x, (A, B, ...))``, may be given as the target to\n" -"check against. This is equivalent to ``isinstance(x, A) or isinstance(x, B)\n" -"or ...`` etc."); - -#define BUILTIN_ISINSTANCE_METHODDEF \ - {"isinstance", (PyCFunction)builtin_isinstance, METH_VARARGS, builtin_isinstance__doc__}, - -static PyObject * -builtin_isinstance_impl(PyModuleDef *module, PyObject *obj, PyObject *class_or_tuple); - -static PyObject * -builtin_isinstance(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *obj; - PyObject *class_or_tuple; - - if (!PyArg_UnpackTuple(args, "isinstance", - 2, 2, - &obj, &class_or_tuple)) - goto exit; - return_value = builtin_isinstance_impl(module, obj, class_or_tuple); - -exit: - return return_value; -} - static PyObject * builtin_isinstance_impl(PyModuleDef *module, PyObject *obj, PyObject *class_or_tuple) -/*[clinic end generated code: output=847df57fef8ddea7 input=cf9eb0ad6bb9bad6]*/ +/*[clinic end generated code: output=5e234dc3872d75a2 input=cf9eb0ad6bb9bad6]*/ { int retval; @@ -2974,42 +2354,9 @@ check against. This is equivalent to ``i or ...`` etc. [clinic start generated code]*/ -PyDoc_STRVAR(builtin_issubclass__doc__, -"issubclass($module, cls, class_or_tuple, /)\n" -"--\n" -"\n" -"Return whether \'cls\' is a derived from another class or is the same class.\n" -"\n" -"A tuple, as in ``issubclass(x, (A, B, ...))``, may be given as the target to\n" -"check against. This is equivalent to ``issubclass(x, A) or issubclass(x, B)\n" -"or ...`` etc."); - -#define BUILTIN_ISSUBCLASS_METHODDEF \ - {"issubclass", (PyCFunction)builtin_issubclass, METH_VARARGS, builtin_issubclass__doc__}, - -static PyObject * -builtin_issubclass_impl(PyModuleDef *module, PyObject *cls, PyObject *class_or_tuple); - -static PyObject * -builtin_issubclass(PyModuleDef *module, PyObject *args) -{ - PyObject *return_value = NULL; - PyObject *cls; - PyObject *class_or_tuple; - - if (!PyArg_UnpackTuple(args, "issubclass", - 2, 2, - &cls, &class_or_tuple)) - goto exit; - return_value = builtin_issubclass_impl(module, cls, class_or_tuple); - -exit: - return return_value; -} - static PyObject * builtin_issubclass_impl(PyModuleDef *module, PyObject *cls, PyObject *class_or_tuple) -/*[clinic end generated code: output=a0f8c03692e35474 input=923d03fa41fc352a]*/ +/*[clinic end generated code: output=6346a85ba15dbd7d input=923d03fa41fc352a]*/ { int retval; diff -r a824c40e8fc0 Python/clinic/bltinmodule.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/clinic/bltinmodule.c.h Sun Feb 22 11:52:48 2015 +0200 @@ -0,0 +1,659 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(builtin_abs__doc__, +"abs($module, x, /)\n" +"--\n" +"\n" +"Return the absolute value of the argument."); + +#define BUILTIN_ABS_METHODDEF \ + {"abs", (PyCFunction)builtin_abs, METH_O, builtin_abs__doc__}, + +PyDoc_STRVAR(builtin_all__doc__, +"all($module, iterable, /)\n" +"--\n" +"\n" +"Return True if bool(x) is True for all values x in the iterable.\n" +"\n" +"If the iterable is empty, return True."); + +#define BUILTIN_ALL_METHODDEF \ + {"all", (PyCFunction)builtin_all, METH_O, builtin_all__doc__}, + +PyDoc_STRVAR(builtin_any__doc__, +"any($module, iterable, /)\n" +"--\n" +"\n" +"Return True if bool(x) is True for any x in the iterable.\n" +"\n" +"If the iterable is empty, return False."); + +#define BUILTIN_ANY_METHODDEF \ + {"any", (PyCFunction)builtin_any, METH_O, builtin_any__doc__}, + +PyDoc_STRVAR(builtin_ascii__doc__, +"ascii($module, obj, /)\n" +"--\n" +"\n" +"Return an ASCII-only representation of an object.\n" +"\n" +"As repr(), return a string containing a printable representation of an\n" +"object, but escape the non-ASCII characters in the string returned by\n" +"repr() using \\\\x, \\\\u or \\\\U escapes. This generates a string similar\n" +"to that returned by repr() in Python 2."); + +#define BUILTIN_ASCII_METHODDEF \ + {"ascii", (PyCFunction)builtin_ascii, METH_O, builtin_ascii__doc__}, + +PyDoc_STRVAR(builtin_bin__doc__, +"bin($module, number, /)\n" +"--\n" +"\n" +"Return the binary representation of an integer.\n" +"\n" +" >>> bin(2796202)\n" +" \'0b1010101010101010101010\'"); + +#define BUILTIN_BIN_METHODDEF \ + {"bin", (PyCFunction)builtin_bin, METH_O, builtin_bin__doc__}, + +PyDoc_STRVAR(builtin_callable__doc__, +"callable($module, obj, /)\n" +"--\n" +"\n" +"Return whether the object is callable (i.e., some kind of function).\n" +"\n" +"Note that classes are callable, as are instances of classes with a\n" +"__call__() method."); + +#define BUILTIN_CALLABLE_METHODDEF \ + {"callable", (PyCFunction)builtin_callable, METH_O, builtin_callable__doc__}, + +PyDoc_STRVAR(builtin_format__doc__, +"format($module, value, format_spec=\'\', /)\n" +"--\n" +"\n" +"Return value.__format__(format_spec)\n" +"\n" +"format_spec defaults to the empty string"); + +#define BUILTIN_FORMAT_METHODDEF \ + {"format", (PyCFunction)builtin_format, METH_VARARGS, builtin_format__doc__}, + +static PyObject * +builtin_format_impl(PyModuleDef *module, PyObject *value, PyObject *format_spec); + +static PyObject * +builtin_format(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *value; + PyObject *format_spec = NULL; + + if (!PyArg_ParseTuple(args, + "O|U:format", + &value, &format_spec)) + goto exit; + return_value = builtin_format_impl(module, value, format_spec); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_chr__doc__, +"chr($module, i, /)\n" +"--\n" +"\n" +"Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff."); + +#define BUILTIN_CHR_METHODDEF \ + {"chr", (PyCFunction)builtin_chr, METH_VARARGS, builtin_chr__doc__}, + +static PyObject * +builtin_chr_impl(PyModuleDef *module, int i); + +static PyObject * +builtin_chr(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int i; + + if (!PyArg_ParseTuple(args, + "i:chr", + &i)) + goto exit; + return_value = builtin_chr_impl(module, i); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_compile__doc__, +"compile($module, /, source, filename, mode, flags=0, dont_inherit=0,\n" +" optimize=-1)\n" +"--\n" +"\n" +"Compile source into a code object that can be executed by exec() or eval().\n" +"\n" +"The source code may represent a Python module, statement or expression.\n" +"The filename will be used for run-time error messages.\n" +"The mode must be \'exec\' to compile a module, \'single\' to compile a\n" +"single (interactive) statement, or \'eval\' to compile an expression.\n" +"The flags argument, if present, controls which future statements influence\n" +"the compilation of the code.\n" +"The dont_inherit argument, if non-zero, stops the compilation inheriting\n" +"the effects of any future statements in effect in the code calling\n" +"compile; if absent or zero these statements do influence the compilation,\n" +"in addition to any features explicitly specified."); + +#define BUILTIN_COMPILE_METHODDEF \ + {"compile", (PyCFunction)builtin_compile, METH_VARARGS|METH_KEYWORDS, builtin_compile__doc__}, + +static PyObject * +builtin_compile_impl(PyModuleDef *module, PyObject *source, PyObject *filename, const char *mode, int flags, int dont_inherit, int optimize); + +static PyObject * +builtin_compile(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"source", "filename", "mode", "flags", "dont_inherit", "optimize", NULL}; + PyObject *source; + PyObject *filename; + const char *mode; + int flags = 0; + int dont_inherit = 0; + int optimize = -1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "OO&s|iii:compile", _keywords, + &source, PyUnicode_FSDecoder, &filename, &mode, &flags, &dont_inherit, &optimize)) + goto exit; + return_value = builtin_compile_impl(module, source, filename, mode, flags, dont_inherit, optimize); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_divmod__doc__, +"divmod($module, x, y, /)\n" +"--\n" +"\n" +"Return the tuple ((x-x%y)/y, x%y). Invariant: div*y + mod == x."); + +#define BUILTIN_DIVMOD_METHODDEF \ + {"divmod", (PyCFunction)builtin_divmod, METH_VARARGS, builtin_divmod__doc__}, + +static PyObject * +builtin_divmod_impl(PyModuleDef *module, PyObject *x, PyObject *y); + +static PyObject * +builtin_divmod(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *x; + PyObject *y; + + if (!PyArg_UnpackTuple(args, "divmod", + 2, 2, + &x, &y)) + goto exit; + return_value = builtin_divmod_impl(module, x, y); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_eval__doc__, +"eval($module, source, globals=None, locals=None, /)\n" +"--\n" +"\n" +"Evaluate the given source in the context of globals and locals.\n" +"\n" +"The source may be a string representing a Python expression\n" +"or a code object as returned by compile().\n" +"The globals must be a dictionary and locals can be any mapping,\n" +"defaulting to the current globals and locals.\n" +"If only globals is given, locals defaults to it."); + +#define BUILTIN_EVAL_METHODDEF \ + {"eval", (PyCFunction)builtin_eval, METH_VARARGS, builtin_eval__doc__}, + +static PyObject * +builtin_eval_impl(PyModuleDef *module, PyObject *source, PyObject *globals, PyObject *locals); + +static PyObject * +builtin_eval(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *source; + PyObject *globals = Py_None; + PyObject *locals = Py_None; + + if (!PyArg_UnpackTuple(args, "eval", + 1, 3, + &source, &globals, &locals)) + goto exit; + return_value = builtin_eval_impl(module, source, globals, locals); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_exec__doc__, +"exec($module, source, globals=None, locals=None, /)\n" +"--\n" +"\n" +"Execute the given source in the context of globals and locals.\n" +"\n" +"The source may be a string representing one or more Python statements\n" +"or a code object as returned by compile().\n" +"The globals must be a dictionary and locals can be any mapping,\n" +"defaulting to the current globals and locals.\n" +"If only globals is given, locals defaults to it."); + +#define BUILTIN_EXEC_METHODDEF \ + {"exec", (PyCFunction)builtin_exec, METH_VARARGS, builtin_exec__doc__}, + +static PyObject * +builtin_exec_impl(PyModuleDef *module, PyObject *source, PyObject *globals, PyObject *locals); + +static PyObject * +builtin_exec(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *source; + PyObject *globals = Py_None; + PyObject *locals = Py_None; + + if (!PyArg_UnpackTuple(args, "exec", + 1, 3, + &source, &globals, &locals)) + goto exit; + return_value = builtin_exec_impl(module, source, globals, locals); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_globals__doc__, +"globals($module, /)\n" +"--\n" +"\n" +"Return the dictionary containing the current scope\'s global variables.\n" +"\n" +"NOTE: Updates to this dictionary *will* affect name lookups in the current\n" +"global scope and vice-versa."); + +#define BUILTIN_GLOBALS_METHODDEF \ + {"globals", (PyCFunction)builtin_globals, METH_NOARGS, builtin_globals__doc__}, + +static PyObject * +builtin_globals_impl(PyModuleDef *module); + +static PyObject * +builtin_globals(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return builtin_globals_impl(module); +} + +PyDoc_STRVAR(builtin_hasattr__doc__, +"hasattr($module, obj, name, /)\n" +"--\n" +"\n" +"Return whether the object has an attribute with the given name.\n" +"\n" +"This is done by calling getattr(obj, name) and catching AttributeError."); + +#define BUILTIN_HASATTR_METHODDEF \ + {"hasattr", (PyCFunction)builtin_hasattr, METH_VARARGS, builtin_hasattr__doc__}, + +static PyObject * +builtin_hasattr_impl(PyModuleDef *module, PyObject *obj, PyObject *name); + +static PyObject * +builtin_hasattr(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *obj; + PyObject *name; + + if (!PyArg_UnpackTuple(args, "hasattr", + 2, 2, + &obj, &name)) + goto exit; + return_value = builtin_hasattr_impl(module, obj, name); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_id__doc__, +"id($module, obj, /)\n" +"--\n" +"\n" +"Return the identity of an object.\n" +"\n" +"This is guaranteed to be unique among simultaneously existing objects.\n" +"(CPython uses the object\'s memory address.)"); + +#define BUILTIN_ID_METHODDEF \ + {"id", (PyCFunction)builtin_id, METH_O, builtin_id__doc__}, + +PyDoc_STRVAR(builtin_setattr__doc__, +"setattr($module, obj, name, value, /)\n" +"--\n" +"\n" +"Sets the named attribute on the given object to the specified value.\n" +"\n" +"setattr(x, \'y\', v) is equivalent to ``x.y = v\'\'"); + +#define BUILTIN_SETATTR_METHODDEF \ + {"setattr", (PyCFunction)builtin_setattr, METH_VARARGS, builtin_setattr__doc__}, + +static PyObject * +builtin_setattr_impl(PyModuleDef *module, PyObject *obj, PyObject *name, PyObject *value); + +static PyObject * +builtin_setattr(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *obj; + PyObject *name; + PyObject *value; + + if (!PyArg_UnpackTuple(args, "setattr", + 3, 3, + &obj, &name, &value)) + goto exit; + return_value = builtin_setattr_impl(module, obj, name, value); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_delattr__doc__, +"delattr($module, obj, name, /)\n" +"--\n" +"\n" +"Deletes the named attribute from the given object.\n" +"\n" +"delattr(x, \'y\') is equivalent to ``del x.y\'\'"); + +#define BUILTIN_DELATTR_METHODDEF \ + {"delattr", (PyCFunction)builtin_delattr, METH_VARARGS, builtin_delattr__doc__}, + +static PyObject * +builtin_delattr_impl(PyModuleDef *module, PyObject *obj, PyObject *name); + +static PyObject * +builtin_delattr(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *obj; + PyObject *name; + + if (!PyArg_UnpackTuple(args, "delattr", + 2, 2, + &obj, &name)) + goto exit; + return_value = builtin_delattr_impl(module, obj, name); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_hash__doc__, +"hash($module, obj, /)\n" +"--\n" +"\n" +"Return the hash value for the given object.\n" +"\n" +"Two objects that compare equal must also have the same hash value, but the\n" +"reverse is not necessarily true."); + +#define BUILTIN_HASH_METHODDEF \ + {"hash", (PyCFunction)builtin_hash, METH_O, builtin_hash__doc__}, + +PyDoc_STRVAR(builtin_hex__doc__, +"hex($module, number, /)\n" +"--\n" +"\n" +"Return the hexadecimal representation of an integer.\n" +"\n" +" >>> hex(12648430)\n" +" \'0xc0ffee\'"); + +#define BUILTIN_HEX_METHODDEF \ + {"hex", (PyCFunction)builtin_hex, METH_O, builtin_hex__doc__}, + +PyDoc_STRVAR(builtin_len__doc__, +"len($module, obj, /)\n" +"--\n" +"\n" +"Return the number of items in a container."); + +#define BUILTIN_LEN_METHODDEF \ + {"len", (PyCFunction)builtin_len, METH_O, builtin_len__doc__}, + +PyDoc_STRVAR(builtin_locals__doc__, +"locals($module, /)\n" +"--\n" +"\n" +"Return a dictionary containing the current scope\'s local variables.\n" +"\n" +"NOTE: Whether or not updates to this dictionary will affect name lookups in\n" +"the local scope and vice-versa is *implementation dependent* and not\n" +"covered by any backwards compatibility guarantees."); + +#define BUILTIN_LOCALS_METHODDEF \ + {"locals", (PyCFunction)builtin_locals, METH_NOARGS, builtin_locals__doc__}, + +static PyObject * +builtin_locals_impl(PyModuleDef *module); + +static PyObject * +builtin_locals(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return builtin_locals_impl(module); +} + +PyDoc_STRVAR(builtin_oct__doc__, +"oct($module, number, /)\n" +"--\n" +"\n" +"Return the octal representation of an integer.\n" +"\n" +" >>> oct(342391)\n" +" \'0o1234567\'"); + +#define BUILTIN_OCT_METHODDEF \ + {"oct", (PyCFunction)builtin_oct, METH_O, builtin_oct__doc__}, + +PyDoc_STRVAR(builtin_ord__doc__, +"ord($module, c, /)\n" +"--\n" +"\n" +"Return the Unicode code point for a one-character string."); + +#define BUILTIN_ORD_METHODDEF \ + {"ord", (PyCFunction)builtin_ord, METH_O, builtin_ord__doc__}, + +PyDoc_STRVAR(builtin_pow__doc__, +"pow($module, x, y, z=None, /)\n" +"--\n" +"\n" +"Equivalent to x**y (with two arguments) or x**y % z (with three arguments)\n" +"\n" +"Some types, such as ints, are able to use a more efficient algorithm when\n" +"invoked using the three argument form."); + +#define BUILTIN_POW_METHODDEF \ + {"pow", (PyCFunction)builtin_pow, METH_VARARGS, builtin_pow__doc__}, + +static PyObject * +builtin_pow_impl(PyModuleDef *module, PyObject *x, PyObject *y, PyObject *z); + +static PyObject * +builtin_pow(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *x; + PyObject *y; + PyObject *z = Py_None; + + if (!PyArg_UnpackTuple(args, "pow", + 2, 3, + &x, &y, &z)) + goto exit; + return_value = builtin_pow_impl(module, x, y, z); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_input__doc__, +"input($module, prompt=None, /)\n" +"--\n" +"\n" +"Read a string from standard input. The trailing newline is stripped.\n" +"\n" +"The prompt string, if given, is printed to standard output without a\n" +"trailing newline before reading input.\n" +"\n" +"If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.\n" +"On *nix systems, readline is used if available."); + +#define BUILTIN_INPUT_METHODDEF \ + {"input", (PyCFunction)builtin_input, METH_VARARGS, builtin_input__doc__}, + +static PyObject * +builtin_input_impl(PyModuleDef *module, PyObject *prompt); + +static PyObject * +builtin_input(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *prompt = NULL; + + if (!PyArg_UnpackTuple(args, "input", + 0, 1, + &prompt)) + goto exit; + return_value = builtin_input_impl(module, prompt); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_repr__doc__, +"repr($module, obj, /)\n" +"--\n" +"\n" +"Return the canonical string representation of the object.\n" +"\n" +"For many object types, including most builtins, eval(repr(obj)) == obj."); + +#define BUILTIN_REPR_METHODDEF \ + {"repr", (PyCFunction)builtin_repr, METH_O, builtin_repr__doc__}, + +PyDoc_STRVAR(builtin_sum__doc__, +"sum($module, iterable, start=0, /)\n" +"--\n" +"\n" +"Return the sum of a \'start\' value (default: 0) plus an iterable of numbers\n" +"\n" +"When the iterable is empty, return the start value.\n" +"This function is intended specifically for use with numeric values and may\n" +"reject non-numeric types."); + +#define BUILTIN_SUM_METHODDEF \ + {"sum", (PyCFunction)builtin_sum, METH_VARARGS, builtin_sum__doc__}, + +static PyObject * +builtin_sum_impl(PyModuleDef *module, PyObject *iterable, PyObject *start); + +static PyObject * +builtin_sum(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *iterable; + PyObject *start = NULL; + + if (!PyArg_UnpackTuple(args, "sum", + 1, 2, + &iterable, &start)) + goto exit; + return_value = builtin_sum_impl(module, iterable, start); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_isinstance__doc__, +"isinstance($module, obj, class_or_tuple, /)\n" +"--\n" +"\n" +"Return whether an object is an instance of a class or of a subclass thereof.\n" +"\n" +"A tuple, as in ``isinstance(x, (A, B, ...))``, may be given as the target to\n" +"check against. This is equivalent to ``isinstance(x, A) or isinstance(x, B)\n" +"or ...`` etc."); + +#define BUILTIN_ISINSTANCE_METHODDEF \ + {"isinstance", (PyCFunction)builtin_isinstance, METH_VARARGS, builtin_isinstance__doc__}, + +static PyObject * +builtin_isinstance_impl(PyModuleDef *module, PyObject *obj, PyObject *class_or_tuple); + +static PyObject * +builtin_isinstance(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *obj; + PyObject *class_or_tuple; + + if (!PyArg_UnpackTuple(args, "isinstance", + 2, 2, + &obj, &class_or_tuple)) + goto exit; + return_value = builtin_isinstance_impl(module, obj, class_or_tuple); + +exit: + return return_value; +} + +PyDoc_STRVAR(builtin_issubclass__doc__, +"issubclass($module, cls, class_or_tuple, /)\n" +"--\n" +"\n" +"Return whether \'cls\' is a derived from another class or is the same class.\n" +"\n" +"A tuple, as in ``issubclass(x, (A, B, ...))``, may be given as the target to\n" +"check against. This is equivalent to ``issubclass(x, A) or issubclass(x, B)\n" +"or ...`` etc."); + +#define BUILTIN_ISSUBCLASS_METHODDEF \ + {"issubclass", (PyCFunction)builtin_issubclass, METH_VARARGS, builtin_issubclass__doc__}, + +static PyObject * +builtin_issubclass_impl(PyModuleDef *module, PyObject *cls, PyObject *class_or_tuple); + +static PyObject * +builtin_issubclass(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *cls; + PyObject *class_or_tuple; + + if (!PyArg_UnpackTuple(args, "issubclass", + 2, 2, + &cls, &class_or_tuple)) + goto exit; + return_value = builtin_issubclass_impl(module, cls, class_or_tuple); + +exit: + return return_value; +} +/*[clinic end generated code: output=2da46de189e48d26 input=a9049054013a1b77]*/ diff -r a824c40e8fc0 Tools/clinic/clinic.py --- a/Tools/clinic/clinic.py Sat Feb 21 15:26:02 2015 -0800 +++ b/Tools/clinic/clinic.py Sun Feb 22 11:52:48 2015 +0200 @@ -1561,15 +1561,15 @@ impl_definition block d = self.destinations.get self.field_destinations = collections.OrderedDict(( - ('cpp_if', d('suppress')), + ('cpp_if', d('file')), ('docstring_prototype', d('suppress')), - ('docstring_definition', d('block')), - ('methoddef_define', d('block')), - ('impl_prototype', d('block')), + ('docstring_definition', d('file')), + ('methoddef_define', d('file')), + ('impl_prototype', d('file')), ('parser_prototype', d('suppress')), - ('parser_definition', d('block')), - ('cpp_endif', d('suppress')), - ('methoddef_ifndef', d('buffer')), + ('parser_definition', d('file')), + ('cpp_endif', d('file')), + ('methoddef_ifndef', d('file')), ('impl_definition', d('block')), ))