diff options
author | Tom Tromey <tromey@adacore.com> | 2023-05-12 08:28:28 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-06-12 12:09:28 -0600 |
commit | 5e20b4cd17c6627f93e2618f369e62228a38367e (patch) | |
tree | 5805aa4425de7b510294124eb0046eadea427ea6 /gdb/python | |
parent | 5c7cdc95aaace0f2eb7a13199a3cbf479617a009 (diff) | |
download | gdb-5e20b4cd17c6627f93e2618f369e62228a38367e.zip gdb-5e20b4cd17c6627f93e2618f369e62228a38367e.tar.gz gdb-5e20b4cd17c6627f93e2618f369e62228a38367e.tar.bz2 |
Use tuples for default arguments in DAP
My co-worker Kévin taught me that using a mutable object as a default
argument in Python is somewhat dangerous, because the object is
created a single time (when the function is defined), and so if it is
mutated in the body of the function, the changes will stick around.
This patch changes the cases like this in DAP to use () rather than []
as the default. This patch is merely preventative, as no bugs like
this are in the code.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/dap/breakpoint.py | 4 | ||||
-rw-r--r-- | gdb/python/lib/gdb/dap/launch.py | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py index 877069f..8ffa182 100644 --- a/gdb/python/lib/gdb/dap/breakpoint.py +++ b/gdb/python/lib/gdb/dap/breakpoint.py @@ -96,7 +96,7 @@ def _set_breakpoints(kind, specs): @request("setBreakpoints") -def set_breakpoint(*, source, breakpoints=[], **args): +def set_breakpoint(*, source, breakpoints=(), **args): if "path" not in source: result = [] else: @@ -188,7 +188,7 @@ def _set_exception_catchpoints(filter_options): "label": "Ada exceptions", "supportsCondition": True, })) -def set_exception_breakpoints(*, filters, filterOptions=[], **args): +def set_exception_breakpoints(*, filters, filterOptions=(), **args): # Convert the 'filters' to the filter-options style. options = [{"filterId": filter} for filter in filters] options.extend(filterOptions) diff --git a/gdb/python/lib/gdb/dap/launch.py b/gdb/python/lib/gdb/dap/launch.py index a46be1d..dc4bf3c 100644 --- a/gdb/python/lib/gdb/dap/launch.py +++ b/gdb/python/lib/gdb/dap/launch.py @@ -36,7 +36,7 @@ def _set_args_env(args, env): # from implementations. Any additions or changes here should be # documented in the gdb manual. @request("launch") -def launch(*, program=None, args=[], env=None, **extra): +def launch(*, program=None, args=(), env=None, **extra): if program is not None: global _program _program = program |