Skip to content

Commit 355cd7a

Browse files
Kretzer6019sarahmonod
authored andcommitted
Allowing passing NativeReportingMode.LAST and ALL to print_thread
1 parent 0526605 commit 355cd7a

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/pystack/__main__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ def process_remote(parser: argparse.ArgumentParser, args: argparse.Namespace) ->
292292
locals=args.locals,
293293
method=StackMethod.ALL if args.exhaustive else StackMethod.AUTO,
294294
):
295-
native = args.native_mode != NativeReportingMode.OFF
296-
print_thread(thread, native)
295+
print_thread(thread, args.native_mode)
297296

298297

299298
def format_psinfo_information(psinfo: Dict[str, Any]) -> str:
@@ -423,8 +422,7 @@ def process_core(parser: argparse.ArgumentParser, args: argparse.Namespace) -> N
423422
locals=args.locals,
424423
method=StackMethod.ALL if args.exhaustive else StackMethod.AUTO,
425424
):
426-
native = args.native_mode != NativeReportingMode.OFF
427-
print_thread(thread, native)
425+
print_thread(thread, args.native_mode)
428426

429427

430428
if __name__ == "__main__": # pragma: no cover

src/pystack/_pystack.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class CoreFileAnalyzer:
2424
def missing_modules(self) -> List[str]: ...
2525

2626
class NativeReportingMode(enum.Enum):
27-
ALL = 1
28-
OFF = 2
29-
PYTHON = 3
30-
LAST = 4
27+
ALL = ...
28+
OFF = ...
29+
PYTHON = ...
30+
LAST = ...
3131

3232
class StackMethod(enum.Enum):
3333
ALL = 1

src/pystack/traceback_formatter.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
from typing import Optional
55

66
from .colors import colored
7+
from .engine import NativeReportingMode
78
from .types import NativeFrame
89
from .types import PyCodeObject
910
from .types import PyFrame
1011
from .types import PyThread
1112
from .types import frame_type
1213

1314

14-
def print_thread(thread: PyThread, native: bool) -> None:
15-
for line in format_thread(thread, native):
15+
def print_thread(thread: PyThread, native_mode: NativeReportingMode) -> None:
16+
for line in format_thread(thread, native_mode):
1617
print(line, file=sys.stdout, flush=True)
1718

1819

@@ -62,7 +63,8 @@ def _are_the_stacks_mergeable(thread: PyThread) -> bool:
6263
return n_eval_frames == n_entry_frames
6364

6465

65-
def format_thread(thread: PyThread, native: bool) -> Iterable[str]:
66+
def format_thread(thread: PyThread, native_mode: NativeReportingMode) -> Iterable[str]:
67+
native = native_mode != NativeReportingMode.OFF
6668
current_frame: Optional[PyFrame] = thread.first_frame
6769
if current_frame is None and not native:
6870
yield f"The frame stack for thread {thread.tid} is empty"

0 commit comments

Comments
 (0)