Skip to content

Commit 738afb5

Browse files
committed
refactor: rename state attr / accessor for settable BTree attrs
1 parent 2d61027 commit 738afb5

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/BTrees/BTreeModuleTemplate.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ intern_strings()
157157

158158
static inline PyObject* _get_module(PyTypeObject* typeobj);
159159
static inline PyObject* _get_conflict_error( PyObject* bt_obj_or_module);
160-
static inline PyObject* _get_btreetype_setattro_allowed_names(
161-
PyTypeObject* type);
160+
static inline PyObject* _get_btreetype_allowed_attrs(PyTypeObject* type);
162161
static inline PerCAPI* _get_per_capi(PyObject* bt_obj_or_module);
163162
static inline PyTypeObject* _get_btree_type(PyObject* module);
164163
static inline PyTypeObject* _get_bucket_type(PyObject* module);
@@ -726,7 +725,7 @@ static struct PyMethodDef module_methods[] = {
726725
typedef struct {
727726
PyObject* conflict_error;
728727
PerCAPI* per_capi;
729-
PyObject* btreetype_setattro_allowed_names;
728+
PyObject* btreetype_allowed_attrs;
730729
PyTypeObject* btree_type_type;
731730
PyTypeObject* btree_type;
732731
PyTypeObject* bucket_type;
@@ -743,7 +742,7 @@ module_traverse(PyObject* module, visitproc visit, void *arg)
743742
Py_VISIT(state->conflict_error);
744743
if (state->per_capi)
745744
Py_VISIT(state->per_capi->pertype);
746-
Py_VISIT(state->btreetype_setattro_allowed_names);
745+
Py_VISIT(state->btreetype_allowed_attrs);
747746
Py_VISIT(state->btree_type_type);
748747
Py_VISIT(state->btree_type);
749748
Py_VISIT(state->bucket_type);
@@ -761,7 +760,7 @@ module_clear(PyObject* module)
761760
Py_CLEAR(state->conflict_error);
762761
if (state->per_capi)
763762
Py_CLEAR(state->per_capi->pertype);
764-
Py_CLEAR(state->btreetype_setattro_allowed_names);
763+
Py_CLEAR(state->btreetype_allowed_attrs);
765764
Py_CLEAR(state->btree_type_type);
766765
Py_CLEAR(state->btree_type);
767766
Py_CLEAR(state->bucket_type);
@@ -807,14 +806,14 @@ _get_conflict_error(PyObject* bt_obj_or_module)
807806
}
808807

809808
static inline PyObject*
810-
_get_btreetype_setattro_allowed_names(PyTypeObject* type)
809+
_get_btreetype_allowed_attrs(PyTypeObject* type)
811810
{
812811
PyObject* module = _get_module(type);
813812
if (module == NULL)
814813
return NULL;
815814

816815
module_state* state = PyModule_GetState(module);
817-
return state->btreetype_setattro_allowed_names;
816+
return state->btreetype_allowed_attrs;
818817
}
819818

820819
static inline PerCAPI*
@@ -1038,7 +1037,7 @@ module_exec(PyObject* module)
10381037
PyObject *mod_dict;
10391038
PyObject *interfaces;
10401039

1041-
state->btreetype_setattro_allowed_names = PyTuple_Pack(
1040+
state->btreetype_allowed_attrs = PyTuple_Pack(
10421041
5,
10431042
/* BTree attributes */
10441043
str_max_internal_size,
@@ -1049,7 +1048,7 @@ module_exec(PyObject* module)
10491048
str___provides__
10501049
);
10511050

1052-
if (state->btreetype_setattro_allowed_names == NULL)
1051+
if (state->btreetype_allowed_attrs == NULL)
10531052
return -1;
10541053

10551054
/* Grab the ConflictError class */

src/BTrees/BTreeTemplate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
static int
2323
BTreeType_setattro(PyTypeObject* type, PyObject* name, PyObject* value)
2424
{
25-
PyObject* allowed_names = _get_btreetype_setattro_allowed_names(type);
25+
PyObject* allowed_attrs = _get_btreetype_allowed_attrs(type);
2626
/*
2727
type.tp_setattro prohibits setting any attributes on a built-in type,
2828
so we need to use our own (metaclass) type to handle it. The set of
@@ -34,7 +34,7 @@ BTreeType_setattro(PyTypeObject* type, PyObject* name, PyObject* value)
3434
attributes.
3535
*/
3636
int allowed;
37-
allowed = PySequence_Contains(allowed_names, name);
37+
allowed = PySequence_Contains(allowed_attrs, name);
3838
if (allowed < 0) {
3939
return -1;
4040
}

0 commit comments

Comments
 (0)