homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vajrasky
Recipients larry, nadeem.vawda, serhiy.storchaka, vajrasky
Date 2014年01月20日.08:47:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1390207673.47.0.68688092526.issue20185@psf.upfronthosting.co.za>
In-reply-to
Content
Here is the patch for typeobject. I didn't convert the new method. It's so complicated. It counts whether how many arguments or keywords you pass. It asserts the args before parsing the args. I don't think clinic supports this.
This is the code:
 assert(args != NULL && PyTuple_Check(args));
 assert(kwds == NULL || PyDict_Check(kwds));
 /* Special case: type(x) should return x->ob_type */
 {
 const Py_ssize_t nargs = PyTuple_GET_SIZE(args);
 const Py_ssize_t nkwds = kwds == NULL ? 0 : PyDict_Size(kwds);
 if (PyType_CheckExact(metatype) && nargs == 1 && nkwds == 0) {
 PyObject *x = PyTuple_GET_ITEM(args, 0);
 Py_INCREF(Py_TYPE(x));
 return (PyObject *) Py_TYPE(x);
 }
 /* SF bug 475327 -- if that didn't trigger, we need 3
 arguments. but PyArg_ParseTupleAndKeywords below may give
 a msg saying type() needs exactly 3. */
 if (nargs + nkwds != 3) {
 PyErr_SetString(PyExc_TypeError,
 "type() takes 1 or 3 arguments");
 return NULL;
 }
 }
 /* Check arguments: (name, bases, dict) */
 if (!PyArg_ParseTupleAndKeywords(args, kwds, "UO!O!:type", kwlist,
 &name,
 &PyTuple_Type, &bases,
 &PyDict_Type, &orig_dict))
 return NULL;
History
Date User Action Args
2014年01月20日 08:47:53vajraskysetrecipients: + vajrasky, larry, nadeem.vawda, serhiy.storchaka
2014年01月20日 08:47:53vajraskysetmessageid: <1390207673.47.0.68688092526.issue20185@psf.upfronthosting.co.za>
2014年01月20日 08:47:53vajraskylinkissue20185 messages
2014年01月20日 08:47:53vajraskycreate

AltStyle によって変換されたページ (->オリジナル) /