Merge lp:~cjwatson/storm/cextensions-rename-dunder into lp:storm

Proposed by Colin Watson
Status: Merged
Merged at revision: 508
Proposed branch: lp:~cjwatson/storm/cextensions-rename-dunder
Merge into: lp:storm
Diff against target: 161 lines (+24/-24)
1 file modified
storm/cextensions.c (+24/-24)
To merge this branch: bzr merge lp:~cjwatson/storm/cextensions-rename-dunder
Reviewer Review Type Date Requested Status
Simon Poirier (community) Approve
Review via email: mp+368451@code.launchpad.net

Commit message

Rename double-underscore identifiers in C extensions.

Description of the change

Unlike Python, identifiers that begin with two underscores are reserved in C. This happens not to have caused a practical problem as yet, but it could. These names aren't exposed to Python, so there's no problem just renaming them to begin with a single underscore instead.

To post a comment you must log in.
Revision history for this message
Simon Poirier (simpoir) wrote :

+1 good change

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storm/cextensions.c'
2--- storm/cextensions.c 2019-06-03 08:45:24 +0000
3+++ storm/cextensions.c 2019-06-06 11:07:28 +0000
4@@ -55,7 +55,7 @@
5
6 typedef struct {
7 PyObject_HEAD
8- PyObject *__weakreflist;
9+ PyObject *_weakreflist;
10 PyObject *_owner_ref;
11 PyObject *_hooks;
12 } EventSystemObject;
13@@ -75,7 +75,7 @@
14
15 typedef struct {
16 PyObject_HEAD
17- PyObject *__weakreflist;
18+ PyObject *_weakreflist;
19 PyObject *_local_dispatch_table;
20 PyObject *_local_precedence;
21 PyObject *_local_reserved_words;
22@@ -88,9 +88,9 @@
23
24 typedef struct {
25 PyDictObject super;
26- PyObject *__weakreflist;
27- PyObject *__obj_ref;
28- PyObject *__obj_ref_callback;
29+ PyObject *_weakreflist;
30+ PyObject *_obj_ref;
31+ PyObject *_obj_ref_callback;
32 PyObject *cls_info;
33 PyObject *event;
34 PyObject *variables;
35@@ -211,7 +211,7 @@
36 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &owner))
37 return -1;
38
39- self->__weakreflist = NULL;
40+ self->_weakreflist = NULL;
41
42 /* self._owner_ref = weakref.ref(owner) */
43 self->_owner_ref = PyWeakref_NewRef(owner, NULL);
44@@ -237,7 +237,7 @@
45 static int
46 EventSystem_clear(EventSystemObject *self)
47 {
48- if (self->__weakreflist)
49+ if (self->_weakreflist)
50 PyObject_ClearWeakRefs((PyObject *)self);
51 Py_CLEAR(self->_owner_ref);
52 Py_CLEAR(self->_hooks);
53@@ -495,7 +495,7 @@
54 (traverseproc)EventSystem_traverse, /*tp_traverse*/
55 (inquiry)EventSystem_clear, /*tp_clear*/
56 0, /*tp_richcompare*/
57- offsetof(EventSystemObject, __weakreflist), /*tp_weaklistoffset*/
58+ offsetof(EventSystemObject, _weakreflist), /*tp_weaklistoffset*/
59 0, /*tp_iter*/
60 0, /*tp_iternext*/
61 EventSystem_methods, /*tp_methods*/
62@@ -1206,7 +1206,7 @@
63 static int
64 Compile_clear(CompileObject *self)
65 {
66- if (self->__weakreflist)
67+ if (self->_weakreflist)
68 PyObject_ClearWeakRefs((PyObject *)self);
69 Py_CLEAR(self->_local_dispatch_table);
70 Py_CLEAR(self->_local_precedence);
71@@ -1762,7 +1762,7 @@
72 (traverseproc)Compile_traverse, /*tp_traverse*/
73 (inquiry)Compile_clear, /*tp_clear*/
74 0, /*tp_richcompare*/
75- offsetof(CompileObject, __weakreflist), /*tp_weaklistoffset*/
76+ offsetof(CompileObject, _weakreflist), /*tp_weaklistoffset*/
77 0, /*tp_iter*/
78 0, /*tp_iternext*/
79 Compile_methods, /*tp_methods*/
80@@ -1818,12 +1818,12 @@
81 NULL));
82
83 /* self.set_obj(obj) */
84- CATCH(NULL, self->__obj_ref_callback =
85+ CATCH(NULL, self->_obj_ref_callback =
86 PyCFunction_NewEx(&ObjectInfo_deleted_callback,
87 (PyObject *)self, NULL));
88
89 CATCH(NULL,
90- self->__obj_ref = PyWeakref_NewRef(obj, self->__obj_ref_callback));
91+ self->_obj_ref = PyWeakref_NewRef(obj, self->_obj_ref_callback));
92
93 /* self.event = event = EventSystem(self) */
94 CATCH(NULL,
95@@ -1897,7 +1897,7 @@
96 static PyObject *
97 ObjectInfo_get_obj(ObjectInfoObject *self, PyObject *args)
98 {
99- PyObject *obj = PyWeakref_GET_OBJECT(self->__obj_ref);
100+ PyObject *obj = PyWeakref_GET_OBJECT(self->_obj_ref);
101 Py_INCREF(obj);
102 return obj;
103 }
104@@ -1911,9 +1911,9 @@
105 if (!PyArg_ParseTuple(args, "O", &obj))
106 return NULL;
107
108- Py_DECREF(self->__obj_ref);
109- self->__obj_ref = PyWeakref_NewRef(obj, self->__obj_ref_callback);
110- if (!self->__obj_ref)
111+ Py_DECREF(self->_obj_ref);
112+ self->_obj_ref = PyWeakref_NewRef(obj, self->_obj_ref_callback);
113+ if (!self->_obj_ref)
114 return NULL;
115
116 Py_RETURN_NONE;
117@@ -1947,8 +1947,8 @@
118 static int
119 ObjectInfo_traverse(ObjectInfoObject *self, visitproc visit, void *arg)
120 {
121- Py_VISIT(self->__obj_ref);
122- Py_VISIT(self->__obj_ref_callback);
123+ Py_VISIT(self->_obj_ref);
124+ Py_VISIT(self->_obj_ref_callback);
125 Py_VISIT(self->cls_info);
126 Py_VISIT(self->event);
127 Py_VISIT(self->variables);
128@@ -1959,8 +1959,8 @@
129 static int
130 ObjectInfo_clear(ObjectInfoObject *self)
131 {
132- Py_CLEAR(self->__obj_ref);
133- Py_CLEAR(self->__obj_ref_callback);
134+ Py_CLEAR(self->_obj_ref);
135+ Py_CLEAR(self->_obj_ref_callback);
136 Py_CLEAR(self->cls_info);
137 Py_CLEAR(self->event);
138 Py_CLEAR(self->variables);
139@@ -1991,10 +1991,10 @@
140 static void
141 ObjectInfo_dealloc(ObjectInfoObject *self)
142 {
143- if (self->__weakreflist)
144+ if (self->_weakreflist)
145 PyObject_ClearWeakRefs((PyObject *)self);
146- Py_CLEAR(self->__obj_ref);
147- Py_CLEAR(self->__obj_ref_callback);
148+ Py_CLEAR(self->_obj_ref);
149+ Py_CLEAR(self->_obj_ref_callback);
150 Py_CLEAR(self->cls_info);
151 Py_CLEAR(self->event);
152 Py_CLEAR(self->variables);
153@@ -2053,7 +2053,7 @@
154 (traverseproc)ObjectInfo_traverse, /*tp_traverse*/
155 (inquiry)ObjectInfo_clear, /*tp_clear*/
156 ObjectInfo_richcompare, /*tp_richcompare*/
157- offsetof(ObjectInfoObject, __weakreflist), /*tp_weaklistoffset*/
158+ offsetof(ObjectInfoObject, _weakreflist), /*tp_weaklistoffset*/
159 0, /*tp_iter*/
160 0, /*tp_iternext*/
161 ObjectInfo_methods, /*tp_methods*/

Subscribers

People subscribed via source and target branches

to status/vote changes: