updated for version 7.3.672
Problem: Not possible to lock/unlock lists in Python interface.
Solution: Add .locked and .scope attributes. (ZyX)
diff --git a/src/if_py_both.h b/src/if_py_both.h
index 0909981..0a1ef1b 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -808,6 +808,44 @@
}
static PyInt
+DictionarySetattr(DictionaryObject *self, char *name, PyObject *val)
+{
+ if (val == NULL)
+ {
+ PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes"));
+ return -1;
+ }
+
+ if (strcmp(name, "locked") == 0)
+ {
+ if (self->dict->dv_lock == VAR_FIXED)
+ {
+ PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed dictionary"));
+ return -1;
+ }
+ else
+ {
+ if (!PyBool_Check(val))
+ {
+ PyErr_SetString(PyExc_TypeError, _("Only boolean objects are allowed"));
+ return -1;
+ }
+
+ if (val == Py_True)
+ self->dict->dv_lock = VAR_LOCKED;
+ else
+ self->dict->dv_lock = 0;
+ }
+ return 0;
+ }
+ else
+ {
+ PyErr_SetString(PyExc_AttributeError, _("Cannot set this attribute"));
+ return -1;
+ }
+}
+
+ static PyInt
DictionaryLength(PyObject *self)
{
return ((PyInt) ((((DictionaryObject *)(self))->dict->dv_hashtab.ht_used)));
@@ -1271,6 +1309,44 @@
return self;
}
+ static int
+ListSetattr(ListObject *self, char *name, PyObject *val)
+{
+ if (val == NULL)
+ {
+ PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes"));
+ return -1;
+ }
+
+ if (strcmp(name, "locked") == 0)
+ {
+ if (self->list->lv_lock == VAR_FIXED)
+ {
+ PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed list"));
+ return -1;
+ }
+ else
+ {
+ if (!PyBool_Check(val))
+ {
+ PyErr_SetString(PyExc_TypeError, _("Only boolean objects are allowed"));
+ return -1;
+ }
+
+ if (val == Py_True)
+ self->list->lv_lock = VAR_LOCKED;
+ else
+ self->list->lv_lock = 0;
+ }
+ return 0;
+ }
+ else
+ {
+ PyErr_SetString(PyExc_AttributeError, _("Cannot set this attribute"));
+ return -1;
+ }
+}
+
static struct PyMethodDef ListMethods[] = {
{"extend", (PyCFunction)ListConcatInPlace, METH_O, ""},
{ NULL, NULL, 0, NULL }