Release history

stackscope 0.2.2 (2024-02-27)

Bugfixes

  • Fixed an inspection error that could occur on Python 3.11 when the subject expression of an async with block covers multiple source lines. (#14)

  • Update greenback glue to support the internal reorganizations in version 1.2.0. (#15)

stackscope 0.2.1 (2024-02-02)

Bugfixes

  • Fixed inspection of async context managers that contain a CLEANUP_THROW bytecode instruction in their __aenter__ sequence. This can appear on 3.12+ if you write an async context manager inside an except or finally block, and would previously produce an inspection warning. (#11)

  • The first invocation of stackscope.extract() no longer leaves a partially-exhausted async generator object to be garbage collected, which previously could confuse async generator finalization hooks. (#12)

stackscope 0.2.0 (2023-12-22)

With this release, stackscope can print full Trio task trees out-of-the-box. Try print(stackscope.extract(trio.lowlevel.current_root_task(), recurse_child_tasks=True)).

Backwards-incompatible changes

User-facing improvements to core logic

  • Added support for representing child tasks in structured concurrency libraries, by allowing Context.children to contain Stacks in addition to the existing support for child Contexts. By default, the child tasks will not have their frames filled out, but you can override this with the new recurse_child_tasks parameter to extract(). (#9)

  • Added Frame.hide_line and Context.hide attributes for more precise control of output.

  • Added a new attribute Stack.root which preserves the original “stack item” object that was passed to extract(). For stacks generated from async child tasks, this will be the Task object.

  • Added support for Python 3.12.

Library support (“glue”) improvements

  • stackscope can now trace seamlessly across Trio/thread boundaries when extracting a stack that includes calls to trio.to_thread.run_sync() and/or trio.from_thread.run(). The functions running in the cross-thread child will appear in the same way that they would if they had been called directly without a thread transition. (#8)

  • Added glue to support pytest-trio. (#4)

  • Updated Trio glue to support unwrapping trio.lowlevel.Tasks and filling in the child tasks of a trio.Nursery.

Improvements for glue developers

  • A library can now ship its own stackscope customizations without requiring that all of its users install stackscope. Any module may define a function called _stackscope_install_glue_(), which stackscope will call when it is first used to extract a stack trace after the module has been imported. (#7)

  • Added unwrap_context_generator() hook for more specific customization of generator-based context managers.

  • Modified the elaborate_frame() hook to be able to return a sequence of stack items rather than just a single one. This permits more expressive augmentation rules, such as inserting elements into the stack trace without removing what would’ve been there if the hook were not present.

  • Added a new function extract_child() for use in customization hooks. It is like extract() except that it reuses the options that were specified for the outer extract() call, and contains some additional logic to prune child task frames if the outer extract() didn’t ask for them.

  • elaborate_frame() now runs after Frame.contexts is populated, so it has the chance to modify the detected context managers.

stackscope 0.1.0 (2023-04-12)

Initial release.