Release date: XX-Apr-2002
=================================
-Core
+Core and builtins
+
+- Added new builtin function bool() and new builtin constants True and
+ False to ease backporting of code developed for Python 2.3. In 2.2,
+ bool() returns 1 or 0, True == 1, and False == 0.
- Fixed super() to work correctly with class methods. [SF bug #535444]
Note that classes are callable, as are instances with a __call__() method.";
+static PyObject *
+builtin_bool(PyObject *self, PyObject *x)
+{
+ long b = PyObject_IsTrue(x);
+ if (b < 0)
+ return NULL;
+ if (b)
+ x = Py_True;
+ else
+ x = Py_False;
+ Py_INCREF(x);
+ return x;
+}
+
+static char bool_doc[] =
+"bool(x) -> integer\n\
+\n\
+Normalize Boolean: return True (1) when x is true, False (0) otherwise.";
+
+
static PyObject *
builtin_buffer(PyObject *self, PyObject *args)
{
{"__import__", builtin___import__, METH_VARARGS, import_doc},
{"abs", builtin_abs, METH_O, abs_doc},
{"apply", builtin_apply, METH_VARARGS, apply_doc},
+ {"bool", builtin_bool, METH_O, bool_doc},
{"buffer", builtin_buffer, METH_VARARGS, buffer_doc},
{"callable", builtin_callable, METH_O, callable_doc},
{"chr", builtin_chr, METH_VARARGS, chr_doc},
SETBUILTIN("None", Py_None);
SETBUILTIN("Ellipsis", Py_Ellipsis);
SETBUILTIN("NotImplemented", Py_NotImplemented);
+ SETBUILTIN("True", Py_True);
+ SETBUILTIN("False", Py_False);
SETBUILTIN("classmethod", &PyClassMethod_Type);
#ifndef WITHOUT_COMPLEX
SETBUILTIN("complex", &PyComplex_Type);