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

Signal C syscall in case of exception #1428

merged 12 commits into from Feb 24, 2019

Signal C syscall in case of exception #1428

merged 12 commits into from Feb 24, 2019


Copy link

@giampaolo giampaolo commented Feb 24, 2019

This is aimed at those functions defined in C extension modules which internally calls multiple syscalls. Usually they fail with OSError or WindowsError. We have the error code and the message string but we don't know which syscall caused the error exactly. This is especially bad when receiving a bug report on Windows, since the single functions make invoke multiple syscalls. Instead of asking the user to debug the problem themselves we now pass a debug message string which produces an exception like this:

ERROR: psutil.tests.test_system.TestSystemAPIs.test_net_if_addrs
Traceback (most recent call last):
  File "psutil/tests/", line 582, in test_net_if_addrs
    nic_stats = psutil.net_if_stats()
  File "psutil/", line 2288, in net_if_stats
    return _psplatform.net_if_stats()
  File "psutil/", line 1034, in net_if_stats
    duplex, speed = cext.net_if_duplex_speed(name)
OSError: [Errno 25] Inappropriate ioctl for device (originated from ioctl(SIOCETHTOOL))

When we only exercise one syscall there's no need to add the additional information.
I did this for Linux, OSX, Windows and FreeBSD.

@giampaolo giampaolo merged commit 7a25722 into master Feb 24, 2019
@giampaolo giampaolo deleted the rich-exceptions branch Feb 24, 2019
@giampaolo giampaolo added bug and removed bug labels Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

1 participant