diff --git a/Doc/howto/clinic.rst b/Doc/howto/clinic.rst --- a/Doc/howto/clinic.rst +++ b/Doc/howto/clinic.rst @@ -35,12 +35,12 @@ Argument Clinic will scan over the file looking for lines that look exactly like this:: - /*[clinic] + /*[clinic input] When it finds one, it reads everything up to a line that looks -like this:: +exactly like this:: - [clinic]*/ + [clinic start generated code]*/ Everything in between these two lines is input for Argument Clinic. All of these lines, including the beginning and ending comment @@ -51,11 +51,11 @@ immediately after the block, followed by a comment containing a checksum. The Argument Clinic block now looks like this:: - /*[clinic] + /*[clinic input] ... clinic input goes here ... - [clinic]*/ + [clinic start generated code]*/ ... clinic output goes here ... - /*[clinic checksum:...]*/ + /*[clinic end generated code: checksum=...]*/ If you run Argument Clinic on the same file a second time, Argument Clinic will discard the old output and write out the new output with a fresh checksum @@ -68,9 +68,9 @@ For the sake of clarity, here's the terminology we'll use with Argument Clinic: -* The first line of the comment (``/*[clinic]``) is the *start line*. -* The last line of the initial comment (``[clinic]*/``) is the *end line*. -* The last line (``/*[clinic checksum:...]*/``) is the *checksum line*. +* The first line of the comment (``/*[clinic input]``) is the *start line*. +* The last line of the initial comment (``[clinic start generated code]*/``) is the *end line*. +* The last line (``/*[clinic end generated code: checksum=...]*/``) is the *checksum line*. * In between the start line and the end line is the *input*. * In between the end line and the checksum line is the *output*. * All the text collectively, from the start line to the checksum line inclusively, @@ -111,8 +111,8 @@ 3. Add the following boilerplate above the function, creating our block:: - /*[clinic] - [clinic]*/ + /*[clinic input] + [clinic start generated code]*/ 4. Cut the docstring and paste it in between the ``[clinic]`` lines, removing all the junk that makes it a properly quoted C string. @@ -122,9 +122,9 @@ Sample:: - /*[clinic] + /*[clinic input] Write a pickled representation of obj to the open file. - [clinic]*/ + [clinic start generated code]*/ 5. If your docstring doesn't have a "summary" line, Argument Clinic will complain. So let's make sure it has one. The "summary" line should @@ -143,11 +143,11 @@ Sample:: - /*[clinic] + /*[clinic input] pickle.Pickler.dump Write a pickled representation of obj to the open file. - [clinic]*/ + [clinic start generated code]*/ 7. If this is the first time that module or class has been used with Argument Clinic in this C file, @@ -159,16 +159,16 @@ Sample:: - /*[clinic] + /*[clinic input] module pickle class pickle.Pickler - [clinic]*/ + [clinic start generated code]*/ - /*[clinic] + /*[clinic input] pickle.Pickler.dump Write a pickled representation of obj to the open file. - [clinic]*/ + [clinic start generated code]*/ 8. Declare each of the parameters to the function. Each parameter @@ -207,18 +207,18 @@ Sample:: - /*[clinic] + /*[clinic input] module pickle class pickle.Pickler - [clinic]*/ + [clinic start generated code]*/ - /*[clinic] + /*[clinic input] pickle.Pickler.dump obj: 'O' Write a pickled representation of obj to the open file. - [clinic]*/ + [clinic start generated code]*/ 9. If your function has ``|`` in the format string, meaning some parameters have default values, you can ignore it. Argument @@ -247,19 +247,19 @@ Sample:: - /*[clinic] + /*[clinic input] module pickle class pickle.Pickler - [clinic]*/ + [clinic start generated code]*/ - /*[clinic] + /*[clinic input] pickle.Pickler.dump obj: 'O' / Write a pickled representation of obj to the open file. - [clinic]*/ + [clinic start generated code]*/ 11. It's helpful to write a per-parameter docstring for each parameter. But per-parameter docstrings are optional; you can skip this step @@ -274,12 +274,12 @@ Sample:: - /*[clinic] + /*[clinic input] module pickle class pickle.Pickler - [clinic]*/ + [clinic start generated code]*/ - /*[clinic] + /*[clinic input] pickle.Pickler.dump obj: 'O' @@ -287,19 +287,19 @@ / Write a pickled representation of obj to the open file. - [clinic]*/ + [clinic start generated code]*/ 12. Save and close the file, then run ``Tools/clinic/clinic.py`` on it. With luck everything worked and your block now has output! Reopen the file in your text editor to see:: - /*[clinic] + /*[clinic input] module pickle class pickle.Pickler - [clinic]*/ - /*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ + [clinic start generated code]*/ + /*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ - /*[clinic] + /*[clinic input] pickle.Pickler.dump obj: 'O' @@ -307,7 +307,7 @@ / Write a pickled representation of obj to the open file. - [clinic]*/ + [clinic start generated code]*/ PyDoc_STRVAR(pickle_Pickler_dump__doc__, "Write a pickled representation of obj to the open file.\n" @@ -315,7 +315,7 @@ ... static PyObject * pickle_Pickler_dump_impl(PyObject *self, PyObject *obj) - /*[clinic checksum: 3bd30745bf206a48f8b576a1da3d90f55a0a4187]*/ + /*[clinic end generated code: checksum=3bd30745bf206a48f8b576a1da3d90f55a0a4187]*/ Obviously, if Argument Clinic didn't produce any output, it's because it found an error in your input. Keep fixing your errors and retrying @@ -373,7 +373,7 @@ static return_type your_function_impl(...) - /*[clinic checksum: ...]*/ + /*[clinic end generated code: checksum=...]*/ { ... @@ -383,13 +383,13 @@ Sample:: - /*[clinic] + /*[clinic input] module pickle class pickle.Pickler - [clinic]*/ - /*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ + [clinic start generated code]*/ + /*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ - /*[clinic] + /*[clinic input] pickle.Pickler.dump obj: 'O' @@ -397,7 +397,7 @@ / Write a pickled representation of obj to the open file. - [clinic]*/ + [clinic start generated code]*/ PyDoc_STRVAR(pickle_Pickler_dump__doc__, "Write a pickled representation of obj to the open file.\n" @@ -405,7 +405,7 @@ ... static PyObject * pickle_Pickler_dump_impl(PyObject *self, PyObject *obj) - /*[clinic checksum: 3bd30745bf206a48f8b576a1da3d90f55a0a4187]*/ + /*[clinic end generated code: checksum=3bd30745bf206a48f8b576a1da3d90f55a0a4187]*/ { /* Check whether the Pickler was initialized correctly (issue3664). Developers often forget to call __init__() in their subclasses, which @@ -470,7 +470,7 @@ For example, if we wanted to rename the C function names generated for ``pickle.Pickler.dump``, it'd look like this:: - /*[clinic] + /*[clinic input] pickle.Pickler.dump as pickler_dumper ... @@ -515,7 +515,7 @@ uses optional groups to make the first two parameters and the last parameter optional:: - /*[clinic] + /*[clinic input] curses.window.addch @@ -666,7 +666,7 @@ As an example, here's our sample ``pickle.Pickler.dump`` using the proper converter:: - /*[clinic] + /*[clinic input] pickle.Pickler.dump obj: object @@ -674,7 +674,7 @@ / Write a pickled representation of obj to the open file. - [clinic]*/ + [clinic start generated code]*/ Argument Clinic will show you all the converters it has available. For each converter it'll show you all the parameters @@ -767,9 +767,9 @@ A Python block uses different delimiter lines than an Argument Clinic function block. It looks like this:: - /*[python] + /*[python input] # python code goes here - [python]*/ + [python start generated code]*/ All the code inside the Python block is executed at the time it's parsed. All text written to stdout inside the block @@ -778,9 +778,9 @@ As an example, here's a Python block that adds a static integer variable to the C code:: - /*[python] + /*[python input] print('static int __ignored_unused_variable__ = 0;') - [python]*/ + [python start generated code]*/ static int __ignored_unused_variable__ = 0; /*[python checksum:...]*/ @@ -803,7 +803,7 @@ you can directly use Argument Clinic's existing ``self`` converter, passing in the type you want to use as the ``type`` parameter:: - /*[clinic] + /*[clinic input] _pickle.Pickler.dump @@ -812,18 +812,18 @@ / Write a pickled representation of the given object to the open file. - [clinic]*/ + [clinic start generated code]*/ On the other hand, if you have a lot of functions that will use the same type for ``self``, it's best to create your own converter, subclassing ``self_converter`` but overwriting the ``type`` member:: - /*[clinic] + /*[clinic input] class PicklerObject_converter(self_converter): type = "PicklerObject *" - [clinic]*/ + [clinic start generated code]*/ - /*[clinic] + /*[clinic input] _pickle.Pickler.dump @@ -832,7 +832,7 @@ / Write a pickled representation of the given object to the open file. - [clinic]*/ + [clinic start generated code]*/ @@ -914,14 +914,14 @@ Here's the simplest example of a custom converter, from ``Modules/zlibmodule.c``:: - /*[python] + /*[python input] class uint_converter(CConverter): type = 'unsigned int' converter = 'uint_converter' - [python]*/ - /*[python checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ + [python start generated code]*/ + /*[python end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ This block adds a converter to Argument Clinic named ``uint``. Parameters declared as ``uint`` will be declared as type ``unsigned int``, and will @@ -960,8 +960,8 @@ Since Python comments are different from C comments, Argument Clinic blocks embedded in Python files look slightly different. They look like this:: - #/*[python] + #/*[python input] #print("def foo(): pass") - #[python]*/ + #[python start generated code]*/ def foo(): pass #/*[python checksum:...]*/ diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -134,11 +134,11 @@ #define STRICT_SYSV_CURSES #endif -/*[clinic] +/*[clinic input] module curses class curses.window -[clinic]*/ -/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ /* Definition of exception curses.error */ @@ -555,7 +555,7 @@ /* Addch, Addstr, Addnstr */ -/*[clinic] +/*[clinic input] curses.window.addch @@ -581,7 +581,7 @@ overwriting any character previously painted at that location. By default, the character position and attributes are the current settings for the window object. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(curses_window_addch__doc__, "addch([x, y,] ch, [attr])\n" @@ -650,7 +650,7 @@ static PyObject * curses_window_addch_impl(PyObject *self, int group_left_1, int x, int y, PyObject *ch, int group_right_1, long attr) -/*[clinic checksum: 44ed958b891cde91205e584c766e048f3999714f]*/ +/*[clinic end generated code: checksum=44ed958b891cde91205e584c766e048f3999714f]*/ { PyCursesWindowObject *cwself = (PyCursesWindowObject *)self; int coordinates_group = group_left_1; diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -16,11 +16,11 @@ #include "datetime.h" #undef Py_BUILD_CORE -/*[clinic] +/*[clinic input] module datetime class datetime.datetime -[clinic]*/ -/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ /* 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 @@ -4145,7 +4145,7 @@ tzinfo); } -/*[clinic] +/*[clinic input] @classmethod datetime.datetime.now @@ -4156,7 +4156,7 @@ Returns new datetime object representing current time local to tz. If no tz is specified, uses local timezone. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(datetime_datetime_now__doc__, "now(tz=None)\n" @@ -4192,7 +4192,7 @@ static PyObject * datetime_datetime_now_impl(PyTypeObject *cls, PyObject *tz) -/*[clinic checksum: ca3d26a423b3f633b260c7622e303f0915a96f7c]*/ +/*[clinic end generated code: checksum=ca3d26a423b3f633b260c7622e303f0915a96f7c]*/ { PyObject *self; diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c --- a/Modules/_dbmmodule.c +++ b/Modules/_dbmmodule.c @@ -28,11 +28,11 @@ #error "No ndbm.h available!" #endif -/*[clinic] +/*[clinic input] module dbm class dbm.dbm -[clinic]*/ -/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ typedef struct { PyObject_HEAD @@ -49,13 +49,13 @@ static PyObject *DbmError; -/*[python] +/*[python input] class dbmobject_converter(self_converter): type = "dbmobject *" def converter_init(self): self.name = 'dp' -[python]*/ -/*[python checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[python start generated code]*/ +/*[python end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ static PyObject * newdbmobject(const char *file, int flags, int mode) @@ -263,7 +263,7 @@ 0, /* sq_inplace_repeat */ }; -/*[clinic] +/*[clinic input] dbm.dbm.get @@ -276,7 +276,7 @@ / Return the value for key if present, otherwise default. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(dbm_dbm_get__doc__, "get(key, [default])\n" @@ -318,7 +318,7 @@ static PyObject * dbm_dbm_get_impl(dbmobject *dp, const char *key, Py_ssize_clean_t key_length, int group_right_1, PyObject *default_value) -/*[clinic checksum: 28cf8928811bde51e535d67ae98ea039d79df717]*/ +/*[clinic end generated code: checksum=28cf8928811bde51e535d67ae98ea039d79df717]*/ { datum dbm_key, val; @@ -440,7 +440,7 @@ /* ----------------------------------------------------------------- */ -/*[clinic] +/*[clinic input] dbm.open as dbmopen @@ -458,7 +458,7 @@ Return a database object. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(dbmopen__doc__, "open(filename, flags=\'r\', mode=0o666)\n" @@ -498,7 +498,7 @@ static PyObject * dbmopen_impl(PyModuleDef *module, const char *filename, const char *flags, int mode) -/*[clinic checksum: fb265f75641553ccd963f84c143b35c11f9121fc]*/ +/*[clinic end generated code: checksum=fb265f75641553ccd963f84c143b35c11f9121fc]*/ { int iflags; diff --git a/Modules/_opcode.c b/Modules/_opcode.c --- a/Modules/_opcode.c +++ b/Modules/_opcode.c @@ -1,12 +1,12 @@ #include "Python.h" #include "opcode.h" -/*[clinic] +/*[clinic input] module _opcode -[clinic]*/ -/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ -/*[clinic] +/*[clinic input] _opcode.stack_effect -> int @@ -18,7 +18,7 @@ / Compute the stack effect of the opcode. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_opcode_stack_effect__doc__, "stack_effect(opcode, [oparg])\n" @@ -64,10 +64,10 @@ static int _opcode_stack_effect_impl(PyModuleDef *module, int opcode, int group_right_1, int oparg) -/*[clinic checksum: e880e62dc7b0de73403026eaf4f8074aa106358b]*/ +/*[clinic end generated code: checksum=e880e62dc7b0de73403026eaf4f8074aa106358b]*/ { int effect; - if (HAS_ARG(opcode)) { + if (HAS_ARG(opcode)) { if (!group_right_1) { PyErr_SetString(PyExc_ValueError, "stack_effect: opcode requires oparg but oparg was not specified"); diff --git a/Modules/_pickle.c b/Modules/_pickle.c --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -4,16 +4,16 @@ PyDoc_STRVAR(pickle_module_doc, "Optimized C implementation for the Python pickle module."); -/*[clinic] +/*[clinic input] module _pickle class _pickle.Pickler class _pickle.PicklerMemoProxy class _pickle.Unpickler class _pickle.UnpicklerMemoProxy -[clinic]*/ -/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ - -/*[python] +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ + +/*[python input] class PicklerObject_converter(self_converter): type = "PicklerObject *" @@ -25,8 +25,8 @@ class UnpicklerMemoProxyObject_converter(self_converter): type = "UnpicklerMemoProxyObject *" -[python]*/ -/*[python checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[python start generated code]*/ +/*[python end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ /* Bump this when new opcodes are added to the pickle protocol. */ enum { @@ -140,7 +140,7 @@ PyObject *PickleError; PyObject *PicklingError; PyObject *UnpicklingError; - + /* copyreg.dispatch_table, {type_object: pickling_function} */ PyObject *dispatch_table; @@ -1770,7 +1770,7 @@ else if (self->bin && (sizeof(long) <= 4 || (val <= 0x7fffffffL && val >= (-0x7fffffffL - 1)))) { - /* result fits in a signed 4-byte integer. + /* result fits in a signed 4-byte integer. Note: we can't use -0x80000000L in the above condition because some compilers (e.g., MSVC) will promote 0x80000000L to an unsigned type @@ -3492,21 +3492,21 @@ cls = PyTuple_GET_ITEM(argtup, 0); if (!PyType_Check(cls)) { - PyErr_Format(st->PicklingError, + PyErr_Format(st->PicklingError, "first item from NEWOBJ_EX argument tuple must " "be a class, not %.200s", Py_TYPE(cls)->tp_name); return -1; } args = PyTuple_GET_ITEM(argtup, 1); if (!PyTuple_Check(args)) { - PyErr_Format(st->PicklingError, + PyErr_Format(st->PicklingError, "second item from NEWOBJ_EX argument tuple must " "be a tuple, not %.200s", Py_TYPE(args)->tp_name); return -1; } kwargs = PyTuple_GET_ITEM(argtup, 2); if (!PyDict_Check(kwargs)) { - PyErr_Format(st->PicklingError, + PyErr_Format(st->PicklingError, "third item from NEWOBJ_EX argument tuple must " "be a dict, not %.200s", Py_TYPE(kwargs)->tp_name); return -1; @@ -3874,7 +3874,7 @@ return 0; } -/*[clinic] +/*[clinic input] _pickle.Pickler.clear_memo @@ -3886,7 +3886,7 @@ pickler has already seen, so that shared or recursive objects are pickled by reference and not by value. This method is useful when re-using picklers. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_Pickler_clear_memo__doc__, "clear_memo()\n" @@ -3915,7 +3915,7 @@ static PyObject * _pickle_Pickler_clear_memo_impl(PicklerObject *self) -/*[clinic checksum: 0574593b102fffb8e781d7bb9b536ceffc525ac1]*/ +/*[clinic end generated code: checksum=0574593b102fffb8e781d7bb9b536ceffc525ac1]*/ { if (self->memo) PyMemoTable_Clear(self->memo); @@ -3923,7 +3923,7 @@ Py_RETURN_NONE; } -/*[clinic] +/*[clinic input] _pickle.Pickler.dump @@ -3932,7 +3932,7 @@ / Write a pickled representation of the given object to the open file. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_Pickler_dump__doc__, "dump(obj)\n" @@ -3943,7 +3943,7 @@ static PyObject * _pickle_Pickler_dump(PicklerObject *self, PyObject *obj) -/*[clinic checksum: b72a69ec98737fabf66dae7c5a3210178bdbd3e6]*/ +/*[clinic end generated code: checksum=b72a69ec98737fabf66dae7c5a3210178bdbd3e6]*/ { /* Check whether the Pickler was initialized correctly (issue3664). Developers often forget to call __init__() in their subclasses, which @@ -4018,7 +4018,7 @@ } -/*[clinic] +/*[clinic input] _pickle.Pickler.__init__ @@ -4045,7 +4045,7 @@ If *fix_imports* is True and protocol is less than 3, pickle will try to map the new Python 3 names to the old module names used in Python 2, so that the pickle data stream is readable with Python 2. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_Pickler___init____doc__, "__init__(file, protocol=None, fix_imports=True)\n" @@ -4095,7 +4095,7 @@ static PyObject * _pickle_Pickler___init___impl(PicklerObject *self, PyObject *file, PyObject *protocol, int fix_imports) -/*[clinic checksum: 2b5ce6452544600478cf9f4b701ab9d9b5efbab9]*/ +/*[clinic end generated code: checksum=2b5ce6452544600478cf9f4b701ab9d9b5efbab9]*/ { _Py_IDENTIFIER(persistent_id); _Py_IDENTIFIER(dispatch_table); @@ -4173,13 +4173,13 @@ PicklerObject *pickler; /* Pickler whose memo table we're proxying. */ } PicklerMemoProxyObject; -/*[clinic] +/*[clinic input] _pickle.PicklerMemoProxy.clear self: PicklerMemoProxyObject Remove all items from memo. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_PicklerMemoProxy_clear__doc__, "clear()\n" @@ -4203,20 +4203,20 @@ static PyObject * _pickle_PicklerMemoProxy_clear_impl(PicklerMemoProxyObject *self) -/*[clinic checksum: c6ca252530ccb3ea2f4b33507b51b183f23b24c7]*/ +/*[clinic end generated code: checksum=c6ca252530ccb3ea2f4b33507b51b183f23b24c7]*/ { if (self->pickler->memo) PyMemoTable_Clear(self->pickler->memo); Py_RETURN_NONE; } -/*[clinic] +/*[clinic input] _pickle.PicklerMemoProxy.copy self: PicklerMemoProxyObject Copy the memo to a new object. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_PicklerMemoProxy_copy__doc__, "copy()\n" @@ -4240,7 +4240,7 @@ static PyObject * _pickle_PicklerMemoProxy_copy_impl(PicklerMemoProxyObject *self) -/*[clinic checksum: 808c4d5a37359ed5fb2efe81dbe5ff480719f470]*/ +/*[clinic end generated code: checksum=808c4d5a37359ed5fb2efe81dbe5ff480719f470]*/ { Py_ssize_t i; PyMemoTable *memo; @@ -4277,13 +4277,13 @@ return NULL; } -/*[clinic] +/*[clinic input] _pickle.PicklerMemoProxy.__reduce__ self: PicklerMemoProxyObject Implement pickle support. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_PicklerMemoProxy___reduce____doc__, "__reduce__()\n" @@ -4307,7 +4307,7 @@ static PyObject * _pickle_PicklerMemoProxy___reduce___impl(PicklerMemoProxyObject *self) -/*[clinic checksum: 2293152bdf53951a012d430767b608f5fb4213b5]*/ +/*[clinic end generated code: checksum=2293152bdf53951a012d430767b608f5fb4213b5]*/ { PyObject *reduce_value, *dict_args; PyObject *contents = _pickle_PicklerMemoProxy_copy_impl(self); @@ -5348,12 +5348,12 @@ Py_DECREF(args); return -1; } - + if (!PyType_Check(cls)) { Py_DECREF(kwargs); Py_DECREF(args); Py_DECREF(cls); - PyErr_Format(st->UnpicklingError, + PyErr_Format(st->UnpicklingError, "NEWOBJ_EX class argument must be a type, not %.200s", Py_TYPE(cls)->tp_name); return -1; @@ -6317,7 +6317,7 @@ return value; } -/*[clinic] +/*[clinic input] _pickle.Unpickler.load @@ -6326,7 +6326,7 @@ Read a pickled object representation from the open file object given in the constructor, and return the reconstituted object hierarchy specified therein. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_Unpickler_load__doc__, "load()\n" @@ -6354,7 +6354,7 @@ static PyObject * _pickle_Unpickler_load_impl(PyObject *self) -/*[clinic checksum: 55f35fcaf034817e75c355ec50b7878577355899]*/ +/*[clinic end generated code: checksum=55f35fcaf034817e75c355ec50b7878577355899]*/ { UnpicklerObject *unpickler = (UnpicklerObject*)self; @@ -6377,7 +6377,7 @@ function is used for loading any global (i.e., functions), not just classes. The name is kept only for backward compatibility. */ -/*[clinic] +/*[clinic input] _pickle.Unpickler.find_class @@ -6394,7 +6394,7 @@ This method is called whenever a class or a function object is needed. Both arguments passed are str objects. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_Unpickler_find_class__doc__, "find_class(module_name, global_name)\n" @@ -6432,7 +6432,7 @@ static PyObject * _pickle_Unpickler_find_class_impl(UnpicklerObject *self, PyObject *module_name, PyObject *global_name) -/*[clinic checksum: 1f353d13a32c9d94feb1466b3c2d0529a7e5650e]*/ +/*[clinic end generated code: checksum=1f353d13a32c9d94feb1466b3c2d0529a7e5650e]*/ { PyObject *global; PyObject *modules_dict; @@ -6581,7 +6581,7 @@ return 0; } -/*[clinic] +/*[clinic input] _pickle.Unpickler.__init__ @@ -6612,7 +6612,7 @@ instances pickled by Python 2; these default to 'ASCII' and 'strict', respectively. The *encoding* can be 'bytes' to read these 8-bit string instances as bytes objects. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_Unpickler___init____doc__, "__init__(file, *, fix_imports=True, encoding=\'ASCII\', errors=\'strict\')\n" @@ -6665,7 +6665,7 @@ static PyObject * _pickle_Unpickler___init___impl(UnpicklerObject *self, PyObject *file, int fix_imports, const char *encoding, const char *errors) -/*[clinic checksum: 9ce6783224e220573d42a94fe1bb7199d6f1c5a6]*/ +/*[clinic end generated code: checksum=9ce6783224e220573d42a94fe1bb7199d6f1c5a6]*/ { _Py_IDENTIFIER(persistent_load); @@ -6737,13 +6737,13 @@ UnpicklerObject *unpickler; } UnpicklerMemoProxyObject; -/*[clinic] +/*[clinic input] _pickle.UnpicklerMemoProxy.clear self: UnpicklerMemoProxyObject Remove all items from memo. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_UnpicklerMemoProxy_clear__doc__, "clear()\n" @@ -6767,7 +6767,7 @@ static PyObject * _pickle_UnpicklerMemoProxy_clear_impl(UnpicklerMemoProxyObject *self) -/*[clinic checksum: e0f99c26d48444a3f58f598bec3190c66595fce7]*/ +/*[clinic end generated code: checksum=e0f99c26d48444a3f58f598bec3190c66595fce7]*/ { _Unpickler_MemoCleanup(self->unpickler); self->unpickler->memo = _Unpickler_NewMemo(self->unpickler->memo_size); @@ -6776,13 +6776,13 @@ Py_RETURN_NONE; } -/*[clinic] +/*[clinic input] _pickle.UnpicklerMemoProxy.copy self: UnpicklerMemoProxyObject Copy the memo to a new object. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_UnpicklerMemoProxy_copy__doc__, "copy()\n" @@ -6806,7 +6806,7 @@ static PyObject * _pickle_UnpicklerMemoProxy_copy_impl(UnpicklerMemoProxyObject *self) -/*[clinic checksum: 8c0ab91c0b694ea71a1774650898a760d1ab4765]*/ +/*[clinic end generated code: checksum=8c0ab91c0b694ea71a1774650898a760d1ab4765]*/ { Py_ssize_t i; PyObject *new_memo = PyDict_New(); @@ -6836,13 +6836,13 @@ return NULL; } -/*[clinic] +/*[clinic input] _pickle.UnpicklerMemoProxy.__reduce__ self: UnpicklerMemoProxyObject Implement pickling support. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_UnpicklerMemoProxy___reduce____doc__, "__reduce__()\n" @@ -6866,7 +6866,7 @@ static PyObject * _pickle_UnpicklerMemoProxy___reduce___impl(UnpicklerMemoProxyObject *self) -/*[clinic checksum: 4ee76a65511291f0de2e9e63db395d2e5d6d8df6]*/ +/*[clinic end generated code: checksum=4ee76a65511291f0de2e9e63db395d2e5d6d8df6]*/ { PyObject *reduce_value; PyObject *constructor_args; @@ -7141,7 +7141,7 @@ 0, /*tp_is_gc*/ }; -/*[clinic] +/*[clinic input] _pickle.dump @@ -7172,7 +7172,7 @@ If *fix_imports* is True and protocol is less than 3, pickle will try to map the new Python 3 names to the old module names used in Python 2, so that the pickle data stream is readable with Python 2. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_dump__doc__, "dump(obj, file, protocol=None, *, fix_imports=True)\n" @@ -7226,7 +7226,7 @@ static PyObject * _pickle_dump_impl(PyModuleDef *module, PyObject *obj, PyObject *file, PyObject *protocol, int fix_imports) -/*[clinic checksum: eb5c23e64da34477178230b704d2cc9c6b6650ea]*/ +/*[clinic end generated code: checksum=eb5c23e64da34477178230b704d2cc9c6b6650ea]*/ { PicklerObject *pickler = _Pickler_New(); @@ -7253,7 +7253,7 @@ return NULL; } -/*[clinic] +/*[clinic input] _pickle.dumps @@ -7275,7 +7275,7 @@ If *fix_imports* is True and *protocol* is less than 3, pickle will try to map the new Python 3 names to the old module names used in Python 2, so that the pickle data stream is readable with Python 2. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_dumps__doc__, "dumps(obj, protocol=None, *, fix_imports=True)\n" @@ -7320,7 +7320,7 @@ static PyObject * _pickle_dumps_impl(PyModuleDef *module, PyObject *obj, PyObject *protocol, int fix_imports) -/*[clinic checksum: e9b915d61202a9692cb6c6718db74fe54fc9c4d1]*/ +/*[clinic end generated code: checksum=e9b915d61202a9692cb6c6718db74fe54fc9c4d1]*/ { PyObject *result; PicklerObject *pickler = _Pickler_New(); @@ -7343,7 +7343,7 @@ return NULL; } -/*[clinic] +/*[clinic input] _pickle.load @@ -7376,7 +7376,7 @@ instances pickled by Python 2; these default to 'ASCII' and 'strict', respectively. The *encoding* can be 'bytes' to read these 8-bit string instances as bytes objects. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_load__doc__, "load(file, *, fix_imports=True, encoding=\'ASCII\', errors=\'strict\')\n" @@ -7432,7 +7432,7 @@ static PyObject * _pickle_load_impl(PyModuleDef *module, PyObject *file, int fix_imports, const char *encoding, const char *errors) -/*[clinic checksum: b41f06970e57acf2fd602e4b7f88e3f3e1e53087]*/ +/*[clinic end generated code: checksum=b41f06970e57acf2fd602e4b7f88e3f3e1e53087]*/ { PyObject *result; UnpicklerObject *unpickler = _Unpickler_New(); @@ -7457,7 +7457,7 @@ return NULL; } -/*[clinic] +/*[clinic input] _pickle.loads @@ -7481,7 +7481,7 @@ instances pickled by Python 2; these default to 'ASCII' and 'strict', respectively. The *encoding* can be 'bytes' to read these 8-bit string instances as bytes objects. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_pickle_loads__doc__, "loads(data, *, fix_imports=True, encoding=\'ASCII\', errors=\'strict\')\n" @@ -7528,7 +7528,7 @@ static PyObject * _pickle_loads_impl(PyModuleDef *module, PyObject *data, int fix_imports, const char *encoding, const char *errors) -/*[clinic checksum: 0663de43aca6c21508a777e29d98c9c3a6e7f72d]*/ +/*[clinic end generated code: checksum=0663de43aca6c21508a777e29d98c9c3a6e7f72d]*/ { PyObject *result; UnpicklerObject *unpickler = _Unpickler_New(); diff --git a/Modules/_weakref.c b/Modules/_weakref.c --- a/Modules/_weakref.c +++ b/Modules/_weakref.c @@ -4,12 +4,12 @@ #define GET_WEAKREFS_LISTPTR(o) \ ((PyWeakReference **) PyObject_GET_WEAKREFS_LISTPTR(o)) -/*[clinic] +/*[clinic input] module _weakref -[clinic]*/ -/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ -/*[clinic] +/*[clinic input] _weakref.getweakrefcount -> Py_ssize_t @@ -17,7 +17,7 @@ / Return the number of weak references to 'object'. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(_weakref_getweakrefcount__doc__, "getweakrefcount(object)\n" @@ -45,13 +45,13 @@ static Py_ssize_t _weakref_getweakrefcount_impl(PyModuleDef *module, PyObject *object) -/*[clinic checksum: 436e8fbe0297434375f039d8c2d9fc3a9bbe773c]*/ +/*[clinic end generated code: checksum=436e8fbe0297434375f039d8c2d9fc3a9bbe773c]*/ { PyWeakReference **list; if (!PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))) return 0; - + list = GET_WEAKREFS_LISTPTR(object); return _PyWeakref_GetWeakrefCount(*list); } diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -181,10 +181,10 @@ #endif /* ! __WATCOMC__ || __QNX__ */ -/*[clinic] +/*[clinic input] module os -[clinic]*/ -/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ #ifndef _MSC_VER @@ -2355,7 +2355,7 @@ #endif -/*[python] +/*[python input] class path_t_converter(CConverter): @@ -2396,10 +2396,10 @@ self.c_default = 'DEFAULT_DIR_FD' -[python]*/ -/*[python checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ - -/*[clinic] +[python start generated code]*/ +/*[python end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ + +/*[clinic input] os.stat -> object(doc_default='stat_result') @@ -2427,7 +2427,7 @@ It's an error to use dir_fd or follow_symlinks when specifying path as an open file descriptor. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(os_stat__doc__, "stat(path, *, dir_fd=None, follow_symlinks=True)\n" @@ -2481,7 +2481,7 @@ static PyObject * os_stat_impl(PyModuleDef *module, path_t *path, int dir_fd, int follow_symlinks) -/*[clinic checksum: 85a71ad602e89f8e280118da976f70cd2f9abdf1]*/ +/*[clinic end generated code: checksum=85a71ad602e89f8e280118da976f70cd2f9abdf1]*/ { return posix_do_stat("stat", path, dir_fd, follow_symlinks); } @@ -2522,7 +2522,7 @@ #else #define OS_ACCESS_DIR_FD_CONVERTER dir_fd_unavailable #endif -/*[clinic] +/*[clinic input] os.access -> object(doc_default='True if granted, False otherwise') path: path_t(allow_fd=True) @@ -2559,7 +2559,7 @@ routine can be used in a suid/sgid environment to test if the invoking user has the specified access to the path. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(os_access__doc__, "access(path, mode, *, dir_fd=None, effective_ids=False, follow_symlinks=True)\n" @@ -2622,7 +2622,7 @@ static PyObject * os_access_impl(PyModuleDef *module, path_t *path, int mode, int dir_fd, int effective_ids, int follow_symlinks) -/*[clinic checksum: 636e835c36562a2fc11acab75314634127fdf769]*/ +/*[clinic end generated code: checksum=636e835c36562a2fc11acab75314634127fdf769]*/ { PyObject *return_value = NULL; @@ -2706,7 +2706,7 @@ #ifdef HAVE_TTYNAME -/*[clinic] +/*[clinic input] os.ttyname -> DecodeFSDefault fd: int @@ -2715,7 +2715,7 @@ / Return the name of the terminal device connected to 'fd'. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(os_ttyname__doc__, "ttyname(fd)\n" @@ -2752,7 +2752,7 @@ static char * os_ttyname_impl(PyModuleDef *module, int fd) -/*[clinic checksum: 0f368134dc0a7f21f25185e2e6bacf7675fb473a]*/ +/*[clinic end generated code: checksum=0f368134dc0a7f21f25185e2e6bacf7675fb473a]*/ { char *ret; diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -17,11 +17,11 @@ #include "ucnhash.h" #include "structmember.h" -/*[clinic] +/*[clinic input] module unicodedata class unicodedata.UCD -[clinic]*/ -/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ /* character properties */ @@ -113,7 +113,7 @@ /* --- Module API --------------------------------------------------------- */ -/*[clinic] +/*[clinic input] unicodedata.UCD.decimal @@ -126,7 +126,7 @@ Returns the decimal value assigned to the Unicode character unichr as integer. If no such value is defined, default is returned, or, if not given, ValueError is raised. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(unicodedata_UCD_decimal__doc__, "decimal(unichr, default=None)\n" @@ -161,7 +161,7 @@ static PyObject * unicodedata_UCD_decimal_impl(PyObject *self, PyObject *unichr, PyObject *default_value) -/*[clinic checksum: 9576fa55f4ea0be82968af39dc9d0283e634beeb]*/ +/*[clinic end generated code: checksum=9576fa55f4ea0be82968af39dc9d0283e634beeb]*/ { PyUnicodeObject *v = (PyUnicodeObject *)unichr; int have_old = 0; diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -81,12 +81,12 @@ PyErr_Format(ZlibError, "Error %d %s: %.200s", err, msg, zmsg); } -/*[clinic] +/*[clinic input] module zlib class zlib.Compress class zlib.Decompress -[clinic]*/ -/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ PyDoc_STRVAR(compressobj__doc__, "compressobj(level=-1, method=DEFLATED, wbits=15, memlevel=8,\n" @@ -164,7 +164,7 @@ PyMem_RawFree(ptr); } -/*[clinic] +/*[clinic input] zlib.compress bytes: Py_buffer @@ -177,7 +177,7 @@ Returns compressed string. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(zlib_compress__doc__, "compress(bytes, [level])\n" @@ -227,7 +227,7 @@ static PyObject * zlib_compress_impl(PyModuleDef *module, Py_buffer *bytes, int group_right_1, int level) -/*[clinic checksum: 9f055a396620bc1a8a13d74c3496249528b32b0d]*/ +/*[clinic end generated code: checksum=9f055a396620bc1a8a13d74c3496249528b32b0d]*/ { PyObject *ReturnVal = NULL; Byte *input, *output = NULL; @@ -306,14 +306,14 @@ return ReturnVal; } -/*[python] +/*[python input] class uint_converter(CConverter): type = 'unsigned int' converter = 'uint_converter' -[python]*/ -/*[python checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[python start generated code]*/ +/*[python end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ static int uint_converter(PyObject *obj, void *ptr) @@ -743,7 +743,7 @@ return 0; } -/*[clinic] +/*[clinic input] zlib.Decompress.decompress @@ -762,7 +762,7 @@ After calling this function, some of the input data may still be stored in internal buffers for later processing. Call the flush() method to clear these buffers. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(zlib_Decompress_decompress__doc__, "decompress(data, max_length=0)\n" @@ -808,7 +808,7 @@ static PyObject * zlib_Decompress_decompress_impl(compobject *self, Py_buffer *data, unsigned int max_length) -/*[clinic checksum: 5b1e4f9f1ef8eca55fff78356f9df0c81232ed3b]*/ +/*[clinic end generated code: checksum=5b1e4f9f1ef8eca55fff78356f9df0c81232ed3b]*/ { int err; unsigned int old_length, length = DEFAULTALLOC; @@ -1026,13 +1026,13 @@ #ifdef HAVE_ZLIB_COPY -/*[clinic] +/*[clinic input] zlib.Compress.copy self: self(type="compobject *") Return a copy of the compression object. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(zlib_Compress_copy__doc__, "copy()\n" @@ -1056,7 +1056,7 @@ static PyObject * zlib_Compress_copy_impl(compobject *self) -/*[clinic checksum: 2f454ee15be3bc53cfb4e845c3f891f68be4c8e4]*/ +/*[clinic end generated code: checksum=2f454ee15be3bc53cfb4e845c3f891f68be4c8e4]*/ { compobject *retval = NULL; int err; diff --git a/Objects/dictobject.c b/Objects/dictobject.c --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -69,10 +69,10 @@ #include "Python.h" #include "stringlib/eq.h" -/*[clinic] +/*[clinic input] class dict -[clinic]*/ -/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ typedef struct { /* Cached hash code of me_key. */ @@ -2164,7 +2164,7 @@ return res; } -/*[clinic] +/*[clinic input] @coexist dict.__contains__ @@ -2173,7 +2173,7 @@ / True if D has a key k, else False" -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(dict___contains____doc__, "__contains__(key)\n" @@ -2184,7 +2184,7 @@ static PyObject * dict___contains__(PyObject *self, PyObject *key) -/*[clinic checksum: 3bbac5ce898ae630d9668fa1c8b3afb645ff22e8]*/ +/*[clinic end generated code: checksum=3bbac5ce898ae630d9668fa1c8b3afb645ff22e8]*/ { register PyDictObject *mp = (PyDictObject *)self; Py_hash_t hash; diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -47,10 +47,10 @@ #include #endif -/*[clinic] +/*[clinic input] class str -[clinic]*/ -/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ /* --- Globals ------------------------------------------------------------ @@ -12860,7 +12860,7 @@ return case_operation(self, do_swapcase); } -/*[clinic] +/*[clinic input] @staticmethod str.maketrans as unicode_maketrans @@ -12882,7 +12882,7 @@ in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result. -[clinic]*/ +[clinic start generated code]*/ PyDoc_STRVAR(unicode_maketrans__doc__, "maketrans(x, y=None, z=None)\n" @@ -12922,7 +12922,7 @@ static PyObject * unicode_maketrans_impl(void *null, PyObject *x, PyObject *y, PyObject *z) -/*[clinic checksum: 7f76f414a0dfd0c614e0d4717872eeb520516da7]*/ +/*[clinic end generated code: checksum=7f76f414a0dfd0c614e0d4717872eeb520516da7]*/ { PyObject *new = NULL, *key, *value; Py_ssize_t i = 0; diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -292,10 +292,10 @@ class PythonLanguage(Language): language = 'Python' - start_line = "#/*[{dsl_name}]" + start_line = "#/*[{dsl_name} input]" body_prefix = "#" - stop_line = "#[{dsl_name}]*/" - checksum_line = "#/*[{dsl_name} checksum: {checksum}]*/" + stop_line = "#[{dsl_name} start generated code]*/" + checksum_line = "#/*[{dsl_name} end generated code: checksum={checksum}]*/" def permute_left_option_groups(l): @@ -360,11 +360,12 @@ class CLanguage(Language): + body_prefix = "#" language = 'C' - start_line = "/*[{dsl_name}]" + start_line = "/*[{dsl_name} input]" body_prefix = "" - stop_line = "[{dsl_name}]*/" - checksum_line = "/*[{dsl_name} checksum: {checksum}]*/" + stop_line = "[{dsl_name} start generated code]*/" + checksum_line = "/*[{dsl_name} end generated code: checksum={checksum}]*/" def render(self, signatures): function = None