summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-01-25 18:59:36 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2020-01-25 18:59:36 +0100
commit362e175a7f1edcc19239f0390273cbf6567a0e95 (patch)
tree88ac1fbc42071faf355e05c6a6108efcad70b2c2
parent8355f96ef6d4896a77f7443041a23cd5b98426af (diff)
downloadpsutil-362e175a7f1edcc19239f0390273cbf6567a0e95.tar.gz
replace Py_PidConverter with _Py_PARSE_PID
-rw-r--r--psutil/_psutil_bsd.c8
-rw-r--r--psutil/_psutil_osx.c24
-rw-r--r--psutil/_psutil_posix.c4
-rw-r--r--psutil/arch/freebsd/proc_socks.c5
4 files changed, 21 insertions, 20 deletions
diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c
index 0f36c0a0..20f24ce9 100644
--- a/psutil/_psutil_bsd.c
+++ b/psutil/_psutil_bsd.c
@@ -204,7 +204,7 @@ psutil_proc_oneshot_info(PyObject *self, PyObject *args) {
PyObject *py_ppid;
PyObject *py_retlist;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
if (psutil_kinfo_proc(pid, &kp) == -1)
return NULL;
@@ -370,7 +370,7 @@ psutil_proc_name(PyObject *self, PyObject *args) {
kinfo_proc kp;
char str[1000];
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
if (psutil_kinfo_proc(pid, &kp) == -1)
return NULL;
@@ -392,7 +392,7 @@ psutil_proc_cmdline(PyObject *self, PyObject *args) {
pid_t pid;
PyObject *py_retlist = NULL;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
py_retlist = psutil_get_cmdline(pid);
if (py_retlist == NULL)
@@ -477,7 +477,7 @@ psutil_proc_open_files(PyObject *self, PyObject *args) {
if (py_retlist == NULL)
return NULL;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
goto error;
if (psutil_kinfo_proc(pid, &kipp) == -1)
goto error;
diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c
index 85c694d8..e4f0e0eb 100644
--- a/psutil/_psutil_osx.c
+++ b/psutil/_psutil_osx.c
@@ -169,7 +169,7 @@ psutil_proc_kinfo_oneshot(PyObject *self, PyObject *args) {
PyObject *py_name;
PyObject *py_retlist;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
if (psutil_get_kinfo_proc(pid, &kp) == -1)
return NULL;
@@ -218,7 +218,7 @@ psutil_proc_pidtaskinfo_oneshot(PyObject *self, PyObject *args) {
pid_t pid;
struct proc_taskinfo pti;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
if (psutil_proc_pidinfo(pid, PROC_PIDTASKINFO, 0, &pti, sizeof(pti)) <= 0)
return NULL;
@@ -253,7 +253,7 @@ psutil_proc_name(PyObject *self, PyObject *args) {
pid_t pid;
struct kinfo_proc kp;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
if (psutil_get_kinfo_proc(pid, &kp) == -1)
return NULL;
@@ -270,7 +270,7 @@ psutil_proc_cwd(PyObject *self, PyObject *args) {
pid_t pid;
struct proc_vnodepathinfo pathinfo;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
if (psutil_proc_pidinfo(
@@ -292,7 +292,7 @@ psutil_proc_exe(PyObject *self, PyObject *args) {
char buf[PATH_MAX];
int ret;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
errno = 0;
ret = proc_pidpath(pid, &buf, sizeof(buf));
@@ -315,7 +315,7 @@ psutil_proc_cmdline(PyObject *self, PyObject *args) {
pid_t pid;
PyObject *py_retlist = NULL;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
// get the commandline, defined in arch/osx/process_info.c
@@ -332,7 +332,7 @@ psutil_proc_environ(PyObject *self, PyObject *args) {
pid_t pid;
PyObject *py_retdict = NULL;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
// get the environment block, defined in arch/osx/process_info.c
@@ -435,7 +435,7 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) {
vm_region_top_info_data_t info;
mach_port_t object_name;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
if (psutil_task_for_pid(pid, &task) != 0)
@@ -882,7 +882,7 @@ psutil_proc_threads(PyObject *self, PyObject *args) {
if (py_retlist == NULL)
return NULL;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
goto error;
if (psutil_task_for_pid(pid, &task) != 0)
@@ -985,7 +985,7 @@ psutil_proc_open_files(PyObject *self, PyObject *args) {
if (py_retlist == NULL)
return NULL;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
goto error;
pidinfo_result = psutil_proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0);
@@ -1090,7 +1090,7 @@ psutil_proc_connections(PyObject *self, PyObject *args) {
if (py_retlist == NULL)
return NULL;
- if (! PyArg_ParseTuple(args, "O&OO", Py_PidConverter, &pid, &py_af_filter,
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID "OO", &pid, &py_af_filter,
&py_type_filter)) {
goto error;
}
@@ -1279,7 +1279,7 @@ psutil_proc_num_fds(PyObject *self, PyObject *args) {
int num;
struct proc_fdinfo *fds_pointer;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
pidinfo_result = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0);
diff --git a/psutil/_psutil_posix.c b/psutil/_psutil_posix.c
index 792264de..f4ecbd93 100644
--- a/psutil/_psutil_posix.c
+++ b/psutil/_psutil_posix.c
@@ -135,7 +135,7 @@ psutil_posix_getpriority(PyObject *self, PyObject *args) {
int priority;
errno = 0;
- if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
#ifdef PSUTIL_OSX
@@ -158,7 +158,7 @@ psutil_posix_setpriority(PyObject *self, PyObject *args) {
int priority;
int retval;
- if (! PyArg_ParseTuple(args, "O&i", Py_PidConverter, &pid, &priority))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID "i", &pid, &priority))
return NULL;
#ifdef PSUTIL_OSX
diff --git a/psutil/arch/freebsd/proc_socks.c b/psutil/arch/freebsd/proc_socks.c
index b40888ee..cdf5770b 100644
--- a/psutil/arch/freebsd/proc_socks.c
+++ b/psutil/arch/freebsd/proc_socks.c
@@ -202,8 +202,9 @@ psutil_proc_connections(PyObject *self, PyObject *args) {
if (py_retlist == NULL)
return NULL;
- if (! PyArg_ParseTuple(args, "O&OO", Py_PidConverter, &pid,
- &py_af_filter, &py_type_filter)) {
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID "OO", &pid,
+ &py_af_filter, &py_type_filter))
+ {
goto error;
}
if (!PySequence_Check(py_af_filter) || !PySequence_Check(py_type_filter)) {