Skip to content

Commit ab8894d

Browse files
committed
Administriva and add a guard check
* Relax xdis version * Check for None in frame more often * Add more type annotations
1 parent de209a5 commit ab8894d

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ description = "GDB-like Python Debugger in the Trepan family"
1515
dependencies = [
1616
"columnize >= 0.3.10",
1717
"pyficache >= 2.5.0",
18-
"xdis > 6.1.6,<6.2.1",
18+
"xdis > 6.1.6,<6.3",
1919
"Pygments >= 2.2.0",
2020
"spark_parser >= 1.8.9, <1.9.2",
2121
"tracer > 1.9.0",

trepan/lib/core.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright (C) 2008-2010, 2013-2016, 2020 2023-2024
3+
# Copyright (C) 2008-2010, 2013-2016, 2020 2023-2025
44
# Rocky Bernstein <rocky@gnu.org>
55
#
66
# This program is free software: you can redistribute it and/or modify
@@ -29,6 +29,7 @@
2929
import os.path as osp
3030
import sys
3131
import threading
32+
from types import FrameType
3233
from typing import Any, Dict, NewType, Optional
3334

3435
# External packages
@@ -187,9 +188,11 @@ def canonic(self, filename):
187188

188189
return canonic
189190

190-
def canonic_filename(self, frame):
191+
def canonic_filename(self, frame: Optional[FrameType]) -> str:
191192
"""Picks out the file name from `frame' and returns its
192193
canonic() value, a string."""
194+
if frame is None:
195+
return "?? - No frame"
193196
return self.canonic(frame.f_code.co_filename)
194197

195198
def filename(self, filename=None):

trepan/lib/stack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def deparse_offset(_code, _name: str, _list_i: int, _) -> tuple:
6464
_with_local_varname = re.compile(r"_\[[0-9+]]")
6565

6666

67-
def count_frames(frame: FrameType, count_start=0):
67+
def count_frames(frame: FrameType, count_start=0) -> int:
6868
"""Return a count of the number of frames"""
6969
count = -count_start
7070
for _ in range(1000):

0 commit comments

Comments
 (0)