summaryrefslogtreecommitdiff
path: root/psutil
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-01-25 09:54:11 -0800
committerGiampaolo Rodola <g.rodola@gmail.com>2020-01-25 09:54:11 -0800
commit88bde608d2e7155eb264a6a49ca76b5bcc4943c5 (patch)
tree70dc821625d7b0860b9611794677714d5300cbcb /psutil
parent18f64da8f695216ea02e26e2a5a3581876842e24 (diff)
downloadpsutil-88bde608d2e7155eb264a6a49ca76b5bcc4943c5.tar.gz
get rid of Py_PidConverter
Diffstat (limited to 'psutil')
-rw-r--r--psutil/_psutil_common.c24
-rw-r--r--psutil/_psutil_common.h1
-rw-r--r--psutil/arch/windows/socks.c5
3 files changed, 3 insertions, 27 deletions
diff --git a/psutil/_psutil_common.c b/psutil/_psutil_common.c
index bebb9b5e..0ad5f281 100644
--- a/psutil/_psutil_common.c
+++ b/psutil/_psutil_common.c
@@ -165,30 +165,6 @@ psutil_setup(void) {
}
-int
-Py_PidConverter(PyObject *arg, void *addr) {
-#ifdef PSUTIL_WINDOWS
- if ((sizeof(DWORD) == sizeof(int)) || (sizeof(DWORD) == sizeof(long))) {
- *((DWORD *)addr) = PyLong_AsLong(arg);
- }
-#else
- if ((sizeof(pid_t) == sizeof(int)) || (sizeof(pid_t) == sizeof(long))) {
- *((pid_t *)addr) = PyLong_AsLong(arg);
- }
- else if (sizeof(pid_t) == sizeof(long long)) {
- *((pid_t *)addr) = PyLong_AsLongLong(arg);
- }
-#endif
- else {
- PyErr_SetString(PyExc_ValueError, "can't get size of pid_t");
- }
-
- if (PyErr_Occurred())
- return 0;
- return 1;
-}
-
-
// ====================================================================
// --- Windows
// ====================================================================
diff --git a/psutil/_psutil_common.h b/psutil/_psutil_common.h
index 84361927..79c2be29 100644
--- a/psutil/_psutil_common.h
+++ b/psutil/_psutil_common.h
@@ -63,7 +63,6 @@ PyObject* PyErr_SetFromOSErrnoWithSyscall(const char *syscall);
PyObject* psutil_set_testing(PyObject *self, PyObject *args);
void psutil_debug(const char* format, ...);
int psutil_setup(void);
-int Py_PidConverter(PyObject *arg, void *addr);
// ====================================================================
// --- Windows
diff --git a/psutil/arch/windows/socks.c b/psutil/arch/windows/socks.c
index f0778c47..cb19d5d2 100644
--- a/psutil/arch/windows/socks.c
+++ b/psutil/arch/windows/socks.c
@@ -137,8 +137,9 @@ psutil_net_connections(PyObject *self, PyObject *args) {
PyObject *_SOCK_STREAM = PyLong_FromLong((long)SOCK_STREAM);
PyObject *_SOCK_DGRAM = PyLong_FromLong((long)SOCK_DGRAM);
- 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;
}