Skip to content

Commit 7bb4d2b

Browse files
committed
Add "info locals --list"
Also start supporting Python 3.9
1 parent fdd6c8b commit 7bb4d2b

2 files changed

Lines changed: 40 additions & 4 deletions

File tree

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import sys
33

44
SYS_VERSION = sys.version_info[0:2]
5-
if not ((3, 1) <= SYS_VERSION <= (3, 8)):
6-
mess = "Python Versions 3.1 to 3.8 are supported only in this package."
5+
if not ((3, 1) <= SYS_VERSION <= (3, 9)):
6+
mess = "Python Versions 3.1 to 3.9 are supported only in this package."
77
if (2, 4) <= SYS_VERSION <= (2, 7):
88
mess += "\nFor your Python, version %s, See trepan2" % sys.version[0:3]
99
elif SYS_VERSION < (2, 4):

trepan/processor/command/info_subcmd/locals.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2008-2009, 2013, 2015, 2018 Rocky Bernstein <rocky@gnu.org>
2+
# Copyright (C) 2008-2009, 2013, 2015, 2018, 2020 Rocky Bernstein <rocky@gnu.org>
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -15,6 +15,8 @@
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
import re
1717

18+
from getopt import getopt, GetoptError
19+
1820
# Our local modules
1921
from trepan.processor.command import base_subcmd as Mbase_subcmd
2022
from trepan.lib import pp as Mpp
@@ -26,7 +28,9 @@
2628
_with_local_varname = re.compile(r'_\[[0-9+]\]')
2729

2830
class InfoLocals(Mbase_subcmd.DebuggerSubcommand):
29-
"""**info locals** [*var1 ...*]
31+
"""**info locals** [-l | --list | | -h --help]
32+
33+
**info locals** [*var1 ...*]
3034
3135
**info locals** *
3236
@@ -54,7 +58,39 @@ def run(self, args):
5458
if not self.proc.curframe:
5559
self.errmsg("No frame selected")
5660
return False
61+
62+
try:
63+
opts, args = getopt(
64+
args,
65+
"hl",
66+
["help", "list"],
67+
)
68+
except GetoptError as err:
69+
# print help information and exit:
70+
self.errmsg(
71+
str(err)
72+
) # will print something like "option -a not recognized"
73+
return
74+
75+
list_only = False
76+
for o, a in opts:
77+
if o in ("-h", "--help"):
78+
self.proc.commands["help"].run(["help", "info", "locals"])
79+
return
80+
elif o in ("-l", "--list"):
81+
list_only = True
82+
else:
83+
self.errmsg("unhandled option '%s'" % o)
84+
pass
85+
pass
86+
87+
5788
names = list(self.proc.curframe.f_locals.keys())
89+
90+
if list_only:
91+
for name in names:
92+
self.msg(name)
93+
return
5894
if len(args) > 0 and args[0] == '*' :
5995
self.section("locals")
6096
self.msg(self.columnize_commands(names))

0 commit comments

Comments
 (0)