annotate Objects/boolobject.c @ 49955:878d40468c4e legacy-trunk

Issue #4384: Added logging integration with warnings module using captureWarnings(). This change includes a NullHandler which does nothing; it will be of use to library developers who want to avoid the "No handlers could be found for logger XXX" message which can appear if the library user doesn't configure logging.
author Vinay Sajip <vinay_sajip@yahoo.co.uk>
date Wed, 03 Dec 2008 23:22:58 +0000
parents 52294af4b663
children fd25030223b0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /* Boolean type, a subtype of int */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 #include "Python.h"
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 /* We need to define bool_print to override int_print */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 static int
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 bool_print(PyBoolObject *self, FILE *fp, int flags)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 {
43378
7630248b593c Add a bunch of GIL release/acquire points in tp_print implementations and for
Brett Cannon <bcannon@gmail.com>
parents: 42333
diff changeset
10 Py_BEGIN_ALLOW_THREADS
22789
97a34643e544 As Neal pointed out, bool_print was an order of magnitude too complex.
Guido van Rossum <guido@python.org>
parents: 22787
diff changeset
11 fputs(self->ob_ival == 0 ? "False" : "True", fp);
43378
7630248b593c Add a bunch of GIL release/acquire points in tp_print implementations and for
Brett Cannon <bcannon@gmail.com>
parents: 42333
diff changeset
12 Py_END_ALLOW_THREADS
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 return 0;
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 }
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 /* We define bool_repr to return "False" or "True" */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 static PyObject *false_str = NULL;
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 static PyObject *true_str = NULL;
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20
24616
35dba6007ac3 Make more functions static
Neal Norwitz <nnorwitz@gmail.com>
parents: 23832
diff changeset
21 static PyObject *
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 bool_repr(PyBoolObject *self)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 {
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 PyObject *s;
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
25
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 if (self->ob_ival)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 s = true_str ? true_str :
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
28 (true_str = PyString_InternFromString("True"));
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 else
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 s = false_str ? false_str :
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
31 (false_str = PyString_InternFromString("False"));
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 Py_XINCREF(s);
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 return s;
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 }
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
35
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 /* Function to return a bool from a C long */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
37
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 PyObject *PyBool_FromLong(long ok)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 {
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 PyObject *result;
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
41
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 if (ok)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 result = Py_True;
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 else
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 result = Py_False;
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 Py_INCREF(result);
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 return result;
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 }
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 /* We define bool_new to always return either Py_True or Py_False */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51
24616
35dba6007ac3 Make more functions static
Neal Norwitz <nnorwitz@gmail.com>
parents: 23832
diff changeset
52 static PyObject *
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 bool_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 {
36675
dba6494735d0 Revert backwards-incompatible const changes.
Martin v. Löwis <martin@v.loewis.de>
parents: 35999
diff changeset
55 static char *kwlist[] = {"x", 0};
28696
658b10c5ba2a - bool() called without arguments now returns False rather than
Guido van Rossum <guido@python.org>
parents: 24616
diff changeset
56 PyObject *x = Py_False;
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 long ok;
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
58
28696
658b10c5ba2a - bool() called without arguments now returns False rather than
Guido van Rossum <guido@python.org>
parents: 24616
diff changeset
59 if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:bool", kwlist, &x))
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 return NULL;
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 ok = PyObject_IsTrue(x);
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 if (ok < 0)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 return NULL;
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 return PyBool_FromLong(ok);
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 }
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
66
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 /* Arithmetic operations redefined to return bool if both args are bool. */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
68
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 static PyObject *
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 bool_and(PyObject *a, PyObject *b)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 {
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 if (!PyBool_Check(a) || !PyBool_Check(b))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 return PyInt_Type.tp_as_number->nb_and(a, b);
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
74 return PyBool_FromLong(
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 ((PyBoolObject *)a)->ob_ival & ((PyBoolObject *)b)->ob_ival);
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
76 }
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
77
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 static PyObject *
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
79 bool_or(PyObject *a, PyObject *b)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 {
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 if (!PyBool_Check(a) || !PyBool_Check(b))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 return PyInt_Type.tp_as_number->nb_or(a, b);
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 return PyBool_FromLong(
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
84 ((PyBoolObject *)a)->ob_ival | ((PyBoolObject *)b)->ob_ival);
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 }
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
86
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
87 static PyObject *
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 bool_xor(PyObject *a, PyObject *b)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
89 {
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 if (!PyBool_Check(a) || !PyBool_Check(b))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
91 return PyInt_Type.tp_as_number->nb_xor(a, b);
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
92 return PyBool_FromLong(
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
93 ((PyBoolObject *)a)->ob_ival ^ ((PyBoolObject *)b)->ob_ival);
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
94 }
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
95
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 /* Doc string */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
97
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 23276
diff changeset
98 PyDoc_STRVAR(bool_doc,
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
99 "bool(x) -> bool\n\
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 \n\
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
101 Returns True when the argument x is true, False otherwise.\n\
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
102 The builtins True and False are the only two instances of the class bool.\n\
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 23276
diff changeset
103 The class bool is a subclass of the class int, and cannot be subclassed.");
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
104
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
105 /* Arithmetic methods -- only so we can override &, |, ^. */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
106
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 static PyNumberMethods bool_as_number = {
37304
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
108 0, /* nb_add */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
109 0, /* nb_subtract */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
110 0, /* nb_multiply */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
111 0, /* nb_divide */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
112 0, /* nb_remainder */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
113 0, /* nb_divmod */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
114 0, /* nb_power */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
115 0, /* nb_negative */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
116 0, /* nb_positive */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
117 0, /* nb_absolute */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
118 0, /* nb_nonzero */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
119 0, /* nb_invert */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
120 0, /* nb_lshift */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
121 0, /* nb_rshift */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
122 bool_and, /* nb_and */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
123 bool_xor, /* nb_xor */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
124 bool_or, /* nb_or */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
125 0, /* nb_coerce */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
126 0, /* nb_int */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
127 0, /* nb_long */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
128 0, /* nb_float */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
129 0, /* nb_oct */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
130 0, /* nb_hex */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
131 0, /* nb_inplace_add */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
132 0, /* nb_inplace_subtract */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
133 0, /* nb_inplace_multiply */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
134 0, /* nb_inplace_divide */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
135 0, /* nb_inplace_remainder */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
136 0, /* nb_inplace_power */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
137 0, /* nb_inplace_lshift */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
138 0, /* nb_inplace_rshift */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
139 0, /* nb_inplace_and */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
140 0, /* nb_inplace_xor */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
141 0, /* nb_inplace_or */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
142 0, /* nb_floor_divide */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
143 0, /* nb_true_divide */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
144 0, /* nb_inplace_floor_divide */
79a0f080f898 Remove unnecessary casts in type object initializers.
Georg Brandl <georg@python.org>
parents: 36675
diff changeset
145 0, /* nb_inplace_true_divide */
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
146 };
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
147
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
148 /* The type object for bool. Note that this cannot be subclassed! */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
149
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
150 PyTypeObject PyBool_Type = {
42333
6620a510e9a9 PEP 3123: Provide forward compatibility with Python 3.0, while keeping
Martin v. Löwis <martin@v.loewis.de>
parents: 37304
diff changeset
151 PyVarObject_HEAD_INIT(&PyType_Type, 0)
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
152 "bool",
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
153 sizeof(PyIntObject),
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
154 0,
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
155 0, /* tp_dealloc */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
156 (printfunc)bool_print, /* tp_print */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
157 0, /* tp_getattr */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
158 0, /* tp_setattr */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
159 0, /* tp_compare */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
160 (reprfunc)bool_repr, /* tp_repr */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
161 &bool_as_number, /* tp_as_number */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
162 0, /* tp_as_sequence */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
163 0, /* tp_as_mapping */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 0, /* tp_hash */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
165 0, /* tp_call */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
166 (reprfunc)bool_repr, /* tp_str */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
167 0, /* tp_getattro */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
168 0, /* tp_setattro */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
169 0, /* tp_as_buffer */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
170 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, /* tp_flags */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
171 bool_doc, /* tp_doc */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
172 0, /* tp_traverse */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
173 0, /* tp_clear */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
174 0, /* tp_richcompare */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
175 0, /* tp_weaklistoffset */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
176 0, /* tp_iter */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
177 0, /* tp_iternext */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
178 0, /* tp_methods */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
179 0, /* tp_members */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
180 0, /* tp_getset */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
181 &PyInt_Type, /* tp_base */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
182 0, /* tp_dict */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
183 0, /* tp_descr_get */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
184 0, /* tp_descr_set */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
185 0, /* tp_dictoffset */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
186 0, /* tp_init */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
187 0, /* tp_alloc */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
188 bool_new, /* tp_new */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
189 };
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
190
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
191 /* The objects representing bool values False and True */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
192
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
193 /* Named Zero for link-level compatibility */
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
194 PyIntObject _Py_ZeroStruct = {
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
195 PyObject_HEAD_INIT(&PyBool_Type)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
196 0
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
197 };
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
198
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
199 PyIntObject _Py_TrueStruct = {
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
200 PyObject_HEAD_INIT(&PyBool_Type)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
201 1
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
202 };