178
/* Issue #4701: Check that PyObject_Hash implicitly calls
179
* PyType_Ready if it hasn't already been called
181
static PyTypeObject _HashInheritanceTester_Type = {
182
PyVarObject_HEAD_INIT(NULL, 0)
183
"hashinheritancetester", /* Name of this type */
184
sizeof(PyObject), /* Basic object size */
185
0, /* Item size for varobject */
186
(destructor)PyObject_Del, /* tp_dealloc */
192
0, /* tp_as_number */
193
0, /* tp_as_sequence */
194
0, /* tp_as_mapping */
198
PyObject_GenericGetAttr, /* tp_getattro */
200
0, /* tp_as_buffer */
201
Py_TPFLAGS_DEFAULT, /* tp_flags */
205
0, /* tp_richcompare */
206
0, /* tp_weaklistoffset */
214
0, /* tp_descr_get */
215
0, /* tp_descr_set */
216
0, /* tp_dictoffset */
219
PyType_GenericNew, /* tp_new */
223
test_lazy_hash_inheritance(PyObject* self)
229
type = &_HashInheritanceTester_Type;
230
obj = PyObject_New(PyObject, type);
235
"test_lazy_hash_inheritance: failed to create object");
239
if (type->tp_dict != NULL) {
242
"test_lazy_hash_inheritance: type initialised too soon");
247
hash = PyObject_Hash(obj);
248
if ((hash == -1) && PyErr_Occurred()) {
252
"test_lazy_hash_inheritance: could not hash object");
257
if (type->tp_dict == NULL) {
260
"test_lazy_hash_inheritance: type not initialised by hash()");
265
if (type->tp_hash != PyType_Type.tp_hash) {
268
"test_lazy_hash_inheritance: unexpected hash function");
178
277
/* Tests of PyLong_{As, From}{Unsigned,}Long(), and (#ifdef HAVE_LONG_LONG)
179
278
PyLong_{As, From}{Unsigned,}LongLong().
610
710
static PyObject *
711
test_empty_argparse(PyObject *self)
713
/* Test that formats can begin with '|'. See issue #4720. */
714
PyObject *tuple, *dict = NULL;
715
static char *kwlist[] = {NULL};
717
tuple = PyTuple_New(0);
720
if ((result = PyArg_ParseTuple(tuple, "|:test_empty_argparse")) < 0)
725
result = PyArg_ParseTupleAndKeywords(tuple, dict, "|:test_empty_argparse", kwlist);
611
737
codec_incrementalencoder(PyObject *self, PyObject *args)
613
739
const char *encoding, *errors = NULL;
1009
1135
{"test_config", (PyCFunction)test_config, METH_NOARGS},
1010
1136
{"test_list_api", (PyCFunction)test_list_api, METH_NOARGS},
1011
1137
{"test_dict_iteration", (PyCFunction)test_dict_iteration,METH_NOARGS},
1138
{"test_lazy_hash_inheritance", (PyCFunction)test_lazy_hash_inheritance,METH_NOARGS},
1012
1139
{"test_long_api", (PyCFunction)test_long_api, METH_NOARGS},
1013
1140
{"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS},
1014
1141
{"test_k_code", (PyCFunction)test_k_code, METH_NOARGS},
1142
{"test_empty_argparse", (PyCFunction)test_empty_argparse,METH_NOARGS},
1015
1143
{"test_null_strings", (PyCFunction)test_null_strings, METH_NOARGS},
1016
1144
{"test_string_from_format", (PyCFunction)test_string_from_format, METH_NOARGS},
1017
1145
{"test_with_docstring", (PyCFunction)test_with_docstring, METH_NOARGS,
1342
Py_TYPE(&_HashInheritanceTester_Type)=&PyType_Type;
1214
1344
Py_TYPE(&test_structmembersType)=&PyType_Type;
1215
1345
Py_INCREF(&test_structmembersType);
1216
1346
PyModule_AddObject(m, "test_structmembersType", (PyObject *)&test_structmembersType);