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