mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
Argument Clinic: rename "self" to "module" for module-level functions.
This commit is contained in:
parent
fd32fffa5a
commit
ed4a1c5703
10 changed files with 88 additions and 79 deletions
|
@ -551,7 +551,6 @@ PyCursesWindow_Dealloc(PyCursesWindowObject *wo)
|
||||||
|
|
||||||
/*[clinic]
|
/*[clinic]
|
||||||
module curses
|
module curses
|
||||||
|
|
||||||
class curses.window
|
class curses.window
|
||||||
|
|
||||||
curses.window.addch
|
curses.window.addch
|
||||||
|
|
|
@ -4141,9 +4141,10 @@ datetime_best_possible(PyObject *cls, TM_FUNC f, PyObject *tzinfo)
|
||||||
|
|
||||||
/*[clinic]
|
/*[clinic]
|
||||||
module datetime
|
module datetime
|
||||||
|
class datetime.datetime
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
datetime.now
|
datetime.datetime.now
|
||||||
|
|
||||||
tz: object = None
|
tz: object = None
|
||||||
Timezone object.
|
Timezone object.
|
||||||
|
@ -4153,23 +4154,23 @@ Returns new datetime object representing current time local to tz.
|
||||||
If no tz is specified, uses local timezone.
|
If no tz is specified, uses local timezone.
|
||||||
[clinic]*/
|
[clinic]*/
|
||||||
|
|
||||||
PyDoc_STRVAR(datetime_now__doc__,
|
PyDoc_STRVAR(datetime_datetime_now__doc__,
|
||||||
"Returns new datetime object representing current time local to tz.\n"
|
"Returns new datetime object representing current time local to tz.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"datetime.now(tz=None)\n"
|
"datetime.datetime.now(tz=None)\n"
|
||||||
" tz\n"
|
" tz\n"
|
||||||
" Timezone object.\n"
|
" Timezone object.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"If no tz is specified, uses local timezone.");
|
"If no tz is specified, uses local timezone.");
|
||||||
|
|
||||||
#define DATETIME_NOW_METHODDEF \
|
#define DATETIME_DATETIME_NOW_METHODDEF \
|
||||||
{"now", (PyCFunction)datetime_now, METH_VARARGS|METH_KEYWORDS|METH_CLASS, datetime_now__doc__},
|
{"now", (PyCFunction)datetime_datetime_now, METH_VARARGS|METH_KEYWORDS|METH_CLASS, datetime_datetime_now__doc__},
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
datetime_now_impl(PyObject *cls, PyObject *tz);
|
datetime_datetime_now_impl(PyObject *cls, PyObject *tz);
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
datetime_now(PyObject *cls, PyObject *args, PyObject *kwargs)
|
datetime_datetime_now(PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
static char *_keywords[] = {"tz", NULL};
|
static char *_keywords[] = {"tz", NULL};
|
||||||
|
@ -4179,15 +4180,15 @@ datetime_now(PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||||
"|O:now", _keywords,
|
"|O:now", _keywords,
|
||||||
&tz))
|
&tz))
|
||||||
goto exit;
|
goto exit;
|
||||||
return_value = datetime_now_impl(cls, tz);
|
return_value = datetime_datetime_now_impl(cls, tz);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
datetime_now_impl(PyObject *cls, PyObject *tz)
|
datetime_datetime_now_impl(PyObject *cls, PyObject *tz)
|
||||||
/*[clinic checksum: 328b54387f4c2f8cb534997e1bd55f8cb38c4992]*/
|
/*[clinic checksum: cde1daca68c9b7dca6df51759db2de1d43a39774]*/
|
||||||
{
|
{
|
||||||
PyObject *self;
|
PyObject *self;
|
||||||
|
|
||||||
|
@ -5037,7 +5038,7 @@ static PyMethodDef datetime_methods[] = {
|
||||||
|
|
||||||
/* Class methods: */
|
/* Class methods: */
|
||||||
|
|
||||||
DATETIME_NOW_METHODDEF
|
DATETIME_DATETIME_NOW_METHODDEF
|
||||||
|
|
||||||
{"utcnow", (PyCFunction)datetime_utcnow,
|
{"utcnow", (PyCFunction)datetime_utcnow,
|
||||||
METH_NOARGS | METH_CLASS,
|
METH_NOARGS | METH_CLASS,
|
||||||
|
|
|
@ -415,10 +415,10 @@ PyDoc_STRVAR(dbmopen__doc__,
|
||||||
{"open", (PyCFunction)dbmopen, METH_VARARGS, dbmopen__doc__},
|
{"open", (PyCFunction)dbmopen, METH_VARARGS, dbmopen__doc__},
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dbmopen_impl(PyObject *self, const char *filename, const char *flags, int mode);
|
dbmopen_impl(PyObject *module, const char *filename, const char *flags, int mode);
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dbmopen(PyObject *self, PyObject *args)
|
dbmopen(PyObject *module, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
|
@ -429,15 +429,15 @@ dbmopen(PyObject *self, PyObject *args)
|
||||||
"s|si:open",
|
"s|si:open",
|
||||||
&filename, &flags, &mode))
|
&filename, &flags, &mode))
|
||||||
goto exit;
|
goto exit;
|
||||||
return_value = dbmopen_impl(self, filename, flags, mode);
|
return_value = dbmopen_impl(module, filename, flags, mode);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dbmopen_impl(PyObject *self, const char *filename, const char *flags, int mode)
|
dbmopen_impl(PyObject *module, const char *filename, const char *flags, int mode)
|
||||||
/*[clinic checksum: 61007c796d38af85c8035afa769fb4bb453429ee]*/
|
/*[clinic checksum: 2b0ec9e3c6ecd19e06d16c9f0ba33848245cb1ab]*/
|
||||||
{
|
{
|
||||||
int iflags;
|
int iflags;
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,14 @@ PyDoc_STRVAR(_weakref_getweakrefcount__doc__,
|
||||||
{"getweakrefcount", (PyCFunction)_weakref_getweakrefcount, METH_O, _weakref_getweakrefcount__doc__},
|
{"getweakrefcount", (PyCFunction)_weakref_getweakrefcount, METH_O, _weakref_getweakrefcount__doc__},
|
||||||
|
|
||||||
static Py_ssize_t
|
static Py_ssize_t
|
||||||
_weakref_getweakrefcount_impl(PyObject *self, PyObject *object);
|
_weakref_getweakrefcount_impl(PyObject *module, PyObject *object);
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
_weakref_getweakrefcount(PyObject *self, PyObject *object)
|
_weakref_getweakrefcount(PyObject *module, PyObject *object)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
Py_ssize_t _return_value;
|
Py_ssize_t _return_value;
|
||||||
_return_value = _weakref_getweakrefcount_impl(self, object);
|
_return_value = _weakref_getweakrefcount_impl(module, object);
|
||||||
if ((_return_value == -1) && PyErr_Occurred())
|
if ((_return_value == -1) && PyErr_Occurred())
|
||||||
goto exit;
|
goto exit;
|
||||||
return_value = PyLong_FromSsize_t(_return_value);
|
return_value = PyLong_FromSsize_t(_return_value);
|
||||||
|
@ -42,8 +42,8 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
static Py_ssize_t
|
static Py_ssize_t
|
||||||
_weakref_getweakrefcount_impl(PyObject *self, PyObject *object)
|
_weakref_getweakrefcount_impl(PyObject *module, PyObject *object)
|
||||||
/*[clinic checksum: 0b7e7ddd87d483719ebac0fba364fff0ed0182d9]*/
|
/*[clinic checksum: 05cffbc3a4b193a0b7e645da81be281748704f69]*/
|
||||||
{
|
{
|
||||||
PyWeakReference **list;
|
PyWeakReference **list;
|
||||||
|
|
||||||
|
|
|
@ -2460,10 +2460,10 @@ PyDoc_STRVAR(os_stat__doc__,
|
||||||
{"stat", (PyCFunction)os_stat, METH_VARARGS|METH_KEYWORDS, os_stat__doc__},
|
{"stat", (PyCFunction)os_stat, METH_VARARGS|METH_KEYWORDS, os_stat__doc__},
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
os_stat_impl(PyObject *self, path_t *path, int dir_fd, int follow_symlinks);
|
os_stat_impl(PyObject *module, path_t *path, int dir_fd, int follow_symlinks);
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
os_stat(PyObject *self, PyObject *args, PyObject *kwargs)
|
os_stat(PyObject *module, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
static char *_keywords[] = {"path", "dir_fd", "follow_symlinks", NULL};
|
static char *_keywords[] = {"path", "dir_fd", "follow_symlinks", NULL};
|
||||||
|
@ -2475,7 +2475,7 @@ os_stat(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
"O&|$O&p:stat", _keywords,
|
"O&|$O&p:stat", _keywords,
|
||||||
path_converter, &path, OS_STAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks))
|
path_converter, &path, OS_STAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks))
|
||||||
goto exit;
|
goto exit;
|
||||||
return_value = os_stat_impl(self, &path, dir_fd, follow_symlinks);
|
return_value = os_stat_impl(module, &path, dir_fd, follow_symlinks);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
/* Cleanup for path */
|
/* Cleanup for path */
|
||||||
|
@ -2485,8 +2485,8 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
os_stat_impl(PyObject *self, path_t *path, int dir_fd, int follow_symlinks)
|
os_stat_impl(PyObject *module, path_t *path, int dir_fd, int follow_symlinks)
|
||||||
/*[clinic checksum: 9d9af08e8cfafd12f94e73ea3065eb3056f99515]*/
|
/*[clinic checksum: 89390f78327e3f045a81974d758d3996e2a71f68]*/
|
||||||
{
|
{
|
||||||
return posix_do_stat("stat", path, dir_fd, follow_symlinks);
|
return posix_do_stat("stat", path, dir_fd, follow_symlinks);
|
||||||
}
|
}
|
||||||
|
@ -2600,10 +2600,10 @@ PyDoc_STRVAR(os_access__doc__,
|
||||||
{"access", (PyCFunction)os_access, METH_VARARGS|METH_KEYWORDS, os_access__doc__},
|
{"access", (PyCFunction)os_access, METH_VARARGS|METH_KEYWORDS, os_access__doc__},
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
os_access_impl(PyObject *self, path_t *path, int mode, int dir_fd, int effective_ids, int follow_symlinks);
|
os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd, int effective_ids, int follow_symlinks);
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
os_access(PyObject *self, PyObject *args, PyObject *kwargs)
|
os_access(PyObject *module, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
static char *_keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL};
|
static char *_keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL};
|
||||||
|
@ -2617,7 +2617,7 @@ os_access(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
"O&i|$O&pp:access", _keywords,
|
"O&i|$O&pp:access", _keywords,
|
||||||
path_converter, &path, &mode, OS_STAT_DIR_FD_CONVERTER, &dir_fd, &effective_ids, &follow_symlinks))
|
path_converter, &path, &mode, OS_STAT_DIR_FD_CONVERTER, &dir_fd, &effective_ids, &follow_symlinks))
|
||||||
goto exit;
|
goto exit;
|
||||||
return_value = os_access_impl(self, &path, mode, dir_fd, effective_ids, follow_symlinks);
|
return_value = os_access_impl(module, &path, mode, dir_fd, effective_ids, follow_symlinks);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
/* Cleanup for path */
|
/* Cleanup for path */
|
||||||
|
@ -2627,8 +2627,8 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
os_access_impl(PyObject *self, path_t *path, int mode, int dir_fd, int effective_ids, int follow_symlinks)
|
os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd, int effective_ids, int follow_symlinks)
|
||||||
/*[clinic checksum: 0147557eb43243df57ba616cc7c35f232c69bc6a]*/
|
/*[clinic checksum: aa3e145816a748172e62df8e44af74169c7e1247]*/
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
|
||||||
|
@ -2734,10 +2734,10 @@ PyDoc_STRVAR(os_ttyname__doc__,
|
||||||
{"ttyname", (PyCFunction)os_ttyname, METH_VARARGS, os_ttyname__doc__},
|
{"ttyname", (PyCFunction)os_ttyname, METH_VARARGS, os_ttyname__doc__},
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
os_ttyname_impl(PyObject *self, int fd);
|
os_ttyname_impl(PyObject *module, int fd);
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
os_ttyname(PyObject *self, PyObject *args)
|
os_ttyname(PyObject *module, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -2747,7 +2747,7 @@ os_ttyname(PyObject *self, PyObject *args)
|
||||||
"i:ttyname",
|
"i:ttyname",
|
||||||
&fd))
|
&fd))
|
||||||
goto exit;
|
goto exit;
|
||||||
_return_value = os_ttyname_impl(self, fd);
|
_return_value = os_ttyname_impl(module, fd);
|
||||||
if (_return_value == NULL)
|
if (_return_value == NULL)
|
||||||
goto exit;
|
goto exit;
|
||||||
return_value = PyUnicode_DecodeFSDefault(_return_value);
|
return_value = PyUnicode_DecodeFSDefault(_return_value);
|
||||||
|
@ -2757,8 +2757,8 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
os_ttyname_impl(PyObject *self, int fd)
|
os_ttyname_impl(PyObject *module, int fd)
|
||||||
/*[clinic checksum: ea680155d87bb733f542d67653eca732dd0981a8]*/
|
/*[clinic checksum: c742dd621ec98d0f81d37d264e1d3c89c7a5fb1a]*/
|
||||||
{
|
{
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,8 @@ static Py_UCS4 getuchar(PyUnicodeObject *obj)
|
||||||
|
|
||||||
/*[clinic]
|
/*[clinic]
|
||||||
module unicodedata
|
module unicodedata
|
||||||
unicodedata.decimal
|
class unicodedata.UCD
|
||||||
|
unicodedata.UCD.decimal
|
||||||
|
|
||||||
unichr: object(type='str')
|
unichr: object(type='str')
|
||||||
default: object=NULL
|
default: object=NULL
|
||||||
|
@ -122,23 +123,23 @@ as integer. If no such value is defined, default is returned, or, if
|
||||||
not given, ValueError is raised.
|
not given, ValueError is raised.
|
||||||
[clinic]*/
|
[clinic]*/
|
||||||
|
|
||||||
PyDoc_STRVAR(unicodedata_decimal__doc__,
|
PyDoc_STRVAR(unicodedata_UCD_decimal__doc__,
|
||||||
"Converts a Unicode character into its equivalent decimal value.\n"
|
"Converts a Unicode character into its equivalent decimal value.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"unicodedata.decimal(unichr, default=None)\n"
|
"unicodedata.UCD.decimal(unichr, default=None)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Returns the decimal value assigned to the Unicode character unichr\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"
|
"as integer. If no such value is defined, default is returned, or, if\n"
|
||||||
"not given, ValueError is raised.");
|
"not given, ValueError is raised.");
|
||||||
|
|
||||||
#define UNICODEDATA_DECIMAL_METHODDEF \
|
#define UNICODEDATA_UCD_DECIMAL_METHODDEF \
|
||||||
{"decimal", (PyCFunction)unicodedata_decimal, METH_VARARGS, unicodedata_decimal__doc__},
|
{"decimal", (PyCFunction)unicodedata_UCD_decimal, METH_VARARGS, unicodedata_UCD_decimal__doc__},
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
unicodedata_decimal_impl(PyObject *self, PyObject *unichr, PyObject *default_value);
|
unicodedata_UCD_decimal_impl(PyObject *self, PyObject *unichr, PyObject *default_value);
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
unicodedata_decimal(PyObject *self, PyObject *args)
|
unicodedata_UCD_decimal(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
PyObject *unichr;
|
PyObject *unichr;
|
||||||
|
@ -148,15 +149,15 @@ unicodedata_decimal(PyObject *self, PyObject *args)
|
||||||
"O!|O:decimal",
|
"O!|O:decimal",
|
||||||
&PyUnicode_Type, &unichr, &default_value))
|
&PyUnicode_Type, &unichr, &default_value))
|
||||||
goto exit;
|
goto exit;
|
||||||
return_value = unicodedata_decimal_impl(self, unichr, default_value);
|
return_value = unicodedata_UCD_decimal_impl(self, unichr, default_value);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
unicodedata_decimal_impl(PyObject *self, PyObject *unichr, PyObject *default_value)
|
unicodedata_UCD_decimal_impl(PyObject *self, PyObject *unichr, PyObject *default_value)
|
||||||
/*[clinic checksum: 76c8d1c3dbee495d4cfd86ca6829543a3129344a]*/
|
/*[clinic checksum: a0980c387387287e2ac230c37d95b26f6903e0d2]*/
|
||||||
{
|
{
|
||||||
PyUnicodeObject *v = (PyUnicodeObject *)unichr;
|
PyUnicodeObject *v = (PyUnicodeObject *)unichr;
|
||||||
int have_old = 0;
|
int have_old = 0;
|
||||||
|
@ -1288,7 +1289,7 @@ unicodedata_lookup(PyObject* self, PyObject* args)
|
||||||
/* XXX Add doc strings. */
|
/* XXX Add doc strings. */
|
||||||
|
|
||||||
static PyMethodDef unicodedata_functions[] = {
|
static PyMethodDef unicodedata_functions[] = {
|
||||||
UNICODEDATA_DECIMAL_METHODDEF
|
UNICODEDATA_UCD_DECIMAL_METHODDEF
|
||||||
{"digit", unicodedata_digit, METH_VARARGS, unicodedata_digit__doc__},
|
{"digit", unicodedata_digit, METH_VARARGS, unicodedata_digit__doc__},
|
||||||
{"numeric", unicodedata_numeric, METH_VARARGS, unicodedata_numeric__doc__},
|
{"numeric", unicodedata_numeric, METH_VARARGS, unicodedata_numeric__doc__},
|
||||||
{"category", unicodedata_category, METH_VARARGS,
|
{"category", unicodedata_category, METH_VARARGS,
|
||||||
|
|
|
@ -630,8 +630,9 @@ save_unconsumed_input(compobject *self, int err)
|
||||||
/*[clinic]
|
/*[clinic]
|
||||||
|
|
||||||
module zlib
|
module zlib
|
||||||
|
class zlib.Decompress
|
||||||
|
|
||||||
zlib.decompress
|
zlib.Decompress.decompress
|
||||||
|
|
||||||
data: Py_buffer
|
data: Py_buffer
|
||||||
The binary data to decompress.
|
The binary data to decompress.
|
||||||
|
@ -648,10 +649,10 @@ internal buffers for later processing.
|
||||||
Call the flush() method to clear these buffers.
|
Call the flush() method to clear these buffers.
|
||||||
[clinic]*/
|
[clinic]*/
|
||||||
|
|
||||||
PyDoc_STRVAR(zlib_decompress__doc__,
|
PyDoc_STRVAR(zlib_Decompress_decompress__doc__,
|
||||||
"Return a string containing the decompressed version of the data.\n"
|
"Return a string containing the decompressed version of the data.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"zlib.decompress(data, max_length=0)\n"
|
"zlib.Decompress.decompress(data, max_length=0)\n"
|
||||||
" data\n"
|
" data\n"
|
||||||
" The binary data to decompress.\n"
|
" The binary data to decompress.\n"
|
||||||
" max_length\n"
|
" max_length\n"
|
||||||
|
@ -663,14 +664,14 @@ PyDoc_STRVAR(zlib_decompress__doc__,
|
||||||
"internal buffers for later processing.\n"
|
"internal buffers for later processing.\n"
|
||||||
"Call the flush() method to clear these buffers.");
|
"Call the flush() method to clear these buffers.");
|
||||||
|
|
||||||
#define ZLIB_DECOMPRESS_METHODDEF \
|
#define ZLIB_DECOMPRESS_DECOMPRESS_METHODDEF \
|
||||||
{"decompress", (PyCFunction)zlib_decompress, METH_VARARGS, zlib_decompress__doc__},
|
{"decompress", (PyCFunction)zlib_Decompress_decompress, METH_VARARGS, zlib_Decompress_decompress__doc__},
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
zlib_decompress_impl(PyObject *self, Py_buffer *data, int max_length);
|
zlib_Decompress_decompress_impl(PyObject *self, Py_buffer *data, int max_length);
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
zlib_decompress(PyObject *self, PyObject *args)
|
zlib_Decompress_decompress(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
Py_buffer data;
|
Py_buffer data;
|
||||||
|
@ -680,7 +681,7 @@ zlib_decompress(PyObject *self, PyObject *args)
|
||||||
"y*|i:decompress",
|
"y*|i:decompress",
|
||||||
&data, &max_length))
|
&data, &max_length))
|
||||||
goto exit;
|
goto exit;
|
||||||
return_value = zlib_decompress_impl(self, &data, max_length);
|
return_value = zlib_Decompress_decompress_impl(self, &data, max_length);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
/* Cleanup for data */
|
/* Cleanup for data */
|
||||||
|
@ -690,8 +691,8 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
zlib_decompress_impl(PyObject *self, Py_buffer *data, int max_length)
|
zlib_Decompress_decompress_impl(PyObject *self, Py_buffer *data, int max_length)
|
||||||
/*[clinic checksum: 168d093d400739dde947cca1f4fb0f9d51cdc2c9]*/
|
/*[clinic checksum: bfac7a0f07e891869d87c665a76dc2611014420f]*/
|
||||||
{
|
{
|
||||||
compobject *zself = (compobject *)self;
|
compobject *zself = (compobject *)self;
|
||||||
int err;
|
int err;
|
||||||
|
@ -907,22 +908,23 @@ PyZlib_flush(compobject *self, PyObject *args)
|
||||||
|
|
||||||
/*[clinic]
|
/*[clinic]
|
||||||
|
|
||||||
zlib.copy
|
class zlib.Compress
|
||||||
|
zlib.Compress.copy
|
||||||
|
|
||||||
Return a copy of the compression object.
|
Return a copy of the compression object.
|
||||||
[clinic]*/
|
[clinic]*/
|
||||||
|
|
||||||
PyDoc_STRVAR(zlib_copy__doc__,
|
PyDoc_STRVAR(zlib_Compress_copy__doc__,
|
||||||
"Return a copy of the compression object.\n"
|
"Return a copy of the compression object.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"zlib.copy()");
|
"zlib.Compress.copy()");
|
||||||
|
|
||||||
#define ZLIB_COPY_METHODDEF \
|
#define ZLIB_COMPRESS_COPY_METHODDEF \
|
||||||
{"copy", (PyCFunction)zlib_copy, METH_NOARGS, zlib_copy__doc__},
|
{"copy", (PyCFunction)zlib_Compress_copy, METH_NOARGS, zlib_Compress_copy__doc__},
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
zlib_copy(PyObject *self)
|
zlib_Compress_copy(PyObject *self)
|
||||||
/*[clinic checksum: 7b648de2c1f933ba2b9fa17331ff1a44d9a4a740]*/
|
/*[clinic checksum: 2551952e72329f0f2beb48a1dde3780e485a220b]*/
|
||||||
{
|
{
|
||||||
compobject *zself = (compobject *)self;
|
compobject *zself = (compobject *)self;
|
||||||
compobject *retval = NULL;
|
compobject *retval = NULL;
|
||||||
|
@ -1118,14 +1120,14 @@ static PyMethodDef comp_methods[] =
|
||||||
{"flush", (binaryfunc)PyZlib_flush, METH_VARARGS,
|
{"flush", (binaryfunc)PyZlib_flush, METH_VARARGS,
|
||||||
comp_flush__doc__},
|
comp_flush__doc__},
|
||||||
#ifdef HAVE_ZLIB_COPY
|
#ifdef HAVE_ZLIB_COPY
|
||||||
ZLIB_COPY_METHODDEF
|
ZLIB_COMPRESS_COPY_METHODDEF
|
||||||
#endif
|
#endif
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyMethodDef Decomp_methods[] =
|
static PyMethodDef Decomp_methods[] =
|
||||||
{
|
{
|
||||||
ZLIB_DECOMPRESS_METHODDEF
|
ZLIB_DECOMPRESS_DECOMPRESS_METHODDEF
|
||||||
{"flush", (binaryfunc)PyZlib_unflush, METH_VARARGS,
|
{"flush", (binaryfunc)PyZlib_unflush, METH_VARARGS,
|
||||||
decomp_flush__doc__},
|
decomp_flush__doc__},
|
||||||
#ifdef HAVE_ZLIB_COPY
|
#ifdef HAVE_ZLIB_COPY
|
||||||
|
|
|
@ -2161,7 +2161,7 @@ dict_richcompare(PyObject *v, PyObject *w, int op)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*[clinic]
|
/*[clinic]
|
||||||
module dict
|
class dict
|
||||||
|
|
||||||
@coexist
|
@coexist
|
||||||
dict.__contains__
|
dict.__contains__
|
||||||
|
|
|
@ -12722,7 +12722,7 @@ unicode_swapcase(PyObject *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*[clinic]
|
/*[clinic]
|
||||||
module str
|
class str
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
str.maketrans as unicode_maketrans
|
str.maketrans as unicode_maketrans
|
||||||
|
|
|
@ -127,13 +127,13 @@ is_legal_c_identifier = re.compile('^[A-Za-z_][A-Za-z0-9_]*$').match
|
||||||
def is_legal_py_identifier(s):
|
def is_legal_py_identifier(s):
|
||||||
return all(is_legal_c_identifier(field) for field in s.split('.'))
|
return all(is_legal_c_identifier(field) for field in s.split('.'))
|
||||||
|
|
||||||
# added "self", "cls", and "null" just to be safe
|
# added "module", "self", "cls", and "null" just to be safe
|
||||||
# (clinic will generate variables with these names)
|
# (clinic will generate variables with these names)
|
||||||
c_keywords = set("""
|
c_keywords = set("""
|
||||||
asm auto break case char cls const continue default do double
|
asm auto break case char cls const continue default do double
|
||||||
else enum extern float for goto if inline int long null register
|
else enum extern float for goto if inline int long module null
|
||||||
return self short signed sizeof static struct switch typedef
|
register return self short signed sizeof static struct switch
|
||||||
typeof union unsigned void volatile while
|
typedef typeof union unsigned void volatile while
|
||||||
""".strip().split())
|
""".strip().split())
|
||||||
|
|
||||||
def ensure_legal_c_identifier(s):
|
def ensure_legal_c_identifier(s):
|
||||||
|
@ -620,7 +620,7 @@ static {impl_return_type}
|
||||||
else:
|
else:
|
||||||
if f.kind == CALLABLE:
|
if f.kind == CALLABLE:
|
||||||
meth_flags = ''
|
meth_flags = ''
|
||||||
self_name = "self"
|
self_name = "self" if f.cls else "module"
|
||||||
elif f.kind == CLASS_METHOD:
|
elif f.kind == CLASS_METHOD:
|
||||||
meth_flags = 'METH_CLASS'
|
meth_flags = 'METH_CLASS'
|
||||||
self_name = "cls"
|
self_name = "cls"
|
||||||
|
@ -1028,6 +1028,7 @@ class Clinic:
|
||||||
self.verify = verify
|
self.verify = verify
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.modules = collections.OrderedDict()
|
self.modules = collections.OrderedDict()
|
||||||
|
self.classes = collections.OrderedDict()
|
||||||
|
|
||||||
global clinic
|
global clinic
|
||||||
clinic = self
|
clinic = self
|
||||||
|
@ -1064,7 +1065,7 @@ class Clinic:
|
||||||
if not in_classes:
|
if not in_classes:
|
||||||
child = parent.modules.get(field)
|
child = parent.modules.get(field)
|
||||||
if child:
|
if child:
|
||||||
module = child
|
parent = module = child
|
||||||
continue
|
continue
|
||||||
in_classes = True
|
in_classes = True
|
||||||
if not hasattr(parent, 'classes'):
|
if not hasattr(parent, 'classes'):
|
||||||
|
@ -1129,6 +1130,9 @@ class Module:
|
||||||
self.classes = collections.OrderedDict()
|
self.classes = collections.OrderedDict()
|
||||||
self.functions = []
|
self.functions = []
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<clinic.Module " + repr(self.name) + " at " + str(id(self)) + ">"
|
||||||
|
|
||||||
class Class:
|
class Class:
|
||||||
def __init__(self, name, module=None, cls=None):
|
def __init__(self, name, module=None, cls=None):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -1139,6 +1143,10 @@ class Class:
|
||||||
self.classes = collections.OrderedDict()
|
self.classes = collections.OrderedDict()
|
||||||
self.functions = []
|
self.functions = []
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<clinic.Class " + repr(self.name) + " at " + str(id(self)) + ">"
|
||||||
|
|
||||||
|
|
||||||
DATA, CALLABLE, METHOD, STATIC_METHOD, CLASS_METHOD = range(5)
|
DATA, CALLABLE, METHOD, STATIC_METHOD, CLASS_METHOD = range(5)
|
||||||
|
|
||||||
class Function:
|
class Function:
|
||||||
|
@ -1808,13 +1816,11 @@ class DSLParser:
|
||||||
so_far = []
|
so_far = []
|
||||||
module, cls = self.clinic._module_and_class(fields)
|
module, cls = self.clinic._module_and_class(fields)
|
||||||
|
|
||||||
if not module:
|
|
||||||
fail("You must explicitly specify the module for the class.")
|
|
||||||
|
|
||||||
c = Class(name, module, cls)
|
c = Class(name, module, cls)
|
||||||
module.classes[name] = c
|
|
||||||
if cls:
|
if cls:
|
||||||
cls.classes[name] = c
|
cls.classes[name] = c
|
||||||
|
else:
|
||||||
|
module.classes[name] = c
|
||||||
self.block.signatures.append(c)
|
self.block.signatures.append(c)
|
||||||
|
|
||||||
def at_classmethod(self):
|
def at_classmethod(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue