Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f4e32c7

Browse files
committed
Add definitions for symbolic constants LOCK_{EX,NB,SH,UN}.
1 parent 55b9ab5 commit f4e32c7

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Modules/fcntlmodule.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,30 @@ static PyMethodDef fcntl_methods[] = {
257257

258258
/* Module initialisation */
259259

260+
static int
261+
ins(d, symbol, value)
262+
PyObject* d;
263+
char* symbol;
264+
long value;
265+
{
266+
PyObject* v = PyInt_FromLong(value);
267+
if (!v || PyDict_SetItemString(d, symbol, v) < 0)
268+
return -1;
269+
270+
Py_DECREF(v);
271+
return 0;
272+
}
273+
274+
static int
275+
all_ins(d)
276+
PyObject* d;
277+
{
278+
if (ins(d, "LOCK_SH", (long)LOCK_SH)) return -1;
279+
if (ins(d, "LOCK_EX", (long)LOCK_EX)) return -1;
280+
if (ins(d, "LOCK_NB", (long)LOCK_NB)) return -1;
281+
if (ins(d, "LOCK_UN", (long)LOCK_UN)) return -1;
282+
}
283+
260284
void
261285
initfcntl()
262286
{
@@ -267,6 +291,7 @@ initfcntl()
267291

268292
/* Add some symbolic constants to the module */
269293
d = PyModule_GetDict(m);
294+
all_ins(d);
270295

271296
/* Check for errors */
272297
if (PyErr_Occurred())

0 commit comments

Comments
 (0)