RCS file: /cvsroot/python/python/dist/src/Lib/test/test_bool.py,v retrieving revision 1.7 diff -c -r1.7 test_bool.py *** Lib/test/test_bool.py 23 Jul 2002 19:03:45 -0000 1.7 --- Lib/test/test_bool.py 19 Apr 2003 09:32:22 -0000 *************** *** 137,142 **** --- 137,143 ---- veris(bool(0), False) veris(bool("hello"), True) veris(bool(""), False) + veris(bool(), False) veris(hasattr([], "append"), True) veris(hasattr([], "wobble"), False) Index: Lib/test/test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.48 diff -c -r1.48 test_types.py *** Lib/test/test_types.py 14 Apr 2003 20:58:03 -0000 1.48 --- Lib/test/test_types.py 19 Apr 2003 09:32:23 -0000 *************** *** 86,91 **** --- 86,95 ---- if 1 != 1L or 1 != 1.0 or 1L != 1.0: raise TestFailed, 'mixed comparisons' if -1 != -1L or -1 != -1.0 or -1L != -1.0: raise TestFailed, 'int/long/float value not equal' + # calling built-in types without argument must return 0 + if int() != 0: raise TestFailed, 'int() does not return 0' + if long() != 0L: raise TestFailed, 'long() does not return 0L' + if float() != 0.0: raise TestFailed, 'float() does not return 0.0' if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass else: raise TestFailed, 'int() does not round properly' if long(1.9) == 1L == long(1.1) and long(-1.1) == -1L == long(-1.9): pass *************** *** 214,219 **** --- 218,225 ---- print '6.5.2 Tuples' + # calling built-in types without argument must return empty + if tuple() != (): raise TestFailed,'tuple() does not return ()' if len(()) != 0: raise TestFailed, 'len(())' if len((1,)) != 1: raise TestFailed, 'len((1,))' if len((1,2,3,4,5,6)) != 6: raise TestFailed, 'len((1,2,3,4,5,6))' *************** *** 251,256 **** --- 257,264 ---- vereq(list(tuple(f())), range(1000)) print '6.5.3 Lists' + # calling built-in types without argument must return empty + if list() != []: raise TestFailed,'list() does not return []' if len([]) != 0: raise TestFailed, 'len([])' if len([1,]) != 1: raise TestFailed, 'len([1,])' if len([1,2,3,4,5,6]) != 6: raise TestFailed, 'len([1,2,3,4,5,6])' *************** *** 441,446 **** --- 449,456 ---- print '6.6 Mappings == Dictionaries' + # calling built-in types without argument must return empty + if dict() != {}: raise TestFailed,'dict() does not return {}' d = {} if d.keys() != []: raise TestFailed, '{}.keys()' if d.values() != []: raise TestFailed, '{}.values()' Index: Objects/boolobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/boolobject.c,v retrieving revision 1.5 diff -c -r1.5 boolobject.c *** Objects/boolobject.c 6 Aug 2002 22:12:52 -0000 1.5 --- Objects/boolobject.c 19 Apr 2003 09:32:27 -0000 *************** *** 51,62 **** bool_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"x", 0}; ! PyObject *x; long ok; ! if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:bool", kwlist, &x)) return NULL; ! ok = PyObject_IsTrue(x); if (ok < 0) return NULL; return PyBool_FromLong(ok); --- 51,62 ---- bool_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"x", 0}; ! PyObject *x = NULL; long ok; ! if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:bool", kwlist, &x)) return NULL; ! ok = (x != NULL) && PyObject_IsTrue(x); if (ok < 0) return NULL; return PyBool_FromLong(ok);