@@ -42,13 +42,6 @@ typedef struct
4242 PyObject_HEAD /* a pure abstract base clase */
4343} PyDateTime_TZInfo ;
4444
45- typedef struct
46- {
47- PyObject_HEAD
48- long hashcode ;
49- unsigned char data [_PyDateTime_DATE_DATASIZE ];
50- } PyDateTime_Date ;
51-
5245
5346/* The datetime and time types have hashcodes, and an optional tzinfo member,
5447 * present if and only if hastzinfo is true.
@@ -88,25 +81,35 @@ typedef struct
8881 PyObject * tzinfo ;
8982} PyDateTime_Time ; /* hastzinfo true */
9083
91- /* XXX The date type will be reworked similarly. */
9284
85+ /* All datetime objects are of PyDateTime_DateTimeType, but that can be
86+ * allocated in two ways too, just like for time objects above. In addition,
87+ * the plain date type is a base class for datetime, so it must also have
88+ * a hastzinfo member (although it's unused there).
89+ */
9390typedef struct
9491{
95- PyObject_HEAD
96- long hashcode ;
92+ _PyTZINFO_HEAD
93+ unsigned char data [_PyDateTime_DATE_DATASIZE ];
94+ } PyDateTime_Date ;
95+
96+ #define _PyDateTime_DATETIMEHEAD \
97+ _PyTZINFO_HEAD \
9798 unsigned char data[_PyDateTime_DATETIME_DATASIZE];
98- } PyDateTime_DateTime ;
9999
100100typedef struct
101101{
102- PyObject_HEAD
103- long hashcode ;
104- unsigned char data [_PyDateTime_DATETIME_DATASIZE ];
102+ _PyDateTime_DATETIMEHEAD
103+ } _PyDateTime_BaseDateTime ; /* hastzinfo false */
104+
105+ typedef struct
106+ {
107+ _PyDateTime_DATETIMEHEAD
105108 PyObject * tzinfo ;
106- } PyDateTime_DateTimeTZ ;
109+ } PyDateTime_DateTime ; /* hastzinfo true */
107110
108111
109- /* Apply for date, datetime, and datetimetz instances. */
112+ /* Apply for date and datetime instances. */
110113#define PyDateTime_GET_YEAR (o ) ((((PyDateTime_Date*)o)->data[0] << 8) | \
111114 ((PyDateTime_Date*)o)->data[1])
112115#define PyDateTime_GET_MONTH (o ) (((PyDateTime_Date*)o)->data[2])
@@ -135,9 +138,6 @@ typedef struct
135138#define PyDateTime_Check (op ) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
136139#define PyDateTime_CheckExact (op ) ((op)->ob_type == &PyDateTime_DateTimeType)
137140
138- #define PyDateTimeTZ_Check (op ) PyObject_TypeCheck(op, &PyDateTime_DateTimeTZType)
139- #define PyDateTimeTZ_CheckExact (op ) ((op)->ob_type == &PyDateTime_DateTimeTZType)
140-
141141#define PyTime_Check (op ) PyObject_TypeCheck(op, &PyDateTime_TimeType)
142142#define PyTime_CheckExact (op ) ((op)->ob_type == &PyDateTime_TimeType)
143143
0 commit comments