Skip to content

Ignore dist-packages in stack trace#196

Merged
okken merged 2 commits intookken:mainfrom
siferati:main
Mar 2, 2026
Merged

Ignore dist-packages in stack trace#196
okken merged 2 commits intookken:mainfrom
siferati:main

Conversation

@siferati
Copy link
Contributor

@siferati siferati commented Mar 2, 2026

Description

As per the comment below, the stack trace should contain only user code.

# we want to trace through user code, not 3rd party or builtin libs

But packages in dist-packages are not currently ignored.

Results

The example below is from a failing check inside a ROS timer callback.

Before

FAILURE: check 1 > 2: Hello world
test_debug.py:38 in test_debug() -> rclpy.spin(foo)
../../../../../../opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py:229 in spin() -> executor.spin_once()
../../../../../../opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py:773 in spin_once() -> self._spin_once_impl(timeout_sec)
../../../../../../opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py:768 in _spin_once_impl() -> handler()
../../../../../../opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/task.py:254 in __call__() -> self._handler.send(None)
../../../../../../opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py:463 in handler() -> await call_coroutine(entity, arg)
../../../../../../opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py:371 in _execute_timer() -> await await_or_execute(tmr.callback)
../../../../../../opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py:107 in await_or_execute() -> return callback(*args)
test_debug.py:17 in _timer_callback() -> expect.greater(a, b, "Hello world")

After

FAILURE: check 1 > 2: Hello world
test_debug.py:17 in _timer_callback() -> expect.greater(a, b, "Hello world")

@okken
Copy link
Owner

okken commented Mar 2, 2026

Cool idea.
Thanks for the PR.
Any thoughts on a way to test it?
not a deal breaker but it’d be cool to have a test case for it

@siferati
Copy link
Contributor Author

siferati commented Mar 2, 2026

Thanks for the quick review!
I added a unit test now, which inserts a dummy frame into the stack trace, simulating a call to 3rd party code.
The test structure is adapted from test_tracebackhide.py::test_normal_pseudo_traceback.
As expected, the tests fails with current master and passes with this PR.

@okken okken merged commit 3f1bd48 into okken:main Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants