OLD | NEW |
| (Empty) |
1 /* | |
2 * $Id: _psutil_common.c 1142 2011-10-05 18:45:49Z g.rodola $ | |
3 * | |
4 * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved. | |
5 * Use of this source code is governed by a BSD-style license that can be | |
6 * found in the LICENSE file. | |
7 * | |
8 * Routines common to all platforms. | |
9 */ | |
10 | |
11 #include <Python.h> | |
12 | |
13 | |
14 /* | |
15 * Set OSError(errno=ESRCH, strerror="No such process") Python exception. | |
16 */ | |
17 PyObject * | |
18 NoSuchProcess(void) { | |
19 PyObject *exc; | |
20 char *msg = strerror(ESRCH); | |
21 exc = PyObject_CallFunction(PyExc_OSError, "(is)", ESRCH, msg); | |
22 PyErr_SetObject(PyExc_OSError, exc); | |
23 Py_XDECREF(exc); | |
24 return NULL; | |
25 } | |
26 | |
27 /* | |
28 * Set OSError(errno=EACCES, strerror="Permission denied") Python exception. | |
29 */ | |
30 PyObject * | |
31 AccessDenied(void) { | |
32 PyObject *exc; | |
33 char *msg = strerror(EACCES); | |
34 exc = PyObject_CallFunction(PyExc_OSError, "(is)", EACCES, msg); | |
35 PyErr_SetObject(PyExc_OSError, exc); | |
36 Py_XDECREF(exc); | |
37 return NULL; | |
38 } | |
39 | |
OLD | NEW |