Skip to content

Signal C syscall in case of exception #1428

Merged
giampaolo merged 12 commits intomasterfrom
rich-exceptions
Feb 24, 2019
Merged

Signal C syscall in case of exception #1428
giampaolo merged 12 commits intomasterfrom
rich-exceptions

Conversation

@giampaolo
Copy link
Copy Markdown
Owner

@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/test_system.py", line 582, in test_net_if_addrs
    nic_stats = psutil.net_if_stats()
  File "psutil/__init__.py", line 2288, in net_if_stats
    return _psplatform.net_if_stats()
  File "psutil/_pslinux.py", 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 February 24, 2019 17:55
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant