cpython: 84c3be27b4c7 (original) (raw)

Mercurial > cpython

changeset 71614:84c3be27b4c7

make the types of None and Ellipsis callable

Benjamin Peterson benjamin@python.org
date Fri, 29 Jul 2011 18:19:43 -0500
parents a6afd26caa8a
children 50dd507a38d8
files Lib/test/test_builtin.py Misc/NEWS Objects/object.c Objects/sliceobject.c
diffstat 4 files changed, 73 insertions(+), 0 deletions(-)[+] [-] Lib/test/test_builtin.py 7 Misc/NEWS 3 Objects/object.c 34 Objects/sliceobject.c 29

line wrap: on

line diff

--- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1343,6 +1343,13 @@ class BuiltinTest(unittest.TestCase): self.assertRaises(ValueError, x.translate, b"1", 1) self.assertRaises(TypeError, x.translate, b"1"*256, 1)

+ class TestSorted(unittest.TestCase): def test_basic(self):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1? Core and Builtins ----------------- +- Make type(None) and type(Ellipsis) callable. They return the respective

--- a/Objects/object.c +++ b/Objects/object.c @@ -1277,6 +1277,16 @@ none_dealloc(PyObject* ignore) Py_FatalError("deallocating None"); } +static PyObject * +none_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{

+} + static int none_bool(PyObject *v) { @@ -1335,6 +1345,30 @@ static PyTypeObject PyNone_Type = { 0, /tp_as_sequence/ 0, /tp_as_mapping/ 0, /*tp_hash */

}; PyObject _Py_NoneStruct = {

--- a/Objects/sliceobject.c +++ b/Objects/sliceobject.c @@ -17,6 +17,17 @@ this type and there is exactly one in ex #include "structmember.h" static PyObject * +ellipsis_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{

+} + +static PyObject * ellipsis_repr(PyObject op) { return PyUnicode_FromString("Ellipsis"); @@ -43,6 +54,24 @@ PyTypeObject PyEllipsis_Type = { 0, / tp_setattro / 0, / tp_as_buffer / Py_TPFLAGS_DEFAULT, / tp_flags */

}; PyObject _Py_EllipsisObject = {