diff options
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/complexobject.c | 6 | ||||
-rw-r--r-- | Objects/descrobject.c | 32 | ||||
-rw-r--r-- | Objects/dictobject.c | 75 | ||||
-rw-r--r-- | Objects/fileobject.c | 53 | ||||
-rw-r--r-- | Objects/iterobject.c | 4 | ||||
-rw-r--r-- | Objects/listobject.c | 57 | ||||
-rw-r--r-- | Objects/methodobject.c | 33 | ||||
-rw-r--r-- | Objects/rangeobject.c | 5 | ||||
-rw-r--r-- | Objects/stringobject.c | 159 | ||||
-rw-r--r-- | Objects/typeobject.c | 6 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 176 |
11 files changed, 223 insertions, 383 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c index 5cfb3ca..84eee11 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -580,18 +580,16 @@ complex_float(PyObject *v) } static PyObject * -complex_conjugate(PyObject *self, PyObject *args) +complex_conjugate(PyObject *self) { Py_complex c; - if (!PyArg_ParseTuple(args, ":conjugate")) - return NULL; c = ((PyComplexObject *)self)->cval; c.imag = -c.imag; return PyComplex_FromCComplex(c); } static PyMethodDef complex_methods[] = { - {"conjugate", complex_conjugate, 1}, + {"conjugate", (PyCFunction)complex_conjugate, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; diff --git a/Objects/descrobject.c b/Objects/descrobject.c index a2ecde5..facd1c4 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -601,12 +601,8 @@ static PySequenceMethods proxy_as_sequence = { }; static PyObject * -proxy_has_key(proxyobject *pp, PyObject *args) +proxy_has_key(proxyobject *pp, PyObject *key) { - PyObject *key; - - if (!PyArg_ParseTuple(args, "O:has_key", &key)) - return NULL; return PyInt_FromLong(PySequence_Contains(pp->dict, key)); } @@ -621,44 +617,36 @@ proxy_get(proxyobject *pp, PyObject *args) } static PyObject * -proxy_keys(proxyobject *pp, PyObject *args) +proxy_keys(proxyobject *pp) { - if (!PyArg_ParseTuple(args, ":keys")) - return NULL; return PyMapping_Keys(pp->dict); } static PyObject * -proxy_values(proxyobject *pp, PyObject *args) +proxy_values(proxyobject *pp) { - if (!PyArg_ParseTuple(args, ":values")) - return NULL; return PyMapping_Values(pp->dict); } static PyObject * -proxy_items(proxyobject *pp, PyObject *args) +proxy_items(proxyobject *pp) { - if (!PyArg_ParseTuple(args, ":items")) - return NULL; return PyMapping_Items(pp->dict); } static PyObject * -proxy_copy(proxyobject *pp, PyObject *args) +proxy_copy(proxyobject *pp) { - if (!PyArg_ParseTuple(args, ":copy")) - return NULL; return PyObject_CallMethod(pp->dict, "copy", NULL); } static PyMethodDef proxy_methods[] = { - {"has_key", (PyCFunction)proxy_has_key, METH_VARARGS, "XXX"}, + {"has_key", (PyCFunction)proxy_has_key, METH_O, "XXX"}, {"get", (PyCFunction)proxy_get, METH_VARARGS, "XXX"}, - {"keys", (PyCFunction)proxy_keys, METH_VARARGS, "XXX"}, - {"values", (PyCFunction)proxy_values, METH_VARARGS, "XXX"}, - {"items", (PyCFunction)proxy_items, METH_VARARGS, "XXX"}, - {"copy", (PyCFunction)proxy_copy, METH_VARARGS, "XXX"}, + {"keys", (PyCFunction)proxy_keys, METH_NOARGS, "XXX"}, + {"values", (PyCFunction)proxy_values, METH_NOARGS, "XXX"}, + {"items", (PyCFunction)proxy_items, METH_NOARGS, "XXX"}, + {"copy", (PyCFunction)proxy_copy, METH_NOARGS, "XXX"}, {0} }; diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 73c459f..ab5f4b5 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -875,13 +875,11 @@ static PyMappingMethods dict_as_mapping = { }; static PyObject * -dict_keys(register dictobject *mp, PyObject *args) +dict_keys(register dictobject *mp) { register PyObject *v; register int i, j, n; - if (!PyArg_NoArgs(args)) - return NULL; again: n = mp->ma_used; v = PyList_New(n); @@ -906,13 +904,11 @@ dict_keys(register dictobject *mp, PyObject *args) } static PyObject * -dict_values(register dictobject *mp, PyObject *args) +dict_values(register dictobject *mp) { register PyObject *v; register int i, j, n; - if (!PyArg_NoArgs(args)) - return NULL; again: n = mp->ma_used; v = PyList_New(n); @@ -937,14 +933,12 @@ dict_values(register dictobject *mp, PyObject *args) } static PyObject * -dict_items(register dictobject *mp, PyObject *args) +dict_items(register dictobject *mp) { register PyObject *v; register int i, j, n; PyObject *item, *key, *value; - if (!PyArg_NoArgs(args)) - return NULL; /* Preallocate the list of tuples, to avoid allocations during * the loop over the items, which could trigger GC, which * could resize the dict. :-( @@ -987,12 +981,8 @@ dict_items(register dictobject *mp, PyObject *args) } static PyObject * -dict_update(PyObject *mp, PyObject *args) +dict_update(PyObject *mp, PyObject *other) { - PyObject *other; - - if (!PyArg_ParseTuple(args, "O:update", &other)) - return NULL; if (PyDict_Update(mp, other) < 0) return NULL; Py_INCREF(Py_None); @@ -1099,10 +1089,8 @@ PyDict_Merge(PyObject *a, PyObject *b, int override) } static PyObject * -dict_copy(register dictobject *mp, PyObject *args) +dict_copy(register dictobject *mp) { - if (!PyArg_Parse(args, "")) - return NULL; return PyDict_Copy((PyObject*)mp); } @@ -1155,7 +1143,7 @@ PyDict_Keys(PyObject *mp) PyErr_BadInternalCall(); return NULL; } - return dict_keys((dictobject *)mp, (PyObject *)NULL); + return dict_keys((dictobject *)mp); } PyObject * @@ -1165,7 +1153,7 @@ PyDict_Values(PyObject *mp) PyErr_BadInternalCall(); return NULL; } - return dict_values((dictobject *)mp, (PyObject *)NULL); + return dict_values((dictobject *)mp); } PyObject * @@ -1175,7 +1163,7 @@ PyDict_Items(PyObject *mp) PyErr_BadInternalCall(); return NULL; } - return dict_items((dictobject *)mp, (PyObject *)NULL); + return dict_items((dictobject *)mp); } /* Subroutine which returns the smallest key in a for which b's value @@ -1366,13 +1354,10 @@ dict_richcompare(PyObject *v, PyObject *w, int op) } static PyObject * -dict_has_key(register dictobject *mp, PyObject *args) +dict_has_key(register dictobject *mp, PyObject *key) { - PyObject *key; long hash; register long ok; - if (!PyArg_ParseTuple(args, "O:has_key", &key)) - return NULL; #ifdef CACHE_HASH if (!PyString_Check(key) || (hash = ((PyStringObject *) key)->ob_shash) == -1) @@ -1447,24 +1432,20 @@ dict_setdefault(register dictobject *mp, PyObject *args) static PyObject * -dict_clear(register dictobject *mp, PyObject *args) +dict_clear(register dictobject *mp) { - if (!PyArg_NoArgs(args)) - return NULL; PyDict_Clear((PyObject *)mp); Py_INCREF(Py_None); return Py_None; } static PyObject * -dict_popitem(dictobject *mp, PyObject *args) +dict_popitem(dictobject *mp) { int i = 0; dictentry *ep; PyObject *res; - if (!PyArg_NoArgs(args)) - return NULL; /* Allocate the result tuple before checking the size. Believe it * or not, this allocation could trigger a garbage collection which * could empty the dict, so if we checked the size first and that @@ -1573,26 +1554,20 @@ select_item(PyObject *key, PyObject *value) } static PyObject * -dict_iterkeys(dictobject *dict, PyObject *args) +dict_iterkeys(dictobject *dict) { - if (!PyArg_ParseTuple(args, "")) - return NULL; return dictiter_new(dict, select_key); } static PyObject * -dict_itervalues(dictobject *dict, PyObject *args) +dict_itervalues(dictobject *dict) { - if (!PyArg_ParseTuple(args, "")) - return NULL; return dictiter_new(dict, select_value); } static PyObject * -dict_iteritems(dictobject *dict, PyObject *args) +dict_iteritems(dictobject *dict) { - if (!PyArg_ParseTuple(args, "")) - return NULL; return dictiter_new(dict, select_item); } @@ -1638,31 +1613,31 @@ static char iteritems__doc__[] = "D.iteritems() -> an iterator over the (key, value) items of D"; static PyMethodDef mapp_methods[] = { - {"has_key", (PyCFunction)dict_has_key, METH_VARARGS, + {"has_key", (PyCFunction)dict_has_key, METH_O, has_key__doc__}, {"get", (PyCFunction)dict_get, METH_VARARGS, get__doc__}, {"setdefault", (PyCFunction)dict_setdefault, METH_VARARGS, setdefault_doc__}, - {"popitem", (PyCFunction)dict_popitem, METH_OLDARGS, + {"popitem", (PyCFunction)dict_popitem, METH_NOARGS, popitem__doc__}, - {"keys", (PyCFunction)dict_keys, METH_OLDARGS, + {"keys", (PyCFunction)dict_keys, METH_NOARGS, keys__doc__}, - {"items", (PyCFunction)dict_items, METH_OLDARGS, + {"items", (PyCFunction)dict_items, METH_NOARGS, items__doc__}, - {"values", (PyCFunction)dict_values, METH_OLDARGS, + {"values", (PyCFunction)dict_values, METH_NOARGS, values__doc__}, - {"update", (PyCFunction)dict_update, METH_VARARGS, + {"update", (PyCFunction)dict_update, METH_O, update__doc__}, - {"clear", (PyCFunction)dict_clear, METH_OLDARGS, + {"clear", (PyCFunction)dict_clear, METH_NOARGS, clear__doc__}, - {"copy", (PyCFunction)dict_copy, METH_OLDARGS, + {"copy", (PyCFunction)dict_copy, METH_NOARGS, copy__doc__}, - {"iterkeys", (PyCFunction)dict_iterkeys, METH_VARARGS, + {"iterkeys", (PyCFunction)dict_iterkeys, METH_NOARGS, iterkeys__doc__}, - {"itervalues", (PyCFunction)dict_itervalues, METH_VARARGS, + {"itervalues", (PyCFunction)dict_itervalues, METH_NOARGS, itervalues__doc__}, - {"iteritems", (PyCFunction)dict_iteritems, METH_VARARGS, + {"iteritems", (PyCFunction)dict_iteritems, METH_NOARGS, iteritems__doc__}, {NULL, NULL} /* sentinel */ }; diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 946d41c..0bb2f25 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -189,11 +189,9 @@ file_repr(PyFileObject *f) } static PyObject * -file_close(PyFileObject *f, PyObject *args) +file_close(PyFileObject *f) { int sts = 0; - if (!PyArg_NoArgs(args)) - return NULL; if (f->f_fp != NULL) { if (f->f_close != NULL) { Py_BEGIN_ALLOW_THREADS @@ -386,14 +384,12 @@ onioerror: #endif /* HAVE_FTRUNCATE */ static PyObject * -file_tell(PyFileObject *f, PyObject *args) +file_tell(PyFileObject *f) { Py_off_t pos; if (f->f_fp == NULL) return err_closed(); - if (!PyArg_NoArgs(args)) - return NULL; Py_BEGIN_ALLOW_THREADS errno = 0; pos = _portable_ftell(f->f_fp); @@ -411,24 +407,20 @@ file_tell(PyFileObject *f, PyObject *args) } static PyObject * -file_fileno(PyFileObject *f, PyObject *args) +file_fileno(PyFileObject *f) { if (f->f_fp == NULL) return err_closed(); - if (!PyArg_NoArgs(args)) - return NULL; return PyInt_FromLong((long) fileno(f->f_fp)); } static PyObject * -file_flush(PyFileObject *f, PyObject *args) +file_flush(PyFileObject *f) { int res; if (f->f_fp == NULL) return err_closed(); - if (!PyArg_NoArgs(args)) - return NULL; Py_BEGIN_ALLOW_THREADS errno = 0; res = fflush(f->f_fp); @@ -443,13 +435,11 @@ file_flush(PyFileObject *f, PyObject *args) } static PyObject * -file_isatty(PyFileObject *f, PyObject *args) +file_isatty(PyFileObject *f) { long res; if (f->f_fp == NULL) return err_closed(); - if (!PyArg_NoArgs(args)) - return NULL; Py_BEGIN_ALLOW_THREADS res = isatty((int)fileno(f->f_fp)); Py_END_ALLOW_THREADS @@ -968,13 +958,10 @@ file_readline(PyFileObject *f, PyObject *args) } static PyObject * -file_xreadlines(PyFileObject *f, PyObject *args) +file_xreadlines(PyFileObject *f) { static PyObject* xreadlines_function = NULL; - if (!PyArg_ParseTuple(args, ":xreadlines")) - return NULL; - if (!xreadlines_function) { PyObject *xreadlines_module = PyImport_ImportModule("xreadlines"); @@ -1248,22 +1235,22 @@ file_writelines(PyFileObject *f, PyObject *args) } static PyMethodDef file_methods[] = { - {"readline", (PyCFunction)file_readline, 1}, - {"read", (PyCFunction)file_read, 1}, - {"write", (PyCFunction)file_write, 0}, - {"fileno", (PyCFunction)file_fileno, 0}, - {"seek", (PyCFunction)file_seek, 1}, + {"readline", (PyCFunction)file_readline, METH_VARARGS}, + {"read", (PyCFunction)file_read, METH_VARARGS}, + {"write", (PyCFunction)file_write, METH_OLDARGS}, + {"fileno", (PyCFunction)file_fileno, METH_NOARGS}, + {"seek", (PyCFunction)file_seek, METH_VARARGS}, #ifdef HAVE_FTRUNCATE - {"truncate", (PyCFunction)file_truncate, 1}, + {"truncate", (PyCFunction)file_truncate, METH_VARARGS}, #endif - {"tell", (PyCFunction)file_tell, 0}, - {"readinto", (PyCFunction)file_readinto, 0}, - {"readlines", (PyCFunction)file_readlines, 1}, - {"xreadlines", (PyCFunction)file_xreadlines, 1}, - {"writelines", (PyCFunction)file_writelines, 0}, - {"flush", (PyCFunction)file_flush, 0}, - {"close", (PyCFunction)file_close, 0}, - {"isatty", (PyCFunction)file_isatty, 0}, + {"tell", (PyCFunction)file_tell, METH_NOARGS}, + {"readinto", (PyCFunction)file_readinto, METH_OLDARGS}, + {"readlines", (PyCFunction)file_readlines, METH_VARARGS}, + {"xreadlines", (PyCFunction)file_xreadlines, METH_NOARGS}, + {"writelines", (PyCFunction)file_writelines, METH_O}, + {"flush", (PyCFunction)file_flush, METH_NOARGS}, + {"close", (PyCFunction)file_close, METH_NOARGS}, + {"isatty", (PyCFunction)file_isatty, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; diff --git a/Objects/iterobject.c b/Objects/iterobject.c index e062c8a..5783d20 100644 --- a/Objects/iterobject.c +++ b/Objects/iterobject.c @@ -37,7 +37,7 @@ iter_traverse(seqiterobject *it, visitproc visit, void *arg) } static PyObject * -iter_next(seqiterobject *it, PyObject *args) +iter_next(seqiterobject *it) { PyObject *seq = it->it_seq; PyObject *result = PySequence_GetItem(seq, it->it_index++); @@ -91,7 +91,7 @@ iter_iternext(PyObject *iterator) } static PyMethodDef iter_methods[] = { - {"next", (PyCFunction)iter_next, METH_VARARGS, + {"next", (PyCFunction)iter_next, METH_NOARGS, "it.next() -- get the next value, or raise StopIteration"}, {NULL, NULL} /* sentinel */ }; diff --git a/Objects/listobject.c b/Objects/listobject.c index b77cc0a..c45cf75 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -623,11 +623,8 @@ listinsert(PyListObject *self, PyObject *args) } static PyObject * -listappend(PyListObject *self, PyObject *args) +listappend(PyListObject *self, PyObject *v) { - PyObject *v; - if (!PyArg_ParseTuple(args, "O:append", &v)) - return NULL; return ins(self, (int) self->ob_size, v); } @@ -702,14 +699,9 @@ list_inplace_concat(PyListObject *self, PyObject *other) } static PyObject * -listextend(PyListObject *self, PyObject *args) +listextend(PyListObject *self, PyObject *b) { - PyObject *b; - - if (!PyArg_ParseTuple(args, "O:extend", &b)) - return NULL; - b = PySequence_Fast(b, "list.extend() argument must be iterable"); if (!b) return NULL; @@ -1344,10 +1336,8 @@ _listreverse(PyListObject *self) } static PyObject * -listreverse(PyListObject *self, PyObject *args) +listreverse(PyListObject *self) { - if (!PyArg_ParseTuple(args, ":reverse")) - return NULL; _listreverse(self); Py_INCREF(Py_None); return Py_None; @@ -1390,13 +1380,10 @@ PyList_AsTuple(PyObject *v) } static PyObject * -listindex(PyListObject *self, PyObject *args) +listindex(PyListObject *self, PyObject *v) { int i; - PyObject *v; - if (!PyArg_ParseTuple(args, "O:index", &v)) - return NULL; for (i = 0; i < self->ob_size; i++) { int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); if (cmp > 0) @@ -1409,14 +1396,11 @@ listindex(PyListObject *self, PyObject *args) } static PyObject * -listcount(PyListObject *self, PyObject *args) +listcount(PyListObject *self, PyObject *v) { int count = 0; int i; - PyObject *v; - if (!PyArg_ParseTuple(args, "O:count", &v)) - return NULL; for (i = 0; i < self->ob_size; i++) { int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); if (cmp > 0) @@ -1428,13 +1412,10 @@ listcount(PyListObject *self, PyObject *args) } static PyObject * -listremove(PyListObject *self, PyObject *args) +listremove(PyListObject *self, PyObject *v) { int i; - PyObject *v; - if (!PyArg_ParseTuple(args, "O:remove", &v)) - return NULL; for (i = 0; i < self->ob_size; i++) { int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); if (cmp > 0) { @@ -1661,14 +1642,14 @@ static char sort_doc[] = "L.sort([cmpfunc]) -- sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1"; static PyMethodDef list_methods[] = { - {"append", (PyCFunction)listappend, METH_VARARGS, append_doc}, + {"append", (PyCFunction)listappend, METH_O, append_doc}, {"insert", (PyCFunction)listinsert, METH_VARARGS, insert_doc}, - {"extend", (PyCFunction)listextend, METH_VARARGS, extend_doc}, + {"extend", (PyCFunction)listextend, METH_O, extend_doc}, {"pop", (PyCFunction)listpop, METH_VARARGS, pop_doc}, - {"remove", (PyCFunction)listremove, METH_VARARGS, remove_doc}, - {"index", (PyCFunction)listindex, METH_VARARGS, index_doc}, - {"count", (PyCFunction)listcount, METH_VARARGS, count_doc}, - {"reverse", (PyCFunction)listreverse, METH_VARARGS, reverse_doc}, + {"remove", (PyCFunction)listremove, METH_O, remove_doc}, + {"index", (PyCFunction)listindex, METH_O, index_doc}, + {"count", (PyCFunction)listcount, METH_O, count_doc}, + {"reverse", (PyCFunction)listreverse, METH_NOARGS, reverse_doc}, {"sort", (PyCFunction)listsort, METH_VARARGS, sort_doc}, {NULL, NULL} /* sentinel */ }; @@ -1749,13 +1730,13 @@ immutable_list_op(void) } static PyMethodDef immutable_list_methods[] = { - {"append", (PyCFunction)immutable_list_op}, - {"insert", (PyCFunction)immutable_list_op}, - {"remove", (PyCFunction)immutable_list_op}, - {"index", (PyCFunction)listindex}, - {"count", (PyCFunction)listcount}, - {"reverse", (PyCFunction)immutable_list_op}, - {"sort", (PyCFunction)immutable_list_op}, + {"append", (PyCFunction)immutable_list_op, METH_VARARGS}, + {"insert", (PyCFunction)immutable_list_op, METH_VARARGS}, + {"remove", (PyCFunction)immutable_list_op, METH_VARARGS}, + {"index", (PyCFunction)listindex, METH_O}, + {"count", (PyCFunction)listcount, METH_O}, + {"reverse", (PyCFunction)immutable_list_op, METH_VARARGS}, + {"sort", (PyCFunction)immutable_list_op, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; diff --git a/Objects/methodobject.c b/Objects/methodobject.c index 9d43044..cdba350 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -63,6 +63,7 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) PyCFunction meth = PyCFunction_GET_FUNCTION(func); PyObject *self = PyCFunction_GET_SELF(func); int flags = PyCFunction_GET_FLAGS(func); + int size = PyTuple_GET_SIZE(arg); if (flags & METH_KEYWORDS) { return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); @@ -73,21 +74,39 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) f->m_ml->ml_name); return NULL; } - if (flags & METH_VARARGS) { + + switch (flags) { + case METH_VARARGS: return (*meth)(self, arg); - } - if (!(flags & METH_VARARGS)) { + break; + case METH_NOARGS: + if (size == 0) + return (*meth)(self, NULL); + PyErr_Format(PyExc_TypeError, + "%.200s() takes no arguments (%d given)", + f->m_ml->ml_name, size); + return NULL; + break; + case METH_O: + if (size == 1) + return (*meth)(self, PyTuple_GET_ITEM(arg, 0)); + PyErr_Format(PyExc_TypeError, + "%.200s() takes exactly one argument (%d given)", + f->m_ml->ml_name, size); + return NULL; + break; + case METH_OLDARGS: /* the really old style */ - int size = PyTuple_GET_SIZE(arg); if (size == 1) arg = PyTuple_GET_ITEM(arg, 0); else if (size == 0) arg = NULL; return (*meth)(self, arg); + default: + /* should never get here ??? */ + PyErr_BadInternalCall(); + return NULL; } - /* should never get here ??? */ - PyErr_BadInternalCall(); - return NULL; } /* Methods (the standard built-in methods, that is) */ diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 9f155cf..5ad86ed 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -243,9 +243,6 @@ range_tolist(rangeobject *self, PyObject *args) WARN("xrange.tolist() is deprecated; use list(xrange) instead"); - if (! PyArg_ParseTuple(args, ":tolist")) - return NULL; - if (self->totlen == -1) return PyErr_NoMemory(); @@ -266,7 +263,7 @@ range_getattr(rangeobject *r, char *name) PyObject *result; static PyMethodDef range_methods[] = { - {"tolist", (PyCFunction)range_tolist, METH_VARARGS, + {"tolist", (PyCFunction)range_tolist, METH_NOARGS, "tolist() -> list\n" "Return a list object with the same values.\n" "(This method is deprecated; use list() instead.)"}, diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 3d12588..e2682a0 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -921,7 +921,7 @@ Return a string which is the concatenation of the strings in the\n\ sequence. The separator between elements is S."; static PyObject * -string_join(PyStringObject *self, PyObject *args) +string_join(PyStringObject *self, PyObject *orig) { char *sep = PyString_AS_STRING(self); const int seplen = PyString_GET_SIZE(self); @@ -930,10 +930,7 @@ string_join(PyStringObject *self, PyObject *args) int seqlen = 0; size_t sz = 0; int i; - PyObject *orig, *seq, *item; - - if (!PyArg_ParseTuple(args, "O:join", &orig)) - return NULL; + PyObject *seq, *item; seq = PySequence_Fast(orig, ""); if (seq == NULL) { @@ -1029,19 +1026,9 @@ string_join(PyStringObject *self, PyObject *args) PyObject * _PyString_Join(PyObject *sep, PyObject *x) { - PyObject* args; - PyObject* result = NULL; - assert(sep != NULL && PyString_Check(sep)); assert(x != NULL); - args = PyTuple_New(1); - if (args != NULL) { - Py_INCREF(x); - PyTuple_SET_ITEM(args, 0, x); - result = string_join((PyStringObject *)sep, args); - Py_DECREF(args); - } - return result; + return string_join((PyStringObject *)sep, x); } static long @@ -1176,14 +1163,11 @@ string_rindex(PyStringObject *self, PyObject *args) static PyObject * -do_strip(PyStringObject *self, PyObject *args, int striptype) +do_strip(PyStringObject *self, int striptype) { char *s = PyString_AS_STRING(self); int len = PyString_GET_SIZE(self), i, j; - if (!PyArg_ParseTuple(args, ":strip")) - return NULL; - i = 0; if (striptype != RIGHTSTRIP) { while (i < len && isspace(Py_CHARMASK(s[i]))) { @@ -1215,9 +1199,9 @@ Return a copy of the string S with leading and trailing\n\ whitespace removed."; static PyObject * -string_strip(PyStringObject *self, PyObject *args) +string_strip(PyStringObject *self) { - return do_strip(self, args, BOTHSTRIP); + return do_strip(self, BOTHSTRIP); } @@ -1227,9 +1211,9 @@ static char lstrip__doc__[] = Return a copy of the string S with leading whitespace removed."; static PyObject * -string_lstrip(PyStringObject *self, PyObject *args) +string_lstrip(PyStringObject *self) { - return do_strip(self, args, LEFTSTRIP); + return do_strip(self, LEFTSTRIP); } @@ -1239,9 +1223,9 @@ static char rstrip__doc__[] = Return a copy of the string S with trailing whitespace removed."; static PyObject * -string_rstrip(PyStringObject *self, PyObject *args) +string_rstrip(PyStringObject *self) { - return do_strip(self, args, RIGHTSTRIP); + return do_strip(self, RIGHTSTRIP); } @@ -1251,14 +1235,12 @@ static char lower__doc__[] = Return a copy of the string S converted to lowercase."; static PyObject * -string_lower(PyStringObject *self, PyObject *args) +string_lower(PyStringObject *self) { char *s = PyString_AS_STRING(self), *s_new; int i, n = PyString_GET_SIZE(self); PyObject *new; - if (!PyArg_ParseTuple(args, ":lower")) - return NULL; new = PyString_FromStringAndSize(NULL, n); if (new == NULL) return NULL; @@ -1281,14 +1263,12 @@ static char upper__doc__[] = Return a copy of the string S converted to uppercase."; static PyObject * -string_upper(PyStringObject *self, PyObject *args) +string_upper(PyStringObject *self) { char *s = PyString_AS_STRING(self), *s_new; int i, n = PyString_GET_SIZE(self); PyObject *new; - if (!PyArg_ParseTuple(args, ":upper")) - return NULL; new = PyString_FromStringAndSize(NULL, n); if (new == NULL) return NULL; @@ -1312,15 +1292,13 @@ Return a titlecased version of S, i.e. words start with uppercase\n\ characters, all remaining cased characters have lowercase."; static PyObject* -string_title(PyStringObject *self, PyObject *args) +string_title(PyStringObject *self) { char *s = PyString_AS_STRING(self), *s_new; int i, n = PyString_GET_SIZE(self); int previous_is_cased = 0; PyObject *new; - if (!PyArg_ParseTuple(args, ":title")) - return NULL; new = PyString_FromStringAndSize(NULL, n); if (new == NULL) return NULL; @@ -1349,14 +1327,12 @@ Return a copy of the string S with only its first character\n\ capitalized."; static PyObject * -string_capitalize(PyStringObject *self, PyObject *args) +string_capitalize(PyStringObject *self) { char *s = PyString_AS_STRING(self), *s_new; int i, n = PyString_GET_SIZE(self); PyObject *new; - if (!PyArg_ParseTuple(args, ":capitalize")) - return NULL; new = PyString_FromStringAndSize(NULL, n); if (new == NULL) return NULL; @@ -1450,14 +1426,12 @@ Return a copy of the string S with uppercase characters\n\ converted to lowercase and vice versa."; static PyObject * -string_swapcase(PyStringObject *self, PyObject *args) +string_swapcase(PyStringObject *self) { char *s = PyString_AS_STRING(self), *s_new; int i, n = PyString_GET_SIZE(self); PyObject *new; - if (!PyArg_ParseTuple(args, ":swapcase")) - return NULL; new = PyString_FromStringAndSize(NULL, n); if (new == NULL) return NULL; @@ -2150,15 +2124,12 @@ Return 1 if there are only whitespace characters in S,\n\ 0 otherwise."; static PyObject* -string_isspace(PyStringObject *self, PyObject *args) +string_isspace(PyStringObject *self) { register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); register const unsigned char *e; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyString_GET_SIZE(self) == 1 && isspace(*p)) @@ -2184,15 +2155,12 @@ Return 1 if all characters in S are alphabetic\n\ and there is at least one character in S, 0 otherwise."; static PyObject* -string_isalpha(PyStringObject *self, PyObject *args) +string_isalpha(PyStringObject *self) { register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); register const unsigned char *e; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyString_GET_SIZE(self) == 1 && isalpha(*p)) @@ -2218,15 +2186,12 @@ Return 1 if all characters in S are alphanumeric\n\ and there is at least one character in S, 0 otherwise."; static PyObject* -string_isalnum(PyStringObject *self, PyObject *args) +string_isalnum(PyStringObject *self) { register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); register const unsigned char *e; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyString_GET_SIZE(self) == 1 && isalnum(*p)) @@ -2252,15 +2217,12 @@ Return 1 if there are only digit characters in S,\n\ 0 otherwise."; static PyObject* -string_isdigit(PyStringObject *self, PyObject *args) +string_isdigit(PyStringObject *self) { register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); register const unsigned char *e; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyString_GET_SIZE(self) == 1 && isdigit(*p)) @@ -2286,16 +2248,13 @@ Return 1 if all cased characters in S are lowercase and there is\n\ at least one cased character in S, 0 otherwise."; static PyObject* -string_islower(PyStringObject *self, PyObject *args) +string_islower(PyStringObject *self) { register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); register const unsigned char *e; int cased; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyString_GET_SIZE(self) == 1) return PyInt_FromLong(islower(*p) != 0); @@ -2323,16 +2282,13 @@ Return 1 if all cased characters in S are uppercase and there is\n\ at least one cased character in S, 0 otherwise."; static PyObject* -string_isupper(PyStringObject *self, PyObject *args) +string_isupper(PyStringObject *self) { register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); register const unsigned char *e; int cased; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyString_GET_SIZE(self) == 1) return PyInt_FromLong(isupper(*p) != 0); @@ -2361,16 +2317,13 @@ may only follow uncased characters and lowercase characters only cased\n\ ones. Return 0 otherwise."; static PyObject* -string_istitle(PyStringObject *self, PyObject *args) +string_istitle(PyStringObject *self, PyObject *uncased) { register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); register const unsigned char *e; int cased, previous_is_cased; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyString_GET_SIZE(self) == 1) return PyInt_FromLong(isupper(*p) != 0); @@ -2482,41 +2435,41 @@ static PyMethodDef string_methods[] = { /* Counterparts of the obsolete stropmodule functions; except string.maketrans(). */ - {"join", (PyCFunction)string_join, 1, join__doc__}, - {"split", (PyCFunction)string_split, 1, split__doc__}, - {"lower", (PyCFunction)string_lower, 1, lower__doc__}, - {"upper", (PyCFunction)string_upper, 1, upper__doc__}, - {"islower", (PyCFunction)string_islower, 0, islower__doc__}, - {"isupper", (PyCFunction)string_isupper, 0, isupper__doc__}, - {"isspace", (PyCFunction)string_isspace, 0, isspace__doc__}, - {"isdigit", (PyCFunction)string_isdigit, 0, isdigit__doc__}, - {"istitle", (PyCFunction)string_istitle, 0, istitle__doc__}, - {"isalpha", (PyCFunction)string_isalpha, 0, isalpha__doc__}, - {"isalnum", (PyCFunction)string_isalnum, 0, isalnum__doc__}, - {"capitalize", (PyCFunction)string_capitalize, 1, capitalize__doc__}, - {"count", (PyCFunction)string_count, 1, count__doc__}, - {"endswith", (PyCFunction)string_endswith, 1, endswith__doc__}, - {"find", (PyCFunction)string_find, 1, find__doc__}, - {"index", (PyCFunction)string_index, 1, index__doc__}, - {"lstrip", (PyCFunction)string_lstrip, 1, lstrip__doc__}, - {"replace", (PyCFunction)string_replace, 1, replace__doc__}, - {"rfind", (PyCFunction)string_rfind, 1, rfind__doc__}, - {"rindex", (PyCFunction)string_rindex, 1, rindex__doc__}, - {"rstrip", (PyCFunction)string_rstrip, 1, rstrip__doc__}, - {"startswith", (PyCFunction)string_startswith, 1, startswith__doc__}, - {"strip", (PyCFunction)string_strip, 1, strip__doc__}, - {"swapcase", (PyCFunction)string_swapcase, 1, swapcase__doc__}, - {"translate", (PyCFunction)string_translate, 1, translate__doc__}, - {"title", (PyCFunction)string_title, 1, title__doc__}, - {"ljust", (PyCFunction)string_ljust, 1, ljust__doc__}, - {"rjust", (PyCFunction)string_rjust, 1, rjust__doc__}, - {"center", (PyCFunction)string_center, 1, center__doc__}, - {"encode", (PyCFunction)string_encode, 1, encode__doc__}, - {"decode", (PyCFunction)string_decode, 1, decode__doc__}, - {"expandtabs", (PyCFunction)string_expandtabs, 1, expandtabs__doc__}, - {"splitlines", (PyCFunction)string_splitlines, 1, splitlines__doc__}, + {"join", (PyCFunction)string_join, METH_O, join__doc__}, + {"split", (PyCFunction)string_split, METH_VARARGS, split__doc__}, + {"lower", (PyCFunction)string_lower, METH_NOARGS, lower__doc__}, + {"upper", (PyCFunction)string_upper, METH_NOARGS, upper__doc__}, + {"islower", (PyCFunction)string_islower, METH_NOARGS, islower__doc__}, + {"isupper", (PyCFunction)string_isupper, METH_NOARGS, isupper__doc__}, + {"isspace", (PyCFunction)string_isspace, METH_NOARGS, isspace__doc__}, + {"isdigit", (PyCFunction)string_isdigit, METH_NOARGS, isdigit__doc__}, + {"istitle", (PyCFunction)string_istitle, METH_NOARGS, istitle__doc__}, + {"isalpha", (PyCFunction)string_isalpha, METH_NOARGS, isalpha__doc__}, + {"isalnum", (PyCFunction)string_isalnum, METH_NOARGS, isalnum__doc__}, + {"capitalize", (PyCFunction)string_capitalize, METH_NOARGS, capitalize__doc__}, + {"count", (PyCFunction)string_count, METH_VARARGS, count__doc__}, + {"endswith", (PyCFunction)string_endswith, METH_VARARGS, endswith__doc__}, + {"find", (PyCFunction)string_find, METH_VARARGS, find__doc__}, + {"index", (PyCFunction)string_index, METH_VARARGS, index__doc__}, + {"lstrip", (PyCFunction)string_lstrip, METH_NOARGS, lstrip__doc__}, + {"replace", (PyCFunction)string_replace, METH_VARARGS, replace__doc__}, + {"rfind", (PyCFunction)string_rfind, METH_VARARGS, rfind__doc__}, + {"rindex", (PyCFunction)string_rindex, METH_VARARGS, rindex__doc__}, + {"rstrip", (PyCFunction)string_rstrip, METH_NOARGS, rstrip__doc__}, + {"startswith", (PyCFunction)string_startswith, METH_VARARGS, startswith__doc__}, + {"strip", (PyCFunction)string_strip, METH_NOARGS, strip__doc__}, + {"swapcase", (PyCFunction)string_swapcase, METH_NOARGS, swapcase__doc__}, + {"translate", (PyCFunction)string_translate, METH_VARARGS, translate__doc__}, + {"title", (PyCFunction)string_title, METH_NOARGS, title__doc__}, + {"ljust", (PyCFunction)string_ljust, METH_VARARGS, ljust__doc__}, + {"rjust", (PyCFunction)string_rjust, METH_VARARGS, rjust__doc__}, + {"center", (PyCFunction)string_center, METH_VARARGS, center__doc__}, + {"encode", (PyCFunction)string_encode, METH_VARARGS, encode__doc__}, + {"decode", (PyCFunction)string_decode, METH_VARARGS, decode__doc__}, + {"expandtabs", (PyCFunction)string_expandtabs, METH_VARARGS, expandtabs__doc__}, + {"splitlines", (PyCFunction)string_splitlines, METH_VARARGS, splitlines__doc__}, #if 0 - {"zfill", (PyCFunction)string_zfill, 1, zfill__doc__}, + {"zfill", (PyCFunction)string_zfill, METH_VARARGS, zfill__doc__}, #endif {NULL, NULL} /* sentinel */ }; diff --git a/Objects/typeobject.c b/Objects/typeobject.c index c4dc364..f7f2c97 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -376,12 +376,10 @@ mro_implementation(PyTypeObject *type) } static PyObject * -mro_external(PyObject *self, PyObject *args) +mro_external(PyObject *self) { PyTypeObject *type = (PyTypeObject *)self; - if (!PyArg_ParseTuple(args, "")) - return NULL; return mro_implementation(type); } @@ -845,7 +843,7 @@ type_dealloc(PyTypeObject *type) } static PyMethodDef type_methods[] = { - {"mro", mro_external, METH_VARARGS, + {"mro", (PyCFunction)mro_external, METH_NOARGS, "mro() -> list\nreturn a type's method resolution order"}, {0} }; diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 8bd1287..c25c5ac 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3251,10 +3251,8 @@ Return a titlecased version of S, i.e. words start with title case\n\ characters, all remaining cased characters have lower case."; static PyObject* -unicode_title(PyUnicodeObject *self, PyObject *args) +unicode_title(PyUnicodeObject *self) { - if (!PyArg_NoArgs(args)) - return NULL; return fixup(self, fixtitle); } @@ -3265,10 +3263,8 @@ Return a capitalized version of S, i.e. make the first character\n\ have upper case."; static PyObject* -unicode_capitalize(PyUnicodeObject *self, PyObject *args) +unicode_capitalize(PyUnicodeObject *self) { - if (!PyArg_NoArgs(args)) - return NULL; return fixup(self, fixcapitalize); } @@ -3280,15 +3276,12 @@ Apply .capitalize() to all words in S and return the result with\n\ normalized whitespace (all whitespace strings are replaced by ' ')."; static PyObject* -unicode_capwords(PyUnicodeObject *self, PyObject *args) +unicode_capwords(PyUnicodeObject *self) { PyObject *list; PyObject *item; int i; - if (!PyArg_NoArgs(args)) - return NULL; - /* Split into words */ list = split(self, NULL, -1); if (!list) @@ -3771,15 +3764,12 @@ Return 1 if all cased characters in S are lowercase and there is\n\ at least one cased character in S, 0 otherwise."; static PyObject* -unicode_islower(PyUnicodeObject *self, PyObject *args) +unicode_islower(PyUnicodeObject *self) { register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); register const Py_UNICODE *e; int cased; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyUnicode_GET_SIZE(self) == 1) return PyInt_FromLong(Py_UNICODE_ISLOWER(*p) != 0); @@ -3808,15 +3798,12 @@ Return 1 if all cased characters in S are uppercase and there is\n\ at least one cased character in S, 0 otherwise."; static PyObject* -unicode_isupper(PyUnicodeObject *self, PyObject *args) +unicode_isupper(PyUnicodeObject *self) { register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); register const Py_UNICODE *e; int cased; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyUnicode_GET_SIZE(self) == 1) return PyInt_FromLong(Py_UNICODE_ISUPPER(*p) != 0); @@ -3846,15 +3833,12 @@ may only follow uncased characters and lowercase characters only cased\n\ ones. Return 0 otherwise."; static PyObject* -unicode_istitle(PyUnicodeObject *self, PyObject *args) +unicode_istitle(PyUnicodeObject *self) { register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); register const Py_UNICODE *e; int cased, previous_is_cased; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyUnicode_GET_SIZE(self) == 1) return PyInt_FromLong((Py_UNICODE_ISTITLE(*p) != 0) || @@ -3895,14 +3879,11 @@ Return 1 if there are only whitespace characters in S,\n\ 0 otherwise."; static PyObject* -unicode_isspace(PyUnicodeObject *self, PyObject *args) +unicode_isspace(PyUnicodeObject *self) { register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); register const Py_UNICODE *e; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyUnicode_GET_SIZE(self) == 1 && Py_UNICODE_ISSPACE(*p)) @@ -3927,14 +3908,11 @@ Return 1 if all characters in S are alphabetic\n\ and there is at least one character in S, 0 otherwise."; static PyObject* -unicode_isalpha(PyUnicodeObject *self, PyObject *args) +unicode_isalpha(PyUnicodeObject *self) { register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); register const Py_UNICODE *e; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyUnicode_GET_SIZE(self) == 1 && Py_UNICODE_ISALPHA(*p)) @@ -3959,14 +3937,11 @@ Return 1 if all characters in S are alphanumeric\n\ and there is at least one character in S, 0 otherwise."; static PyObject* -unicode_isalnum(PyUnicodeObject *self, PyObject *args) +unicode_isalnum(PyUnicodeObject *self) { register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); register const Py_UNICODE *e; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyUnicode_GET_SIZE(self) == 1 && Py_UNICODE_ISALNUM(*p)) @@ -3991,14 +3966,11 @@ Return 1 if there are only decimal characters in S,\n\ 0 otherwise."; static PyObject* -unicode_isdecimal(PyUnicodeObject *self, PyObject *args) +unicode_isdecimal(PyUnicodeObject *self) { register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); register const Py_UNICODE *e; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyUnicode_GET_SIZE(self) == 1 && Py_UNICODE_ISDECIMAL(*p)) @@ -4023,14 +3995,11 @@ Return 1 if there are only digit characters in S,\n\ 0 otherwise."; static PyObject* -unicode_isdigit(PyUnicodeObject *self, PyObject *args) +unicode_isdigit(PyUnicodeObject *self) { register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); register const Py_UNICODE *e; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyUnicode_GET_SIZE(self) == 1 && Py_UNICODE_ISDIGIT(*p)) @@ -4055,14 +4024,11 @@ Return 1 if there are only numeric characters in S,\n\ 0 otherwise."; static PyObject* -unicode_isnumeric(PyUnicodeObject *self, PyObject *args) +unicode_isnumeric(PyUnicodeObject *self) { register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); register const Py_UNICODE *e; - if (!PyArg_NoArgs(args)) - return NULL; - /* Shortcut for single character strings */ if (PyUnicode_GET_SIZE(self) == 1 && Py_UNICODE_ISNUMERIC(*p)) @@ -4087,13 +4053,9 @@ Return a string which is the concatenation of the strings in the\n\ sequence. The separator between elements is S."; static PyObject* -unicode_join(PyUnicodeObject *self, PyObject *args) +unicode_join(PyObject *self, PyObject *data) { - PyObject *data; - if (!PyArg_ParseTuple(args, "O:join", &data)) - return NULL; - - return PyUnicode_Join((PyObject *)self, data); + return PyUnicode_Join(self, data); } static int @@ -4129,10 +4091,8 @@ static char lower__doc__[] = Return a copy of the string S converted to lowercase."; static PyObject* -unicode_lower(PyUnicodeObject *self, PyObject *args) +unicode_lower(PyUnicodeObject *self) { - if (!PyArg_NoArgs(args)) - return NULL; return fixup(self, fixlower); } @@ -4142,10 +4102,8 @@ static char lstrip__doc__[] = Return a copy of the string S with leading whitespace removed."; static PyObject * -unicode_lstrip(PyUnicodeObject *self, PyObject *args) +unicode_lstrip(PyUnicodeObject *self) { - if (!PyArg_NoArgs(args)) - return NULL; return strip(self, 1, 0); } @@ -4357,10 +4315,8 @@ static char rstrip__doc__[] = Return a copy of the string S with trailing whitespace removed."; static PyObject * -unicode_rstrip(PyUnicodeObject *self, PyObject *args) +unicode_rstrip(PyUnicodeObject *self) { - if (!PyArg_NoArgs(args)) - return NULL; return strip(self, 0, 1); } @@ -4465,10 +4421,8 @@ static char strip__doc__[] = Return a copy of S with leading and trailing whitespace removed."; static PyObject * -unicode_strip(PyUnicodeObject *self, PyObject *args) +unicode_strip(PyUnicodeObject *self) { - if (!PyArg_NoArgs(args)) - return NULL; return strip(self, 1, 1); } @@ -4479,10 +4433,8 @@ Return a copy of S with uppercase characters converted to lowercase\n\ and vice versa."; static PyObject* -unicode_swapcase(PyUnicodeObject *self, PyObject *args) +unicode_swapcase(PyUnicodeObject *self) { - if (!PyArg_NoArgs(args)) - return NULL; return fixup(self, fixswapcase); } @@ -4495,12 +4447,8 @@ Unicode ordinals to Unicode ordinals or None. Unmapped characters\n\ are left untouched. Characters mapped to None are deleted."; static PyObject* -unicode_translate(PyUnicodeObject *self, PyObject *args) +unicode_translate(PyUnicodeObject *self, PyObject *table) { - PyObject *table; - - if (!PyArg_ParseTuple(args, "O:translate", &table)) - return NULL; return PyUnicode_TranslateCharmap(self->str, self->length, table, @@ -4513,10 +4461,8 @@ static char upper__doc__[] = Return a copy of S converted to uppercase."; static PyObject* -unicode_upper(PyUnicodeObject *self, PyObject *args) +unicode_upper(PyUnicodeObject *self) { - if (!PyArg_NoArgs(args)) - return NULL; return fixup(self, fixupper); } @@ -4558,10 +4504,8 @@ unicode_zfill(PyUnicodeObject *self, PyObject *args) #if 0 static PyObject* -unicode_freelistsize(PyUnicodeObject *self, PyObject *args) +unicode_freelistsize(PyUnicodeObject *self) { - if (!PyArg_NoArgs(args)) - return NULL; return PyInt_FromLong(unicode_freelist_size); } #endif @@ -4633,49 +4577,49 @@ static PyMethodDef unicode_methods[] = { /* Order is according to common usage: often used methods should appear first, since lookup is done sequentially. */ - {"encode", (PyCFunction) unicode_encode, 1, encode__doc__}, - {"replace", (PyCFunction) unicode_replace, 1, replace__doc__}, - {"split", (PyCFunction) unicode_split, 1, split__doc__}, - {"join", (PyCFunction) unicode_join, 1, join__doc__}, - {"capitalize", (PyCFunction) unicode_capitalize, 0, capitalize__doc__}, - {"title", (PyCFunction) unicode_title, 0, title__doc__}, - {"center", (PyCFunction) unicode_center, 1, center__doc__}, - {"count", (PyCFunction) unicode_count, 1, count__doc__}, - {"expandtabs", (PyCFunction) unicode_expandtabs, 1, expandtabs__doc__}, - {"find", (PyCFunction) unicode_find, 1, find__doc__}, - {"index", (PyCFunction) unicode_index, 1, index__doc__}, - {"ljust", (PyCFunction) unicode_ljust, 1, ljust__doc__}, - {"lower", (PyCFunction) unicode_lower, 0, lower__doc__}, - {"lstrip", (PyCFunction) unicode_lstrip, 0, lstrip__doc__}, -/* {"maketrans", (PyCFunction) unicode_maketrans, 1, maketrans__doc__}, */ - {"rfind", (PyCFunction) unicode_rfind, 1, rfind__doc__}, - {"rindex", (PyCFunction) unicode_rindex, 1, rindex__doc__}, - {"rjust", (PyCFunction) unicode_rjust, 1, rjust__doc__}, - {"rstrip", (PyCFunction) unicode_rstrip, 0, rstrip__doc__}, - {"splitlines", (PyCFunction) unicode_splitlines, 1, splitlines__doc__}, - {"strip", (PyCFunction) unicode_strip, 0, strip__doc__}, - {"swapcase", (PyCFunction) unicode_swapcase, 0, swapcase__doc__}, - {"translate", (PyCFunction) unicode_translate, 1, translate__doc__}, - {"upper", (PyCFunction) unicode_upper, 0, upper__doc__}, - {"startswith", (PyCFunction) unicode_startswith, 1, startswith__doc__}, - {"endswith", (PyCFunction) unicode_endswith, 1, endswith__doc__}, - {"islower", (PyCFunction) unicode_islower, 0, islower__doc__}, - {"isupper", (PyCFunction) unicode_isupper, 0, isupper__doc__}, - {"istitle", (PyCFunction) unicode_istitle, 0, istitle__doc__}, - {"isspace", (PyCFunction) unicode_isspace, 0, isspace__doc__}, - {"isdecimal", (PyCFunction) unicode_isdecimal, 0, isdecimal__doc__}, - {"isdigit", (PyCFunction) unicode_isdigit, 0, isdigit__doc__}, - {"isnumeric", (PyCFunction) unicode_isnumeric, 0, isnumeric__doc__}, - {"isalpha", (PyCFunction) unicode_isalpha, 0, isalpha__doc__}, - {"isalnum", (PyCFunction) unicode_isalnum, 0, isalnum__doc__}, + {"encode", (PyCFunction) unicode_encode, METH_VARARGS, encode__doc__}, + {"replace", (PyCFunction) unicode_replace, METH_VARARGS, replace__doc__}, + {"split", (PyCFunction) unicode_split, METH_VARARGS, split__doc__}, + {"join", (PyCFunction) unicode_join, METH_O, join__doc__}, + {"capitalize", (PyCFunction) unicode_capitalize, METH_NOARGS, capitalize__doc__}, + {"title", (PyCFunction) unicode_title, METH_NOARGS, title__doc__}, + {"center", (PyCFunction) unicode_center, METH_VARARGS, center__doc__}, + {"count", (PyCFunction) unicode_count, METH_VARARGS, count__doc__}, + {"expandtabs", (PyCFunction) unicode_expandtabs, METH_VARARGS, expandtabs__doc__}, + {"find", (PyCFunction) unicode_find, METH_VARARGS, find__doc__}, + {"index", (PyCFunction) unicode_index, METH_VARARGS, index__doc__}, + {"ljust", (PyCFunction) unicode_ljust, METH_VARARGS, ljust__doc__}, + {"lower", (PyCFunction) unicode_lower, METH_NOARGS, lower__doc__}, + {"lstrip", (PyCFunction) unicode_lstrip, METH_NOARGS, lstrip__doc__}, +/* {"maketrans", (PyCFunction) unicode_maketrans, METH_VARARGS, maketrans__doc__}, */ + {"rfind", (PyCFunction) unicode_rfind, METH_VARARGS, rfind__doc__}, + {"rindex", (PyCFunction) unicode_rindex, METH_VARARGS, rindex__doc__}, + {"rjust", (PyCFunction) unicode_rjust, METH_VARARGS, rjust__doc__}, + {"rstrip", (PyCFunction) unicode_rstrip, METH_NOARGS, rstrip__doc__}, + {"splitlines", (PyCFunction) unicode_splitlines, METH_VARARGS, splitlines__doc__}, + {"strip", (PyCFunction) unicode_strip, METH_NOARGS, strip__doc__}, + {"swapcase", (PyCFunction) unicode_swapcase, METH_NOARGS, swapcase__doc__}, + {"translate", (PyCFunction) unicode_translate, METH_O, translate__doc__}, + {"upper", (PyCFunction) unicode_upper, METH_NOARGS, upper__doc__}, + {"startswith", (PyCFunction) unicode_startswith, METH_VARARGS, startswith__doc__}, + {"endswith", (PyCFunction) unicode_endswith, METH_VARARGS, endswith__doc__}, + {"islower", (PyCFunction) unicode_islower, METH_NOARGS, islower__doc__}, + {"isupper", (PyCFunction) unicode_isupper, METH_NOARGS, isupper__doc__}, + {"istitle", (PyCFunction) unicode_istitle, METH_NOARGS, istitle__doc__}, + {"isspace", (PyCFunction) unicode_isspace, METH_NOARGS, isspace__doc__}, + {"isdecimal", (PyCFunction) unicode_isdecimal, METH_NOARGS, isdecimal__doc__}, + {"isdigit", (PyCFunction) unicode_isdigit, METH_NOARGS, isdigit__doc__}, + {"isnumeric", (PyCFunction) unicode_isnumeric, METH_NOARGS, isnumeric__doc__}, + {"isalpha", (PyCFunction) unicode_isalpha, METH_NOARGS, isalpha__doc__}, + {"isalnum", (PyCFunction) unicode_isalnum, METH_NOARGS, isalnum__doc__}, #if 0 - {"zfill", (PyCFunction) unicode_zfill, 1, zfill__doc__}, - {"capwords", (PyCFunction) unicode_capwords, 0, capwords__doc__}, + {"zfill", (PyCFunction) unicode_zfill, METH_VARARGS, zfill__doc__}, + {"capwords", (PyCFunction) unicode_capwords, METH_NOARGS, capwords__doc__}, #endif #if 0 /* This one is just used for debugging the implementation. */ - {"freelistsize", (PyCFunction) unicode_freelistsize, 0}, + {"freelistsize", (PyCFunction) unicode_freelistsize, METH_NOARGS}, #endif {NULL, NULL} |