@@ -1527,7 +1527,11 @@ def get_selected_frame(cls):
1527
1527
def get_selected_python_frame (cls ):
1528
1528
'''Try to obtain the Frame for the python-related code in the selected
1529
1529
frame, or None'''
1530
- frame = cls .get_selected_frame ()
1530
+ try :
1531
+ frame = cls .get_selected_frame ()
1532
+ except gdb .error :
1533
+ # No frame: Python didn't start yet
1534
+ return None
1531
1535
1532
1536
while frame :
1533
1537
if frame .is_python_frame ():
@@ -1668,6 +1672,10 @@ def invoke(self, args, from_tty):
1668
1672
def move_in_stack (move_up ):
1669
1673
'''Move up or down the stack (for the py-up/py-down command)'''
1670
1674
frame = Frame .get_selected_python_frame ()
1675
+ if not frame :
1676
+ print ('Unable to locate python frame' )
1677
+ return
1678
+
1671
1679
while frame :
1672
1680
if move_up :
1673
1681
iter_frame = frame .older ()
@@ -1730,6 +1738,10 @@ def __init__(self):
1730
1738
1731
1739
def invoke (self , args , from_tty ):
1732
1740
frame = Frame .get_selected_python_frame ()
1741
+ if not frame :
1742
+ print ('Unable to locate python frame' )
1743
+ return
1744
+
1733
1745
while frame :
1734
1746
if frame .is_python_frame ():
1735
1747
frame .print_summary ()
@@ -1747,8 +1759,12 @@ def __init__(self):
1747
1759
1748
1760
1749
1761
def invoke (self , args , from_tty ):
1750
- sys .stdout .write ('Traceback (most recent call first):\n ' )
1751
1762
frame = Frame .get_selected_python_frame ()
1763
+ if not frame :
1764
+ print ('Unable to locate python frame' )
1765
+ return
1766
+
1767
+ sys .stdout .write ('Traceback (most recent call first):\n ' )
1752
1768
while frame :
1753
1769
if frame .is_python_frame ():
1754
1770
frame .print_traceback ()
0 commit comments