Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ABI3 wheels warnings #2445

Merged
merged 11 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
python-version: 3.x
- name: 'Run linters'
run: |
python3 -m pip install ruff==0.4.4 black rstcheck toml-sort sphinx
python3 -m pip install ruff black rstcheck toml-sort sphinx
make lint-all

# upload weels as a single artefact
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ download-wheels-appveyor: ## Download latest wheels hosted on appveyor.
$(PYTHON_ENV_VARS) $(PYTHON) scripts/internal/download_wheels_appveyor.py
${MAKE} print-dist

create-wheels: ## Create .whl files
$(PYTHON_ENV_VARS) $(PYTHON) setup.py bdist_wheel
${MAKE} check-wheels

check-sdist: ## Check sanity of source distribution.
$(PYTHON_ENV_VARS) $(PYTHON) -m virtualenv --clear --no-wheel --quiet build/venv
$(PYTHON_ENV_VARS) build/venv/bin/python -m pip install -v --isolated --quiet dist/*.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion psutil/_psutil_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ PyErr_SetFromWindowsErr(int winerr) {
* message.
*/
PyObject *
PyErr_SetFromOSErrnoWithSyscall(const char *syscall) {
psutil_PyErr_SetFromOSErrnoWithSyscall(const char *syscall) {
char fullmsg[1024];

#ifdef PSUTIL_WINDOWS
Expand Down
2 changes: 1 addition & 1 deletion psutil/_psutil_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static const int PSUTIL_CONN_NONE = 128;

PyObject* AccessDenied(const char *msg);
PyObject* NoSuchProcess(const char *msg);
PyObject* PyErr_SetFromOSErrnoWithSyscall(const char *syscall);
PyObject* psutil_PyErr_SetFromOSErrnoWithSyscall(const char *syscall);

// ====================================================================
// --- Global utils
Expand Down
6 changes: 3 additions & 3 deletions psutil/_psutil_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ psutil_pid_exists(pid_t pid) {
void
psutil_raise_for_pid(long pid, char *syscall) {
if (errno != 0)
PyErr_SetFromOSErrnoWithSyscall(syscall);
psutil_PyErr_SetFromOSErrnoWithSyscall(syscall);
else if (psutil_pid_exists(pid) == 0)
NoSuchProcess(syscall);
else
Expand Down Expand Up @@ -470,14 +470,14 @@ psutil_net_if_flags(PyObject *self, PyObject *args) {

sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock == -1) {
PyErr_SetFromOSErrnoWithSyscall("socket(SOCK_DGRAM)");
psutil_PyErr_SetFromOSErrnoWithSyscall("socket(SOCK_DGRAM)");
goto error;
}

PSUTIL_STRNCPY(ifr.ifr_name, nic_name, sizeof(ifr.ifr_name));
ret = ioctl(sock, SIOCGIFFLAGS, &ifr);
if (ret == -1) {
PyErr_SetFromOSErrnoWithSyscall("ioctl(SIOCGIFFLAGS)");
psutil_PyErr_SetFromOSErrnoWithSyscall("ioctl(SIOCGIFFLAGS)");
goto error;
}

Expand Down
2 changes: 1 addition & 1 deletion psutil/arch/bsd/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ psutil_proc_environ(PyObject *self, PyObject *args) {
#endif
default:
sprintf(errbuf, "kvm_getenvv(pid=%ld)", pid);
PyErr_SetFromOSErrnoWithSyscall(errbuf);
psutil_PyErr_SetFromOSErrnoWithSyscall(errbuf);
break;
}
goto error;
Expand Down
18 changes: 10 additions & 8 deletions psutil/arch/freebsd/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ psutil_per_cpu_times(PyObject *self, PyObject *args) {
size = sizeof(maxcpus);
if (sysctlbyname("kern.smp.maxcpus", &maxcpus, &size, NULL, 0) < 0) {
Py_DECREF(py_retlist);
return PyErr_SetFromOSErrnoWithSyscall(
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('kern.smp.maxcpus')");
}
long cpu_time[maxcpus][CPUSTATES];
Expand All @@ -52,14 +52,16 @@ psutil_per_cpu_times(PyObject *self, PyObject *args) {
mib[1] = HW_NCPU;
len = sizeof(ncpu);
if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1) {
PyErr_SetFromOSErrnoWithSyscall("sysctl(HW_NCPU)");
psutil_PyErr_SetFromOSErrnoWithSyscall("sysctl(HW_NCPU)");
goto error;
}

// per-cpu info
size = sizeof(cpu_time);
if (sysctlbyname("kern.cp_times", &cpu_time, &size, NULL, 0) == -1) {
PyErr_SetFromOSErrnoWithSyscall("sysctlbyname('kern.smp.maxcpus')");
psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('kern.smp.maxcpus')"
);
goto error;
}

Expand Down Expand Up @@ -126,23 +128,23 @@ psutil_cpu_stats(PyObject *self, PyObject *args) {
size_t size = sizeof(v_soft);

if (sysctlbyname("vm.stats.sys.v_soft", &v_soft, &size, NULL, 0)) {
return PyErr_SetFromOSErrnoWithSyscall(
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.sys.v_soft')");
}
if (sysctlbyname("vm.stats.sys.v_intr", &v_intr, &size, NULL, 0)) {
return PyErr_SetFromOSErrnoWithSyscall(
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.sys.v_intr')");
}
if (sysctlbyname("vm.stats.sys.v_syscall", &v_syscall, &size, NULL, 0)) {
return PyErr_SetFromOSErrnoWithSyscall(
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.sys.v_syscall')");
}
if (sysctlbyname("vm.stats.sys.v_trap", &v_trap, &size, NULL, 0)) {
return PyErr_SetFromOSErrnoWithSyscall(
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.sys.v_trap')");
}
if (sysctlbyname("vm.stats.sys.v_swtch", &v_swtch, &size, NULL, 0)) {
return PyErr_SetFromOSErrnoWithSyscall(
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.sys.v_swtch')");
}

Expand Down
47 changes: 29 additions & 18 deletions psutil/arch/freebsd/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,44 @@ psutil_virtual_mem(PyObject *self, PyObject *args) {
size_t buffers_size = sizeof(buffers);

if (sysctlbyname("hw.physmem", &total, &size, NULL, 0)) {
return PyErr_SetFromOSErrnoWithSyscall("sysctlbyname('hw.physmem')");
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('hw.physmem')"
);
}
if (sysctlbyname("vm.stats.vm.v_active_count", &active, &size, NULL, 0)) {
return PyErr_SetFromOSErrnoWithSyscall(
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_active_count')");
}
if (sysctlbyname("vm.stats.vm.v_inactive_count", &inactive, &size, NULL, 0))
{
return PyErr_SetFromOSErrnoWithSyscall(
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_inactive_count')");
}
if (sysctlbyname("vm.stats.vm.v_wire_count", &wired, &size, NULL, 0)) {
return PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_wire_count')");
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_wire_count')"
);
}
// https://github.com/giampaolo/psutil/issues/997
if (sysctlbyname("vm.stats.vm.v_cache_count", &cached, &size, NULL, 0)) {
cached = 0;
}
if (sysctlbyname("vm.stats.vm.v_free_count", &free, &size, NULL, 0)) {
return PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_free_count')");
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_free_count')"
);
}
if (sysctlbyname("vfs.bufspace", &buffers, &buffers_size, NULL, 0)) {
return PyErr_SetFromOSErrnoWithSyscall("sysctlbyname('vfs.bufspace')");
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vfs.bufspace')"
);
}

size = sizeof(vm);
if (sysctl(mib, 2, &vm, &size, NULL, 0) != 0) {
return PyErr_SetFromOSErrnoWithSyscall("sysctl(CTL_VM | VM_METER)");
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctl(CTL_VM | VM_METER)"
);
}

return Py_BuildValue("KKKKKKKK",
Expand Down Expand Up @@ -109,20 +117,24 @@ psutil_swap_mem(PyObject *self, PyObject *args) {
kvm_close(kd);

if (sysctlbyname("vm.stats.vm.v_swapin", &swapin, &size, NULL, 0) == -1) {
return PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_swapin)'");
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_swapin)'"
);
}
if (sysctlbyname("vm.stats.vm.v_swapout", &swapout, &size, NULL, 0) == -1){
return PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_swapout)'");
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_swapout)'"
);
}
if (sysctlbyname("vm.stats.vm.v_vnodein", &nodein, &size, NULL, 0) == -1) {
return PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_vnodein)'");
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_vnodein)'"
);
}
if (sysctlbyname("vm.stats.vm.v_vnodeout", &nodeout, &size, NULL, 0) == -1) {
return PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_vnodeout)'");
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctlbyname('vm.stats.vm.v_vnodeout)'"
);
}

return Py_BuildValue(
Expand All @@ -135,4 +147,3 @@ psutil_swap_mem(PyObject *self, PyObject *args) {
nodein + nodeout // swap out
);
}

17 changes: 9 additions & 8 deletions psutil/arch/freebsd/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ psutil_kinfo_proc(pid_t pid, struct kinfo_proc *proc) {

size = sizeof(struct kinfo_proc);
if (sysctl((int *)mib, 4, proc, &size, NULL, 0) == -1) {
PyErr_SetFromOSErrnoWithSyscall("sysctl(KERN_PROC_PID)");
psutil_PyErr_SetFromOSErrnoWithSyscall("sysctl(KERN_PROC_PID)");
return -1;
}

Expand Down Expand Up @@ -92,7 +92,7 @@ psutil_get_proc_list(struct kinfo_proc **procList, size_t *procCount) {
// Call sysctl with a NULL buffer in order to get buffer length.
err = sysctl(name, 3, NULL, &length, NULL, 0);
if (err == -1) {
PyErr_SetFromOSErrnoWithSyscall("sysctl (null buffer)");
psutil_PyErr_SetFromOSErrnoWithSyscall("sysctl (null buffer)");
return 1;
}

Expand Down Expand Up @@ -120,7 +120,7 @@ psutil_get_proc_list(struct kinfo_proc **procList, size_t *procCount) {
}
}

PyErr_SetFromOSErrnoWithSyscall("sysctl()");
psutil_PyErr_SetFromOSErrnoWithSyscall("sysctl()");
return 1;
}
else {
Expand Down Expand Up @@ -177,7 +177,7 @@ psutil_proc_cmdline(PyObject *self, PyObject *args) {

size = argmax;
if (sysctl(mib, 4, procargs, &size, NULL, 0) == -1) {
PyErr_SetFromOSErrnoWithSyscall("sysctl(KERN_PROC_ARGS)");
psutil_PyErr_SetFromOSErrnoWithSyscall("sysctl(KERN_PROC_ARGS)");
goto error;
}

Expand Down Expand Up @@ -238,8 +238,9 @@ psutil_proc_exe(PyObject *self, PyObject *args) {
return PyUnicode_DecodeFSDefault("");
}
else {
return \
PyErr_SetFromOSErrnoWithSyscall("sysctl(KERN_PROC_PATHNAME)");
return psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctl(KERN_PROC_PATHNAME)"
);
}
}
if (size == 0 || strlen(pathname) == 0) {
Expand Down Expand Up @@ -300,7 +301,7 @@ psutil_proc_threads(PyObject *self, PyObject *args) {
size = 0;
error = sysctl(mib, 4, NULL, &size, NULL, 0);
if (error == -1) {
PyErr_SetFromOSErrnoWithSyscall("sysctl(KERN_PROC_INC_THREAD)");
psutil_PyErr_SetFromOSErrnoWithSyscall("sysctl(KERN_PROC_INC_THREAD)");
goto error;
}
if (size == 0) {
Expand All @@ -316,7 +317,7 @@ psutil_proc_threads(PyObject *self, PyObject *args) {

error = sysctl(mib, 4, kip, &size, NULL, 0);
if (error == -1) {
PyErr_SetFromOSErrnoWithSyscall("sysctl(KERN_PROC_INC_THREAD)");
psutil_PyErr_SetFromOSErrnoWithSyscall("sysctl(KERN_PROC_INC_THREAD)");
goto error;
}
if (size == 0) {
Expand Down
4 changes: 2 additions & 2 deletions psutil/arch/linux/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ psutil_net_if_duplex_speed(PyObject* self, PyObject* args) {

sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock == -1)
return PyErr_SetFromOSErrnoWithSyscall("socket()");
return psutil_PyErr_SetFromOSErrnoWithSyscall("socket()");
PSUTIL_STRNCPY(ifr.ifr_name, nic_name, sizeof(ifr.ifr_name));

// duplex and speed
Expand Down Expand Up @@ -102,7 +102,7 @@ psutil_net_if_duplex_speed(PyObject* self, PyObject* args) {
speed = 0;
}
else {
PyErr_SetFromOSErrnoWithSyscall("ioctl(SIOCETHTOOL)");
psutil_PyErr_SetFromOSErrnoWithSyscall("ioctl(SIOCETHTOOL)");
goto error;
}
}
Expand Down
6 changes: 4 additions & 2 deletions psutil/arch/netbsd/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ psutil_proc_cmdline(PyObject *self, PyObject *args) {

st = sysctl(mib, __arraycount(mib), NULL, &len, NULL, 0);
if (st == -1) {
PyErr_SetFromOSErrnoWithSyscall("sysctl(KERN_PROC_ARGV) get size");
psutil_PyErr_SetFromOSErrnoWithSyscall(
"sysctl(KERN_PROC_ARGV) get size"
);
goto error;
}

Expand Down Expand Up @@ -382,7 +384,7 @@ psutil_proc_cmdline(PyObject *self, PyObject *args) {
}
}
else {
PyErr_SetFromOSErrnoWithSyscall("sysctl(KERN_PROC_ARGV)");
psutil_PyErr_SetFromOSErrnoWithSyscall("sysctl(KERN_PROC_ARGV)");
goto error;
}
}
Expand Down
2 changes: 1 addition & 1 deletion psutil/arch/openbsd/socks.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ psutil_net_connections(PyObject *self, PyObject *args) {

ikf = kvm_getfiles(kd, KERN_FILE_BYPID, -1, sizeof(*ikf), &cnt);
if (! ikf) {
PyErr_SetFromOSErrnoWithSyscall("kvm_getfiles");
psutil_PyErr_SetFromOSErrnoWithSyscall("kvm_getfiles");
goto error;
}

Expand Down
2 changes: 1 addition & 1 deletion psutil/arch/osx/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ psutil_cpu_freq(PyObject *self, PyObject *args) {
mib[1] = HW_CPU_FREQ;

if (sysctl(mib, 2, &curr, &len, NULL, 0) < 0)
return PyErr_SetFromOSErrnoWithSyscall("sysctl(HW_CPU_FREQ)");
return psutil_PyErr_SetFromOSErrnoWithSyscall("sysctl(HW_CPU_FREQ)");

if (sysctlbyname("hw.cpufrequency_min", &min, &size, NULL, 0))
psutil_debug("sysctl('hw.cpufrequency_min') failed (set to 0)");
Expand Down
Loading
Loading