to improve readability.
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
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
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,
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.
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
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,
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
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
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
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]*/
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'
/
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"
...
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
static return_type
your_function_impl(...)
- /*[clinic checksum: ...]*/
+ /*[clinic end generated code: checksum=...]*/
{
...
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'
/
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"
...
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
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
...
uses optional groups to make the first two parameters and the last
parameter optional::
- /*[clinic]
+ /*[clinic input]
curses.window.addch
As an example, here's our sample ``pickle.Pickler.dump`` using the proper
converter::
- /*[clinic]
+ /*[clinic input]
pickle.Pickler.dump
obj: object
/
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
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
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:...]*/
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
/
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
/
Write a pickled representation of the given object to the open file.
- [clinic]*/
+ [clinic start generated code]*/
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
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:...]*/
Tools/Demos
-----------
+- Issue #19273: The marker comments Argument Clinic uses have been changed
+ to improve readability.
+
- Issue #20157: When Argument Clinic renames a parameter because its name
collides with a C keyword, it no longer exposes that rename to PyArg_Parse.
#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 */
/* Addch, Addstr, Addnstr */
-/*[clinic]
+/*[clinic input]
curses.window.addch
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"
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;
#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
tzinfo);
}
-/*[clinic]
+/*[clinic input]
@classmethod
datetime.datetime.now
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"
static PyObject *
datetime_datetime_now_impl(PyTypeObject *cls, PyObject *tz)
-/*[clinic checksum: ca3d26a423b3f633b260c7622e303f0915a96f7c]*/
+/*[clinic end generated code: checksum=ca3d26a423b3f633b260c7622e303f0915a96f7c]*/
{
PyObject *self;
#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
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)
0, /* sq_inplace_repeat */
};
-/*[clinic]
+/*[clinic input]
dbm.dbm.get
/
Return the value for key if present, otherwise default.
-[clinic]*/
+[clinic start generated code]*/
PyDoc_STRVAR(dbm_dbm_get__doc__,
"get(key, [default])\n"
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;
/* ----------------------------------------------------------------- */
-/*[clinic]
+/*[clinic input]
dbm.open as dbmopen
Return a database object.
-[clinic]*/
+[clinic start generated code]*/
PyDoc_STRVAR(dbmopen__doc__,
"open(filename, flags=\'r\', mode=0o666)\n"
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;
#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
/
Compute the stack effect of the opcode.
-[clinic]*/
+[clinic start generated code]*/
PyDoc_STRVAR(_opcode_stack_effect__doc__,
"stack_effect(opcode, [oparg])\n"
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");
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]*/
+[clinic start generated code]*/
+/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/
-/*[python]
+/*[python input]
class PicklerObject_converter(self_converter):
type = "PicklerObject *"
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 {
PyObject *PickleError;
PyObject *PicklingError;
PyObject *UnpicklingError;
-
+
/* copyreg.dispatch_table, {type_object: pickling_function} */
PyObject *dispatch_table;
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
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;
return 0;
}
-/*[clinic]
+/*[clinic input]
_pickle.Pickler.clear_memo
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"
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);
Py_RETURN_NONE;
}
-/*[clinic]
+/*[clinic input]
_pickle.Pickler.dump
/
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"
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
}
-/*[clinic]
+/*[clinic input]
_pickle.Pickler.__init__
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"
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);
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"
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"
static PyObject *
_pickle_PicklerMemoProxy_copy_impl(PicklerMemoProxyObject *self)
-/*[clinic checksum: 808c4d5a37359ed5fb2efe81dbe5ff480719f470]*/
+/*[clinic end generated code: checksum=808c4d5a37359ed5fb2efe81dbe5ff480719f470]*/
{
Py_ssize_t i;
PyMemoTable *memo;
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"
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);
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;
return value;
}
-/*[clinic]
+/*[clinic input]
_pickle.Unpickler.load
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"
static PyObject *
_pickle_Unpickler_load_impl(PyObject *self)
-/*[clinic checksum: 55f35fcaf034817e75c355ec50b7878577355899]*/
+/*[clinic end generated code: checksum=55f35fcaf034817e75c355ec50b7878577355899]*/
{
UnpicklerObject *unpickler = (UnpicklerObject*)self;
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
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"
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;
return 0;
}
-/*[clinic]
+/*[clinic input]
_pickle.Unpickler.__init__
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"
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);
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"
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);
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"
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();
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"
static PyObject *
_pickle_UnpicklerMemoProxy___reduce___impl(UnpicklerMemoProxyObject *self)
-/*[clinic checksum: 4ee76a65511291f0de2e9e63db395d2e5d6d8df6]*/
+/*[clinic end generated code: checksum=4ee76a65511291f0de2e9e63db395d2e5d6d8df6]*/
{
PyObject *reduce_value;
PyObject *constructor_args;
0, /*tp_is_gc*/
};
-/*[clinic]
+/*[clinic input]
_pickle.dump
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"
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();
return NULL;
}
-/*[clinic]
+/*[clinic input]
_pickle.dumps
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"
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();
return NULL;
}
-/*[clinic]
+/*[clinic input]
_pickle.load
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"
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();
return NULL;
}
-/*[clinic]
+/*[clinic input]
_pickle.loads
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"
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();
#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
/
Return the number of weak references to 'object'.
-[clinic]*/
+[clinic start generated code]*/
PyDoc_STRVAR(_weakref_getweakrefcount__doc__,
"getweakrefcount(object)\n"
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);
}
#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
#endif
-/*[python]
+/*[python input]
class path_t_converter(CConverter):
self.c_default = 'DEFAULT_DIR_FD'
-[python]*/
-/*[python checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/
+[python start generated code]*/
+/*[python end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/
-/*[clinic]
+/*[clinic input]
os.stat -> object(doc_default='stat_result')
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"
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);
}
#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)
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"
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;
#ifdef HAVE_TTYNAME
-/*[clinic]
+/*[clinic input]
os.ttyname -> DecodeFSDefault
fd: int
/
Return the name of the terminal device connected to 'fd'.
-[clinic]*/
+[clinic start generated code]*/
PyDoc_STRVAR(os_ttyname__doc__,
"ttyname(fd)\n"
static char *
os_ttyname_impl(PyModuleDef *module, int fd)
-/*[clinic checksum: 0f368134dc0a7f21f25185e2e6bacf7675fb473a]*/
+/*[clinic end generated code: checksum=0f368134dc0a7f21f25185e2e6bacf7675fb473a]*/
{
char *ret;
#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 */
/* --- Module API --------------------------------------------------------- */
-/*[clinic]
+/*[clinic input]
unicodedata.UCD.decimal
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"
static PyObject *
unicodedata_UCD_decimal_impl(PyObject *self, PyUnicodeObject *unichr, PyObject *default_value)
-/*[clinic checksum: 73edde0e9cd5913ea174c4fa81504369761b7426]*/
+/*[clinic end generated code: checksum=73edde0e9cd5913ea174c4fa81504369761b7426]*/
{
PyUnicodeObject *v = (PyUnicodeObject *)unichr;
int have_old = 0;
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"
PyMem_RawFree(ptr);
}
-/*[clinic]
+/*[clinic input]
zlib.compress
bytes: Py_buffer
Returns compressed string.
-[clinic]*/
+[clinic start generated code]*/
PyDoc_STRVAR(zlib_compress__doc__,
"compress(bytes, [level])\n"
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;
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)
return 0;
}
-/*[clinic]
+/*[clinic input]
zlib.Decompress.decompress
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"
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;
#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"
static PyObject *
zlib_Compress_copy_impl(compobject *self)
-/*[clinic checksum: 2f454ee15be3bc53cfb4e845c3f891f68be4c8e4]*/
+/*[clinic end generated code: checksum=2f454ee15be3bc53cfb4e845c3f891f68be4c8e4]*/
{
compobject *retval = NULL;
int err;
#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. */
return res;
}
-/*[clinic]
+/*[clinic input]
@coexist
dict.__contains__
/
True if D has a key k, else False"
-[clinic]*/
+[clinic start generated code]*/
PyDoc_STRVAR(dict___contains____doc__,
"__contains__(key)\n"
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;
#include <windows.h>
#endif
-/*[clinic]
+/*[clinic input]
class str
-[clinic]*/
-/*[clinic checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709]*/
+[clinic start generated code]*/
+/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/
/* --- Globals ------------------------------------------------------------
return case_operation(self, do_swapcase);
}
-/*[clinic]
+/*[clinic input]
@staticmethod
str.maketrans as unicode_maketrans
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"
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;
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):
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