]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
authorGuido van Rossum <guido@python.org>
Thu, 31 Jul 1997 19:39:54 +0000 (19:39 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 31 Jul 1997 19:39:54 +0000 (19:39 +0000)
Modules/fcntlmodule.c

index e7c91b19df050d7cd1ca7b79db6b60aec1d24f59..e951bc409523544592760f74fdbdff53467958c0 100644 (file)
@@ -257,6 +257,30 @@ static PyMethodDef fcntl_methods[] = {
 
 /* Module initialisation */
 
+static int
+ins(d, symbol, value)
+        PyObject* d;
+        char* symbol;
+        long value;
+{
+        PyObject* v = PyInt_FromLong(value);
+        if (!v || PyDict_SetItemString(d, symbol, v) < 0)
+                return -1;
+
+        Py_DECREF(v);
+        return 0;
+}
+
+static int
+all_ins(d)
+        PyObject* d;
+{
+        if (ins(d, "LOCK_SH", (long)LOCK_SH)) return -1;
+        if (ins(d, "LOCK_EX", (long)LOCK_EX)) return -1;
+        if (ins(d, "LOCK_NB", (long)LOCK_NB)) return -1;
+        if (ins(d, "LOCK_UN", (long)LOCK_UN)) return -1;
+}
+
 void
 initfcntl()
 {
@@ -267,6 +291,7 @@ initfcntl()
 
        /* Add some symbolic constants to the module */
        d = PyModule_GetDict(m);
+       all_ins(d);
 
        /* Check for errors */
        if (PyErr_Occurred())