FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-40077: Add traverse/clear/free to arraymodule by erlend-aasland · Pull Request #24066 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
39 changes: 33 additions & 6 deletions Modules/arraymodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2977,18 +2977,42 @@ static PyType_Spec arrayiter_spec = {

/*********************** Install Module **************************/

static int
array_traverse(PyObject *module, visitproc visit, void *arg)
{
array_state *state = get_array_state(module);
Py_VISIT(state->ArrayType);
Py_VISIT(state->ArrayIterType);
return 0;
}

static int
array_clear(PyObject *module)
{
array_state *state = get_array_state(module);
Py_CLEAR(state->ArrayType);
Py_CLEAR(state->ArrayIterType);
return 0;
}

static void
array_free(void *module)
{
array_clear((PyObject *)module);
}

/* No functions in array module. */
static PyMethodDef a_methods[] = {
ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF
{NULL, NULL, 0, NULL} /* Sentinel */
};

#define CREATE_TYPE(module, type, spec) \
do { \
type = (PyTypeObject *)PyType_FromModuleAndSpec(m, spec, NULL); \
if (type == NULL) { \
return -1; \
} \
#define CREATE_TYPE(module, type, spec) \
do { \
type = (PyTypeObject *)PyType_FromModuleAndSpec(module, spec, NULL); \
if (type == NULL) { \
return -1; \
} \
} while (0)

static int
Expand Down Expand Up @@ -3059,6 +3083,9 @@ static struct PyModuleDef arraymodule = {
.m_doc = module_doc,
.m_methods = a_methods,
.m_slots = arrayslots,
.m_traverse = array_traverse,
.m_clear = array_clear,
.m_free = array_free,
};


Expand Down

Back | FazBrowse Home | New Git URL