public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: re-format Python files using black 21.4b0
@ 2021-05-07 14:57 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2021-05-07 14:57 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=13123da89a2c7e06a5312ca6b4b24c68ba1c6c2d

commit 13123da89a2c7e06a5312ca6b4b24c68ba1c6c2d
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Fri May 7 10:56:20 2021 -0400

    gdb: re-format Python files using black 21.4b0
    
    Re-format all Python files using black [1] version 21.4b0.  The goal is
    that from now on, we keep all Python files formatted using black.  And
    that we never have to discuss formatting during review (for these files
    at least) ever again.
    
    One change is needed in gdb.python/py-prettyprint.exp, because it
    matches the string representation of an exception, which shows source
    code.  So the change in formatting must be replicated in the expected
    regexp.
    
    To document our usage of black I plan on adding this to the "GDB Python
    Coding Standards" wiki page [2]:
    
    --8<--
    
    All Python source files under the `gdb/` directory must be formatted
    using black version 21.4b0.
    
    This specific version can be installed using:
    
        $ pip3 install 'black == 21.4b0'
    
    All you need to do to re-format files is run `black <file/directory>`,
    and black will re-format any Python file it finds in there.  It runs
    quite fast, so the simplest is to do:
    
        $ black gdb/
    
    from the top-level.
    
    If you notice that black produces changes unrelated to your patch, it's
    probably because someone forgot to run it before you.  In this case,
    don't include unrelated hunks in your patch.  Push an obvious patch
    fixing the formatting and rebase your work on top of that.
    
    -->8--
    
    Once this is merged, I plan on setting a up an `ignoreRevsFile`
    config so that git-blame ignores this commit, as described here:
    
      https://github.com/psf/black#migrating-your-code-style-without-ruining-git-blame
    
    I also plan on working on a git commit hook (checked in the repo) to
    automatically check the formatting of the Python files on commit.
    
    [1] https://pypi.org/project/black/
    [2] https://sourceware.org/gdb/wiki/Internals%20GDB-Python-Coding-Standards
    
    gdb/ChangeLog:
    
            * Re-format all Python files using black.
    
    gdb/testsuite/ChangeLog:
    
            * Re-format all Python files using black.
            * gdb.python/py-prettyprint.exp (run_lang_tests): Adjust.
    
    Change-Id: I28588a22c2406afd6bc2703774ddfff47cd61919

Diff:
---
 gdb/ChangeLog                                      |   4 +
 gdb/contrib/test_pubnames_and_indexes.py           | 303 +++++++++---------
 gdb/copyright.py                                   | 289 ++++++++++++-----
 gdb/python/lib/gdb/FrameDecorator.py               |  43 +--
 gdb/python/lib/gdb/FrameIterator.py                |   1 +
 gdb/python/lib/gdb/__init__.py                     |  60 ++--
 gdb/python/lib/gdb/command/__init__.py             |   2 -
 gdb/python/lib/gdb/command/explore.py              | 342 ++++++++++++---------
 gdb/python/lib/gdb/command/frame_filters.py        | 205 ++++++------
 gdb/python/lib/gdb/command/pretty_printers.py      | 186 ++++++-----
 gdb/python/lib/gdb/command/prompt.py               |  30 +-
 gdb/python/lib/gdb/command/type_printers.py        |  41 +--
 gdb/python/lib/gdb/command/unwinders.py            |  94 +++---
 gdb/python/lib/gdb/command/xmethods.py             | 133 ++++----
 gdb/python/lib/gdb/frames.py                       |  33 +-
 gdb/python/lib/gdb/function/as_string.py           |  11 +-
 gdb/python/lib/gdb/function/caller_is.py           |  87 +++---
 gdb/python/lib/gdb/function/strfns.py              | 100 +++---
 gdb/python/lib/gdb/printer/bound_registers.py      |  16 +-
 gdb/python/lib/gdb/printing.py                     |  27 +-
 gdb/python/lib/gdb/prompt.py                       |  75 +++--
 gdb/python/lib/gdb/types.py                        |  25 +-
 gdb/python/lib/gdb/unwinder.py                     |   8 +-
 gdb/python/lib/gdb/xmethod.py                      |  25 +-
 gdb/python/python-config.py                        |  83 ++---
 gdb/syscalls/arm-linux.py                          |  29 +-
 gdb/system-gdbinit/elinos.py                       |   5 +-
 gdb/system-gdbinit/wrs-linux.py                    |   4 +-
 gdb/testsuite/ChangeLog                            |   5 +
 gdb/testsuite/analyze-racy-logs.py                 | 100 +++---
 gdb/testsuite/gdb.ada/pp-rec-component.py          |   2 +-
 gdb/testsuite/gdb.perf/backtrace.py                |  15 +-
 gdb/testsuite/gdb.perf/disassemble.py              |  20 +-
 gdb/testsuite/gdb.perf/gmonster-null-lookup.py     |   4 +-
 .../gdb.perf/gmonster-pervasive-typedef.py         |   4 +-
 gdb/testsuite/gdb.perf/gmonster-print-cerr.py      |   4 +-
 gdb/testsuite/gdb.perf/gmonster-ptype-string.py    |   4 +-
 gdb/testsuite/gdb.perf/gmonster-runto-main.py      |   4 +-
 gdb/testsuite/gdb.perf/gmonster-select-file.py     |   4 +-
 gdb/testsuite/gdb.perf/lib/perftest/measure.py     |  16 +-
 gdb/testsuite/gdb.perf/lib/perftest/perftest.py    |  11 +-
 gdb/testsuite/gdb.perf/lib/perftest/reporter.py    |  25 +-
 gdb/testsuite/gdb.perf/lib/perftest/testresult.py  |   8 +-
 gdb/testsuite/gdb.perf/lib/perftest/utils.py       |   3 +-
 gdb/testsuite/gdb.perf/single-step.py              |   5 +-
 gdb/testsuite/gdb.perf/skip-command.py             |   5 +-
 gdb/testsuite/gdb.perf/skip-prologue.py            |   1 +
 gdb/testsuite/gdb.perf/solib.py                    |  16 +-
 gdb/testsuite/gdb.perf/template-breakpoints.py     |   5 +-
 .../gdb.python/py-auto-load-chaining-f1.o-gdb.py   |  22 +-
 .../gdb.python/py-auto-load-chaining-f2.o-gdb.py   |   7 +-
 gdb/testsuite/gdb.python/py-bad-printers.py        |  18 +-
 .../gdb.python/py-breakpoint-create-fail.py        |   4 +-
 gdb/testsuite/gdb.python/py-completion.py          | 241 +++++++++------
 gdb/testsuite/gdb.python/py-error.py               |   8 +-
 gdb/testsuite/gdb.python/py-events.py              | 176 ++++++-----
 gdb/testsuite/gdb.python/py-finish-breakpoint.py   | 108 +++----
 gdb/testsuite/gdb.python/py-finish-breakpoint2.py  |  17 +-
 gdb/testsuite/gdb.python/py-format-string.py       |  23 +-
 gdb/testsuite/gdb.python/py-frame-args.py          |  37 ++-
 gdb/testsuite/gdb.python/py-framefilter-addr.py    |  23 +-
 .../gdb.python/py-framefilter-invalidarg.py        |  26 +-
 gdb/testsuite/gdb.python/py-framefilter.py         |  77 ++---
 gdb/testsuite/gdb.python/py-mi-events-gdb.py       |  26 +-
 .../gdb.python/py-mi-var-info-path-expression.py   |  54 ++--
 gdb/testsuite/gdb.python/py-nested-maps.py         |  71 +++--
 gdb/testsuite/gdb.python/py-objfile-script-gdb.py  |  26 +-
 gdb/testsuite/gdb.python/py-pp-integral.py         |   2 +-
 gdb/testsuite/gdb.python/py-pp-maint.py            |  24 +-
 gdb/testsuite/gdb.python/py-pp-re-notag.py         |   2 +-
 gdb/testsuite/gdb.python/py-pp-registration.py     |  16 +-
 gdb/testsuite/gdb.python/py-prettyprint.exp        |   2 +-
 gdb/testsuite/gdb.python/py-prettyprint.py         | 312 ++++++++++---------
 gdb/testsuite/gdb.python/py-recurse-unwind.py      |  28 +-
 gdb/testsuite/gdb.python/py-section-script.py      |  26 +-
 gdb/testsuite/gdb.python/py-typeprint.py           |   9 +-
 gdb/testsuite/gdb.python/py-unwind-inline.py       |  37 +--
 gdb/testsuite/gdb.python/py-unwind-maint.py        |   9 +-
 gdb/testsuite/gdb.python/py-unwind.py              |  26 +-
 gdb/testsuite/gdb.python/py-xmethods.py            | 136 ++++----
 gdb/testsuite/gdb.python/source2.py                |   2 +-
 gdb/testsuite/gdb.python/tui-window-disabled.py    |  49 +--
 gdb/testsuite/gdb.python/tui-window.py             |   8 +-
 gdb/testsuite/print-ts.py                          |   9 +-
 84 files changed, 2348 insertions(+), 1835 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 70d4972cd52..45b048da4f5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2021-05-07  Simon Marchi  <simon.marchi@polymtl.ca>
+
+	* Re-format all Python files using black.
+
 2021-05-07  Tom de Vries  <tdevries@suse.de>
 
 	PR symtab/26327
diff --git a/gdb/contrib/test_pubnames_and_indexes.py b/gdb/contrib/test_pubnames_and_indexes.py
index 67e2430f887..cc767a2cf10 100644
--- a/gdb/contrib/test_pubnames_and_indexes.py
+++ b/gdb/contrib/test_pubnames_and_indexes.py
@@ -39,7 +39,7 @@ to those that gdb produces.
 Finally, check that all strings are canonicalized identically.
 """
 
-__author__ = 'saugustine@google.com (Sterling Augustine)'
+__author__ = "saugustine@google.com (Sterling Augustine)"
 
 import os
 import subprocess
@@ -49,159 +49,176 @@ OBJCOPY = None
 READELF = None
 GDB = None
 
+
 def get_pub_info(filename, readelf_option):
-  """Parse and return all the pubnames or pubtypes produced by readelf with the
-  given option.
-  """
-  readelf = subprocess.Popen([READELF, '--debug-dump=' + readelf_option,
-                                       filename], stdout=subprocess.PIPE)
-  pubnames = []
-
-  in_list = False;
-  for line in readelf.stdout:
-    fields = line.split(None, 1)
-    if (len(fields) == 2 and fields[0] == 'Offset'
-        and fields[1].strip() == 'Name'):
-      in_list = True
-    # Either a blank-line or a new Length field terminates the current section.
-    elif (len(fields) == 0 or fields[0] == 'Length:'):
-      in_list = False;
-    elif (in_list):
-      pubnames.append(fields[1].strip())
-
-  readelf.wait()
-  return pubnames
+    """Parse and return all the pubnames or pubtypes produced by readelf with the
+    given option.
+    """
+    readelf = subprocess.Popen(
+        [READELF, "--debug-dump=" + readelf_option, filename], stdout=subprocess.PIPE
+    )
+    pubnames = []
+
+    in_list = False
+    for line in readelf.stdout:
+        fields = line.split(None, 1)
+        if len(fields) == 2 and fields[0] == "Offset" and fields[1].strip() == "Name":
+            in_list = True
+        # Either a blank-line or a new Length field terminates the current section.
+        elif len(fields) == 0 or fields[0] == "Length:":
+            in_list = False
+        elif in_list:
+            pubnames.append(fields[1].strip())
+
+    readelf.wait()
+    return pubnames
 
 
 def get_gdb_index(filename):
-  """Use readelf to dump the gdb index and collect the types and names"""
-  readelf = subprocess.Popen([READELF, '--debug-dump=gdb_index',
-                              filename], stdout=subprocess.PIPE)
-  index_symbols = []
-  symbol_table_started = False
-  for line in readelf.stdout:
-    if (line == 'Symbol table:\n'):
-      symbol_table_started = True;
-    elif (symbol_table_started):
-      # Readelf prints gdb-index lines formatted like so:
-      # [  4] two::c2<double>::c2: 0
-      # So take the string between the first close bracket and the last colon.
-      index_symbols.append(line[line.find(']') + 2: line.rfind(':')])
-
-  readelf.wait()
-  return index_symbols
+    """Use readelf to dump the gdb index and collect the types and names"""
+    readelf = subprocess.Popen(
+        [READELF, "--debug-dump=gdb_index", filename], stdout=subprocess.PIPE
+    )
+    index_symbols = []
+    symbol_table_started = False
+    for line in readelf.stdout:
+        if line == "Symbol table:\n":
+            symbol_table_started = True
+        elif symbol_table_started:
+            # Readelf prints gdb-index lines formatted like so:
+            # [  4] two::c2<double>::c2: 0
+            # So take the string between the first close bracket and the last colon.
+            index_symbols.append(line[line.find("]") + 2 : line.rfind(":")])
+
+    readelf.wait()
+    return index_symbols
 
 
 def CheckSets(list0, list1, name0, name1):
-  """Report any setwise differences between the two lists"""
-
-  if len(list0) == 0 or len(list1) == 0:
+    """Report any setwise differences between the two lists"""
+
+    if len(list0) == 0 or len(list1) == 0:
+        return False
+
+    difference0 = set(list0) - set(list1)
+    if len(difference0) != 0:
+        print "Elements in " + name0 + " but not " + name1 + ": (",
+        print len(difference0),
+        print ")"
+        for element in difference0:
+            print "  " + element
+
+    difference1 = set(list1) - set(list0)
+    if len(difference1) != 0:
+        print "Elements in " + name1 + " but not " + name0 + ": (",
+        print len(difference1),
+        print ")"
+        for element in difference1:
+            print "  " + element
+
+    if len(difference0) != 0 or len(difference1) != 0:
+        return True
+
+    print name0 + " and " + name1 + " are identical."
     return False
 
-  difference0 = set(list0) - set(list1)
-  if len(difference0) != 0:
-    print "Elements in " + name0 + " but not " + name1 + ": (",
-    print len(difference0),
-    print ")"
-    for element in difference0:
-      print "  " + element
-
-  difference1 = set(list1) - set(list0)
-  if len(difference1) != 0:
-    print "Elements in " + name1 + " but not " + name0 + ": (",
-    print len(difference1),
-    print ")"
-    for element in difference1:
-      print "  " + element
-
-  if (len(difference0) != 0 or len(difference1) != 0):
-    return True
-
-  print name0 + " and " + name1 + " are identical."
-  return False
-
 
 def find_executables():
-  """Find the copies of readelf, objcopy and gdb to use."""
-  # Executable finding logic follows cc-with-index.sh
-  global READELF
-  READELF = os.getenv('READELF')
-  if READELF is None:
-    READELF = 'readelf'
-  global OBJCOPY
-  OBJCOPY = os.getenv('OBJCOPY')
-  if OBJCOPY is None:
-    OBJCOPY = 'objcopy'
-
-  global GDB
-  GDB = os.getenv('GDB')
-  if (GDB is None):
-    if os.path.isfile('./gdb') and os.access('./gdb', os.X_OK):
-      GDB = './gdb'
-    elif os.path.isfile('../gdb') and os.access('../gdb', os.X_OK):
-      GDB = '../gdb'
-    elif os.path.isfile('../../gdb') and os.access('../../gdb', os.X_OK):
-      GDB = '../../gdb'
-    else:
-      # Punt and use the gdb in the path.
-      GDB = 'gdb'
+    """Find the copies of readelf, objcopy and gdb to use."""
+    # Executable finding logic follows cc-with-index.sh
+    global READELF
+    READELF = os.getenv("READELF")
+    if READELF is None:
+        READELF = "readelf"
+    global OBJCOPY
+    OBJCOPY = os.getenv("OBJCOPY")
+    if OBJCOPY is None:
+        OBJCOPY = "objcopy"
+
+    global GDB
+    GDB = os.getenv("GDB")
+    if GDB is None:
+        if os.path.isfile("./gdb") and os.access("./gdb", os.X_OK):
+            GDB = "./gdb"
+        elif os.path.isfile("../gdb") and os.access("../gdb", os.X_OK):
+            GDB = "../gdb"
+        elif os.path.isfile("../../gdb") and os.access("../../gdb", os.X_OK):
+            GDB = "../../gdb"
+        else:
+            # Punt and use the gdb in the path.
+            GDB = "gdb"
 
 
 def main(argv):
-  """The main subprogram."""
-  if len(argv) != 2:
-    print "Usage: test_pubnames_and_indexes.py <filename>"
-    sys.exit(2)
-
-  find_executables();
-
-  # Get the index produced by Gold--It should have been built into the binary.
-  gold_index = get_gdb_index(argv[1])
-
-  # Collect the pubnames and types list
-  pubs_list = get_pub_info(argv[1], "pubnames")
-  pubs_list = pubs_list + get_pub_info(argv[1], "pubtypes")
-
-  # Generate a .gdb_index with gdb
-  gdb_index_file = argv[1] + '.gdb-generated-index'
-  subprocess.check_call([OBJCOPY, '--remove-section', '.gdb_index',
-                         argv[1], gdb_index_file])
-  subprocess.check_call([GDB, '-batch', '-nx', gdb_index_file,
-                         '-ex', 'save gdb-index ' + os.path.dirname(argv[1]),
-                         '-ex', 'quit'])
-  subprocess.check_call([OBJCOPY, '--add-section',
-                         '.gdb_index=' + gdb_index_file + '.gdb-index',
-                         gdb_index_file])
-  gdb_index = get_gdb_index(gdb_index_file)
-  os.remove(gdb_index_file)
-  os.remove(gdb_index_file + '.gdb-index')
-
-  failed = False
-  gdb_index.sort()
-  gold_index.sort()
-  pubs_list.sort()
-
-  # Find the differences between the various indices.
-  if len(gold_index) == 0:
-    print "Gold index is empty"
-    failed |= True
-
-  if len(gdb_index) == 0:
-    print "Gdb index is empty"
-    failed |= True
-
-  if len(pubs_list) == 0:
-    print "Pubs list is empty"
-    failed |= True
-
-  failed |= CheckSets(gdb_index, gold_index, "gdb index", "gold index")
-  failed |= CheckSets(pubs_list, gold_index, "pubs list", "gold index")
-  failed |= CheckSets(pubs_list, gdb_index, "pubs list", "gdb index")
-
-  if failed:
-    print "Test failed"
-    sys.exit(1)
-
-
-if __name__ == '__main__':
-  main(sys.argv)
+    """The main subprogram."""
+    if len(argv) != 2:
+        print "Usage: test_pubnames_and_indexes.py <filename>"
+        sys.exit(2)
+
+    find_executables()
+
+    # Get the index produced by Gold--It should have been built into the binary.
+    gold_index = get_gdb_index(argv[1])
+
+    # Collect the pubnames and types list
+    pubs_list = get_pub_info(argv[1], "pubnames")
+    pubs_list = pubs_list + get_pub_info(argv[1], "pubtypes")
+
+    # Generate a .gdb_index with gdb
+    gdb_index_file = argv[1] + ".gdb-generated-index"
+    subprocess.check_call(
+        [OBJCOPY, "--remove-section", ".gdb_index", argv[1], gdb_index_file]
+    )
+    subprocess.check_call(
+        [
+            GDB,
+            "-batch",
+            "-nx",
+            gdb_index_file,
+            "-ex",
+            "save gdb-index " + os.path.dirname(argv[1]),
+            "-ex",
+            "quit",
+        ]
+    )
+    subprocess.check_call(
+        [
+            OBJCOPY,
+            "--add-section",
+            ".gdb_index=" + gdb_index_file + ".gdb-index",
+            gdb_index_file,
+        ]
+    )
+    gdb_index = get_gdb_index(gdb_index_file)
+    os.remove(gdb_index_file)
+    os.remove(gdb_index_file + ".gdb-index")
+
+    failed = False
+    gdb_index.sort()
+    gold_index.sort()
+    pubs_list.sort()
+
+    # Find the differences between the various indices.
+    if len(gold_index) == 0:
+        print "Gold index is empty"
+        failed |= True
+
+    if len(gdb_index) == 0:
+        print "Gdb index is empty"
+        failed |= True
+
+    if len(pubs_list) == 0:
+        print "Pubs list is empty"
+        failed |= True
+
+    failed |= CheckSets(gdb_index, gold_index, "gdb index", "gold index")
+    failed |= CheckSets(pubs_list, gold_index, "pubs list", "gold index")
+    failed |= CheckSets(pubs_list, gdb_index, "pubs list", "gdb index")
+
+    if failed:
+        print "Test failed"
+        sys.exit(1)
+
+
+if __name__ == "__main__":
+    main(sys.argv)
diff --git a/gdb/copyright.py b/gdb/copyright.py
index f9c96b00079..e501e2533c2 100644
--- a/gdb/copyright.py
+++ b/gdb/copyright.py
@@ -47,23 +47,32 @@ def get_update_list():
     """
     result = []
     for gdb_dir in (
-        'gdb', 'gdbserver', 'gdbsupport', 'gnulib', 'sim', 'include/gdb',
+        "gdb",
+        "gdbserver",
+        "gdbsupport",
+        "gnulib",
+        "sim",
+        "include/gdb",
     ):
         for root, dirs, files in os.walk(gdb_dir, topdown=True):
             for dirname in dirs:
                 reldirname = "%s/%s" % (root, dirname)
-                if (dirname in EXCLUDE_ALL_LIST
+                if (
+                    dirname in EXCLUDE_ALL_LIST
                     or reldirname in EXCLUDE_LIST
                     or reldirname in NOT_FSF_LIST
-                    or reldirname in BY_HAND):
+                    or reldirname in BY_HAND
+                ):
                     # Prune this directory from our search list.
                     dirs.remove(dirname)
             for filename in files:
                 relpath = "%s/%s" % (root, filename)
-                if (filename in EXCLUDE_ALL_LIST
+                if (
+                    filename in EXCLUDE_ALL_LIST
                     or relpath in EXCLUDE_LIST
                     or relpath in NOT_FSF_LIST
-                    or relpath in BY_HAND):
+                    or relpath in BY_HAND
+                ):
                     # Ignore this file.
                     pass
                 else:
@@ -80,15 +89,18 @@ def update_files(update_list):
     # all years should be collapsed to one single year interval,
     # even if there are "holes" in the list of years found in the
     # original copyright notice (OK'ed by the FSF, case [gnu.org #719834]).
-    os.environ['UPDATE_COPYRIGHT_USE_INTERVALS'] = '2'
+    os.environ["UPDATE_COPYRIGHT_USE_INTERVALS"] = "2"
 
     # Perform the update, and save the output in a string.
-    update_cmd = ['bash', 'gnulib/import/extra/update-copyright']
+    update_cmd = ["bash", "gnulib/import/extra/update-copyright"]
     update_cmd += update_list
 
-    p = subprocess.Popen(update_cmd, stdout=subprocess.PIPE,
-                         stderr=subprocess.STDOUT,
-                         encoding=locale.getpreferredencoding())
+    p = subprocess.Popen(
+        update_cmd,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.STDOUT,
+        encoding=locale.getpreferredencoding(),
+    )
     update_out = p.communicate()[0]
 
     # Process the output.  Typically, a lot of files do not have
@@ -100,7 +112,7 @@ def update_files(update_list):
     # short of looking at each file and seeing which notice is appropriate.
     # Too much work! (~4,000 files listed as of 2012-01-03).
     update_out = update_out.splitlines(keepends=False)
-    warning_string = ': warning: copyright statement not found'
+    warning_string = ": warning: copyright statement not found"
     warning_len = len(warning_string)
 
     for line in update_out:
@@ -134,11 +146,11 @@ def may_have_copyright_notice(filename):
     # so just open the file as a byte stream. We only need to search
     # for a pattern that should be the same regardless of encoding,
     # so that should be good enough.
-    fd = open(filename, 'rb')
+    fd = open(filename, "rb")
 
     lineno = 1
     for line in fd:
-        if b'Copyright' in line:
+        if b"Copyright" in line:
             return True
         lineno += 1
         if lineno > 50:
@@ -146,36 +158,41 @@ def may_have_copyright_notice(filename):
     return False
 
 
-def main ():
+def main():
     """The main subprogram."""
     root_dir = os.path.dirname(os.getcwd())
     os.chdir(root_dir)
 
-    if not (os.path.isdir('gdb') and
-            os.path.isfile("gnulib/import/extra/update-copyright")):
+    if not (
+        os.path.isdir("gdb") and os.path.isfile("gnulib/import/extra/update-copyright")
+    ):
         print("Error: This script must be called from the gdb directory.")
         sys.exit(1)
 
     update_list = get_update_list()
-    update_files (update_list)
+    update_files(update_list)
 
     # Remind the user that some files need to be updated by HAND...
 
     if MULTIPLE_COPYRIGHT_HEADERS:
         print()
-        print("\033[31m"
-              "REMINDER: Multiple copyright headers must be updated by hand:"
-              "\033[0m")
+        print(
+            "\033[31m"
+            "REMINDER: Multiple copyright headers must be updated by hand:"
+            "\033[0m"
+        )
         for filename in MULTIPLE_COPYRIGHT_HEADERS:
             print("  ", filename)
 
     if BY_HAND:
         print()
-        print("\033[31mREMINDER: The following files must be updated by hand." \
-              "\033[0m")
+        print(
+            "\033[31mREMINDER: The following files must be updated by hand." "\033[0m"
+        )
         for filename in BY_HAND:
             print("  ", filename)
 
+
 ############################################################################
 #
 # Some constants, placed at the end because they take up a lot of room.
@@ -190,11 +207,11 @@ def main ():
 #
 # Filenames are relative to the root directory.
 EXCLUDE_LIST = (
-    'gdb/nat/glibc_thread_db.h',
-    'gdb/CONTRIBUTE',
-    'gnulib/import',
-    'gnulib/config.in',
-    'gnulib/Makefile.in',
+    "gdb/nat/glibc_thread_db.h",
+    "gdb/CONTRIBUTE",
+    "gnulib/import",
+    "gnulib/config.in",
+    "gnulib/Makefile.in",
 )
 
 # Files which should not be modified, either because they are
@@ -206,8 +223,14 @@ EXCLUDE_LIST = (
 # Eg: We want all files named COPYING to be left untouched.
 
 EXCLUDE_ALL_LIST = (
-    "COPYING", "COPYING.LIB", "CVS", "configure", "copying.c",
-    "fdl.texi", "gpl.texi", "aclocal.m4",
+    "COPYING",
+    "COPYING.LIB",
+    "CVS",
+    "configure",
+    "copying.c",
+    "fdl.texi",
+    "gpl.texi",
+    "aclocal.m4",
 )
 
 # The list of files to update by hand.
@@ -230,66 +253,166 @@ NOT_FSF_LIST = (
     "gdb/exc_request.defs",
     "gdb/gdbtk",
     "gdb/testsuite/gdb.gdbtk/",
-    "sim/arm/armemu.h", "sim/arm/armos.c", "sim/arm/gdbhost.c",
-    "sim/arm/dbg_hif.h", "sim/arm/dbg_conf.h", "sim/arm/communicate.h",
-    "sim/arm/armos.h", "sim/arm/armcopro.c", "sim/arm/armemu.c",
-    "sim/arm/kid.c", "sim/arm/thumbemu.c", "sim/arm/armdefs.h",
-    "sim/arm/armopts.h", "sim/arm/dbg_cp.h", "sim/arm/dbg_rdi.h",
-    "sim/arm/parent.c", "sim/arm/armsupp.c", "sim/arm/armrdi.c",
-    "sim/arm/bag.c", "sim/arm/armvirt.c", "sim/arm/main.c", "sim/arm/bag.h",
-    "sim/arm/communicate.c", "sim/arm/gdbhost.h", "sim/arm/armfpe.h",
+    "sim/arm/armemu.h",
+    "sim/arm/armos.c",
+    "sim/arm/gdbhost.c",
+    "sim/arm/dbg_hif.h",
+    "sim/arm/dbg_conf.h",
+    "sim/arm/communicate.h",
+    "sim/arm/armos.h",
+    "sim/arm/armcopro.c",
+    "sim/arm/armemu.c",
+    "sim/arm/kid.c",
+    "sim/arm/thumbemu.c",
+    "sim/arm/armdefs.h",
+    "sim/arm/armopts.h",
+    "sim/arm/dbg_cp.h",
+    "sim/arm/dbg_rdi.h",
+    "sim/arm/parent.c",
+    "sim/arm/armsupp.c",
+    "sim/arm/armrdi.c",
+    "sim/arm/bag.c",
+    "sim/arm/armvirt.c",
+    "sim/arm/main.c",
+    "sim/arm/bag.h",
+    "sim/arm/communicate.c",
+    "sim/arm/gdbhost.h",
+    "sim/arm/armfpe.h",
     "sim/arm/arminit.c",
-    "sim/common/cgen-fpu.c", "sim/common/cgen-fpu.h",
+    "sim/common/cgen-fpu.c",
+    "sim/common/cgen-fpu.h",
     "sim/common/cgen-accfp.c",
-    "sim/mips/m16run.c", "sim/mips/sim-main.c",
+    "sim/mips/m16run.c",
+    "sim/mips/sim-main.c",
     "sim/moxie/moxie-gdb.dts",
     # Not a single file in sim/ppc/ appears to be copyright FSF :-(.
-    "sim/ppc/filter.h", "sim/ppc/gen-support.h", "sim/ppc/ld-insn.h",
-    "sim/ppc/hw_sem.c", "sim/ppc/hw_disk.c", "sim/ppc/idecode_branch.h",
-    "sim/ppc/sim-endian.h", "sim/ppc/table.c", "sim/ppc/hw_core.c",
-    "sim/ppc/gen-support.c", "sim/ppc/gen-semantics.h", "sim/ppc/cpu.h",
-    "sim/ppc/sim_callbacks.h", "sim/ppc/RUN", "sim/ppc/Makefile.in",
-    "sim/ppc/emul_chirp.c", "sim/ppc/hw_nvram.c", "sim/ppc/dc-test.01",
-    "sim/ppc/hw_phb.c", "sim/ppc/hw_eeprom.c", "sim/ppc/bits.h",
-    "sim/ppc/hw_vm.c", "sim/ppc/cap.h", "sim/ppc/os_emul.h",
-    "sim/ppc/options.h", "sim/ppc/gen-idecode.c", "sim/ppc/filter.c",
-    "sim/ppc/corefile-n.h", "sim/ppc/std-config.h", "sim/ppc/ld-decode.h",
-    "sim/ppc/filter_filename.h", "sim/ppc/hw_shm.c",
-    "sim/ppc/pk_disklabel.c", "sim/ppc/dc-simple", "sim/ppc/misc.h",
-    "sim/ppc/device_table.h", "sim/ppc/ld-insn.c", "sim/ppc/inline.c",
-    "sim/ppc/emul_bugapi.h", "sim/ppc/hw_cpu.h", "sim/ppc/debug.h",
-    "sim/ppc/hw_ide.c", "sim/ppc/debug.c", "sim/ppc/gen-itable.h",
-    "sim/ppc/interrupts.c", "sim/ppc/hw_glue.c", "sim/ppc/emul_unix.c",
-    "sim/ppc/sim_calls.c", "sim/ppc/dc-complex", "sim/ppc/ld-cache.c",
-    "sim/ppc/registers.h", "sim/ppc/dc-test.02", "sim/ppc/options.c",
-    "sim/ppc/igen.h", "sim/ppc/registers.c", "sim/ppc/device.h",
-    "sim/ppc/emul_chirp.h", "sim/ppc/hw_register.c", "sim/ppc/hw_init.c",
-    "sim/ppc/sim-endian-n.h", "sim/ppc/filter_filename.c",
-    "sim/ppc/bits.c", "sim/ppc/idecode_fields.h", "sim/ppc/hw_memory.c",
-    "sim/ppc/misc.c", "sim/ppc/double.c", "sim/ppc/psim.h",
-    "sim/ppc/hw_trace.c", "sim/ppc/emul_netbsd.h", "sim/ppc/psim.c",
-    "sim/ppc/ppc-instructions", "sim/ppc/tree.h", "sim/ppc/README",
-    "sim/ppc/gen-icache.h", "sim/ppc/gen-model.h", "sim/ppc/ld-cache.h",
-    "sim/ppc/mon.c", "sim/ppc/corefile.h", "sim/ppc/vm.c",
-    "sim/ppc/INSTALL", "sim/ppc/gen-model.c", "sim/ppc/hw_cpu.c",
-    "sim/ppc/corefile.c", "sim/ppc/hw_opic.c", "sim/ppc/gen-icache.c",
-    "sim/ppc/events.h", "sim/ppc/os_emul.c", "sim/ppc/emul_generic.c",
-    "sim/ppc/main.c", "sim/ppc/hw_com.c", "sim/ppc/gen-semantics.c",
-    "sim/ppc/emul_bugapi.c", "sim/ppc/device.c", "sim/ppc/emul_generic.h",
-    "sim/ppc/tree.c", "sim/ppc/mon.h", "sim/ppc/interrupts.h",
-    "sim/ppc/cap.c", "sim/ppc/cpu.c", "sim/ppc/hw_phb.h",
-    "sim/ppc/device_table.c", "sim/ppc/lf.c", "sim/ppc/lf.c",
-    "sim/ppc/dc-stupid", "sim/ppc/hw_pal.c", "sim/ppc/ppc-spr-table",
-    "sim/ppc/emul_unix.h", "sim/ppc/words.h", "sim/ppc/basics.h",
-    "sim/ppc/hw_htab.c", "sim/ppc/lf.h", "sim/ppc/ld-decode.c",
-    "sim/ppc/sim-endian.c", "sim/ppc/gen-itable.c",
-    "sim/ppc/idecode_expression.h", "sim/ppc/table.h", "sim/ppc/dgen.c",
-    "sim/ppc/events.c", "sim/ppc/gen-idecode.h", "sim/ppc/emul_netbsd.c",
-    "sim/ppc/igen.c", "sim/ppc/vm_n.h", "sim/ppc/vm.h",
-    "sim/ppc/hw_iobus.c", "sim/ppc/inline.h",
+    "sim/ppc/filter.h",
+    "sim/ppc/gen-support.h",
+    "sim/ppc/ld-insn.h",
+    "sim/ppc/hw_sem.c",
+    "sim/ppc/hw_disk.c",
+    "sim/ppc/idecode_branch.h",
+    "sim/ppc/sim-endian.h",
+    "sim/ppc/table.c",
+    "sim/ppc/hw_core.c",
+    "sim/ppc/gen-support.c",
+    "sim/ppc/gen-semantics.h",
+    "sim/ppc/cpu.h",
+    "sim/ppc/sim_callbacks.h",
+    "sim/ppc/RUN",
+    "sim/ppc/Makefile.in",
+    "sim/ppc/emul_chirp.c",
+    "sim/ppc/hw_nvram.c",
+    "sim/ppc/dc-test.01",
+    "sim/ppc/hw_phb.c",
+    "sim/ppc/hw_eeprom.c",
+    "sim/ppc/bits.h",
+    "sim/ppc/hw_vm.c",
+    "sim/ppc/cap.h",
+    "sim/ppc/os_emul.h",
+    "sim/ppc/options.h",
+    "sim/ppc/gen-idecode.c",
+    "sim/ppc/filter.c",
+    "sim/ppc/corefile-n.h",
+    "sim/ppc/std-config.h",
+    "sim/ppc/ld-decode.h",
+    "sim/ppc/filter_filename.h",
+    "sim/ppc/hw_shm.c",
+    "sim/ppc/pk_disklabel.c",
+    "sim/ppc/dc-simple",
+    "sim/ppc/misc.h",
+    "sim/ppc/device_table.h",
+    "sim/ppc/ld-insn.c",
+    "sim/ppc/inline.c",
+    "sim/ppc/emul_bugapi.h",
+    "sim/ppc/hw_cpu.h",
+    "sim/ppc/debug.h",
+    "sim/ppc/hw_ide.c",
+    "sim/ppc/debug.c",
+    "sim/ppc/gen-itable.h",
+    "sim/ppc/interrupts.c",
+    "sim/ppc/hw_glue.c",
+    "sim/ppc/emul_unix.c",
+    "sim/ppc/sim_calls.c",
+    "sim/ppc/dc-complex",
+    "sim/ppc/ld-cache.c",
+    "sim/ppc/registers.h",
+    "sim/ppc/dc-test.02",
+    "sim/ppc/options.c",
+    "sim/ppc/igen.h",
+    "sim/ppc/registers.c",
+    "sim/ppc/device.h",
+    "sim/ppc/emul_chirp.h",
+    "sim/ppc/hw_register.c",
+    "sim/ppc/hw_init.c",
+    "sim/ppc/sim-endian-n.h",
+    "sim/ppc/filter_filename.c",
+    "sim/ppc/bits.c",
+    "sim/ppc/idecode_fields.h",
+    "sim/ppc/hw_memory.c",
+    "sim/ppc/misc.c",
+    "sim/ppc/double.c",
+    "sim/ppc/psim.h",
+    "sim/ppc/hw_trace.c",
+    "sim/ppc/emul_netbsd.h",
+    "sim/ppc/psim.c",
+    "sim/ppc/ppc-instructions",
+    "sim/ppc/tree.h",
+    "sim/ppc/README",
+    "sim/ppc/gen-icache.h",
+    "sim/ppc/gen-model.h",
+    "sim/ppc/ld-cache.h",
+    "sim/ppc/mon.c",
+    "sim/ppc/corefile.h",
+    "sim/ppc/vm.c",
+    "sim/ppc/INSTALL",
+    "sim/ppc/gen-model.c",
+    "sim/ppc/hw_cpu.c",
+    "sim/ppc/corefile.c",
+    "sim/ppc/hw_opic.c",
+    "sim/ppc/gen-icache.c",
+    "sim/ppc/events.h",
+    "sim/ppc/os_emul.c",
+    "sim/ppc/emul_generic.c",
+    "sim/ppc/main.c",
+    "sim/ppc/hw_com.c",
+    "sim/ppc/gen-semantics.c",
+    "sim/ppc/emul_bugapi.c",
+    "sim/ppc/device.c",
+    "sim/ppc/emul_generic.h",
+    "sim/ppc/tree.c",
+    "sim/ppc/mon.h",
+    "sim/ppc/interrupts.h",
+    "sim/ppc/cap.c",
+    "sim/ppc/cpu.c",
+    "sim/ppc/hw_phb.h",
+    "sim/ppc/device_table.c",
+    "sim/ppc/lf.c",
+    "sim/ppc/lf.c",
+    "sim/ppc/dc-stupid",
+    "sim/ppc/hw_pal.c",
+    "sim/ppc/ppc-spr-table",
+    "sim/ppc/emul_unix.h",
+    "sim/ppc/words.h",
+    "sim/ppc/basics.h",
+    "sim/ppc/hw_htab.c",
+    "sim/ppc/lf.h",
+    "sim/ppc/ld-decode.c",
+    "sim/ppc/sim-endian.c",
+    "sim/ppc/gen-itable.c",
+    "sim/ppc/idecode_expression.h",
+    "sim/ppc/table.h",
+    "sim/ppc/dgen.c",
+    "sim/ppc/events.c",
+    "sim/ppc/gen-idecode.h",
+    "sim/ppc/emul_netbsd.c",
+    "sim/ppc/igen.c",
+    "sim/ppc/vm_n.h",
+    "sim/ppc/vm.h",
+    "sim/ppc/hw_iobus.c",
+    "sim/ppc/inline.h",
     "sim/testsuite/sim/mips/mips32-dsp2.s",
 )
 
 if __name__ == "__main__":
     main()
-
diff --git a/gdb/python/lib/gdb/FrameDecorator.py b/gdb/python/lib/gdb/FrameDecorator.py
index 25d58952f96..1f4b2cab6ec 100644
--- a/gdb/python/lib/gdb/FrameDecorator.py
+++ b/gdb/python/lib/gdb/FrameDecorator.py
@@ -24,6 +24,7 @@ try:
 except NameError:
     basestring = str
 
+
 class FrameDecorator(object):
     """Basic implementation of a Frame Decorator"""
 
@@ -66,9 +67,12 @@ class FrameDecorator(object):
         limited."""
         sal = frame.find_sal()
 
-        if (not sal.symtab or not sal.symtab.filename
+        if (
+            not sal.symtab
+            or not sal.symtab.filename
             or frame.type() == gdb.DUMMY_FRAME
-            or frame.type() == gdb.SIGTRAMP_FRAME):
+            or frame.type() == gdb.SIGTRAMP_FRAME
+        ):
 
             return True
 
@@ -83,7 +87,7 @@ class FrameDecorator(object):
         return None
 
     def function(self):
-        """ Return the name of the frame's function or an address of
+        """Return the name of the frame's function or an address of
         the function of the frame.  First determine if this is a
         special frame.  If not, try to determine filename from GDB's
         frame internal function API.  Finally, if a name cannot be
@@ -120,7 +124,7 @@ class FrameDecorator(object):
         return str(func)
 
     def address(self):
-        """ Return the address of the frame's pc"""
+        """Return the address of the frame's pc"""
 
         if hasattr(self._base, "address"):
             return self._base.address()
@@ -129,7 +133,7 @@ class FrameDecorator(object):
         return frame.pc()
 
     def filename(self):
-        """ Return the filename associated with this frame, detecting
+        """Return the filename associated with this frame, detecting
         and returning the appropriate library name is this is a shared
         library."""
 
@@ -145,7 +149,7 @@ class FrameDecorator(object):
             return sal.symtab.filename
 
     def frame_args(self):
-        """ Return an iterable of frame arguments for this frame, if
+        """Return an iterable of frame arguments for this frame, if
         any.  The iterable object contains objects conforming with the
         Symbol/Value interface.  If there are no frame arguments, or
         if this frame is deemed to be a special case, return None."""
@@ -161,7 +165,7 @@ class FrameDecorator(object):
         return args.fetch_frame_args()
 
     def frame_locals(self):
-        """ Return an iterable of local variables for this frame, if
+        """Return an iterable of local variables for this frame, if
         any.  The iterable object contains objects conforming with the
         Symbol/Value interface.  If there are no frame locals, or if
         this frame is deemed to be a special case, return None."""
@@ -177,7 +181,7 @@ class FrameDecorator(object):
         return args.fetch_frame_locals()
 
     def line(self):
-        """ Return line number information associated with the frame's
+        """Return line number information associated with the frame's
         pc.  If symbol table/line information does not exist, or if
         this frame is deemed to be a special case, return None"""
 
@@ -189,13 +193,13 @@ class FrameDecorator(object):
             return None
 
         sal = frame.find_sal()
-        if (sal):
+        if sal:
             return sal.line
         else:
             return None
 
     def inferior_frame(self):
-        """ Return the gdb.Frame underpinning this frame decorator."""
+        """Return the gdb.Frame underpinning this frame decorator."""
 
         # If 'base' is a frame decorator, we want to call its inferior
         # frame method.  If '_base' is a gdb.Frame, just return that.
@@ -203,22 +207,25 @@ class FrameDecorator(object):
             return self._base.inferior_frame()
         return self._base
 
+
 class SymValueWrapper(object):
     """A container class conforming to the Symbol/Value interface
     which holds frame locals or frame arguments."""
+
     def __init__(self, symbol, value):
         self.sym = symbol
         self.val = value
 
     def value(self):
-        """ Return the value associated with this symbol, or None"""
+        """Return the value associated with this symbol, or None"""
         return self.val
 
     def symbol(self):
-        """ Return the symbol, or Python text, associated with this
+        """Return the symbol, or Python text, associated with this
         symbol, or None"""
         return self.sym
 
+
 class FrameVars(object):
 
     """Utility class to fetch and store frame local variables, or
@@ -232,12 +239,12 @@ class FrameVars(object):
             gdb.SYMBOL_LOC_ARG: True,
             gdb.SYMBOL_LOC_REF_ARG: True,
             gdb.SYMBOL_LOC_LOCAL: True,
-	    gdb.SYMBOL_LOC_REGPARM_ADDR: True,
-	    gdb.SYMBOL_LOC_COMPUTED: True
-            }
+            gdb.SYMBOL_LOC_REGPARM_ADDR: True,
+            gdb.SYMBOL_LOC_COMPUTED: True,
+        }
 
     def fetch_b(self, sym):
-        """ Local utility method to determine if according to Symbol
+        """Local utility method to determine if according to Symbol
         type whether it should be included in the iterator.  Not all
         symbols are fetched, and only symbols that return
         True from this method should be fetched."""
@@ -268,7 +275,7 @@ class FrameVars(object):
                 break
             for sym in block:
                 if sym.is_argument:
-                    continue;
+                    continue
                 if self.fetch_b(sym):
                     lvars.append(SymValueWrapper(sym, None))
 
@@ -296,7 +303,7 @@ class FrameVars(object):
         if block != None:
             for sym in block:
                 if not sym.is_argument:
-                    continue;
+                    continue
                 args.append(SymValueWrapper(sym, None))
 
         return args
diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py
index b9e44be0aff..fccb5886d1a 100644
--- a/gdb/python/lib/gdb/FrameIterator.py
+++ b/gdb/python/lib/gdb/FrameIterator.py
@@ -16,6 +16,7 @@
 import gdb
 import itertools
 
+
 class FrameIterator(object):
     """A gdb.Frame iterator.  Iterates over gdb.Frames or objects that
     conform to that interface."""
diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
index 9a0e9891cc5..d748b3a5827 100644
--- a/gdb/python/lib/gdb/__init__.py
+++ b/gdb/python/lib/gdb/__init__.py
@@ -26,7 +26,8 @@ elif sys.version_info[0] > 2:
 
 from _gdb import *
 
-class _GdbFile (object):
+
+class _GdbFile(object):
     # These two are needed in Python 3
     encoding = "UTF-8"
     errors = "strict"
@@ -45,16 +46,20 @@ class _GdbFile (object):
     def flush(self):
         flush()
 
-class _GdbOutputFile (_GdbFile):
+
+class _GdbOutputFile(_GdbFile):
     def write(self, s):
         write(s, stream=STDOUT)
 
+
 sys.stdout = _GdbOutputFile()
 
-class _GdbOutputErrorFile (_GdbFile):
+
+class _GdbOutputErrorFile(_GdbFile):
     def write(self, s):
         write(s, stream=STDERR)
 
+
 sys.stderr = _GdbOutputErrorFile()
 
 # Default prompt hook does nothing.
@@ -62,7 +67,7 @@ prompt_hook = None
 
 # Ensure that sys.argv is set to something.
 # We do not use PySys_SetArgvEx because it did not appear until 2.6.6.
-sys.argv = ['']
+sys.argv = [""]
 
 # Initial pretty printers.
 pretty_printers = []
@@ -76,6 +81,7 @@ frame_filters = {}
 # Initial frame unwinders.
 frame_unwinders = []
 
+
 def _execute_unwinders(pending_frame):
     """Internal function called from GDB to execute all unwinders.
 
@@ -108,6 +114,7 @@ def _execute_unwinders(pending_frame):
 
     return None
 
+
 def _execute_file(filepath):
     """This function is used to replace Python 2's PyRun_SimpleFile.
 
@@ -117,22 +124,22 @@ def _execute_file(filepath):
     "Furthermore, any functions and classes defined by the executed code are
     not guaranteed to work correctly after a runpy function has returned."
     """
-    globals = sys.modules['__main__'].__dict__
+    globals = sys.modules["__main__"].__dict__
     set_file = False
     # Set file (if not set) so that the imported file can use it (e.g. to
     # access file-relative paths). This matches what PyRun_SimpleFile does.
-    if not hasattr(globals, '__file__'):
-        globals['__file__'] = filepath
+    if not hasattr(globals, "__file__"):
+        globals["__file__"] = filepath
         set_file = True
     try:
-        with open(filepath, 'rb') as file:
+        with open(filepath, "rb") as file:
             # We pass globals also as locals to match what Python does
             # in PyRun_SimpleFile.
-            compiled = compile(file.read(), filepath, 'exec')
+            compiled = compile(file.read(), filepath, "exec")
             exec(compiled, globals, globals)
     finally:
         if set_file:
-            del globals['__file__']
+            del globals["__file__"]
 
 
 # Convenience variable to GDB's python directory
@@ -142,27 +149,24 @@ PYTHONDIR = os.path.dirname(os.path.dirname(__file__))
 
 # Packages to auto-load.
 
-packages = [
-    'function',
-    'command',
-    'printer'
-]
+packages = ["function", "command", "printer"]
 
 # pkgutil.iter_modules is not available prior to Python 2.6.  Instead,
 # manually iterate the list, collating the Python files in each module
 # path.  Construct the module name, and import.
 
+
 def _auto_load_packages():
     for package in packages:
         location = os.path.join(os.path.dirname(__file__), package)
         if os.path.exists(location):
-            py_files = filter(lambda x: x.endswith('.py')
-                                        and x != '__init__.py',
-                              os.listdir(location))
+            py_files = filter(
+                lambda x: x.endswith(".py") and x != "__init__.py", os.listdir(location)
+            )
 
             for py_file in py_files:
                 # Construct from foo.py, gdb.module.foo
-                modname = "%s.%s.%s" % ( __name__, package, py_file[:-3] )
+                modname = "%s.%s.%s" % (__name__, package, py_file[:-3])
                 try:
                     if modname in sys.modules:
                         # reload modules with duplicate names
@@ -170,10 +174,12 @@ def _auto_load_packages():
                     else:
                         __import__(modname)
                 except:
-                    sys.stderr.write (traceback.format_exc() + "\n")
+                    sys.stderr.write(traceback.format_exc() + "\n")
+
 
 _auto_load_packages()
 
+
 def GdbSetPythonDirectory(dir):
     """Update sys.path, reload gdb and auto-load packages."""
     global PYTHONDIR
@@ -191,30 +197,37 @@ def GdbSetPythonDirectory(dir):
     reload(__import__(__name__))
     _auto_load_packages()
 
+
 def current_progspace():
     "Return the current Progspace."
     return selected_inferior().progspace
 
+
 def objfiles():
     "Return a sequence of the current program space's objfiles."
     return current_progspace().objfiles()
 
-def solib_name (addr):
+
+def solib_name(addr):
     """solib_name (Long) -> String.\n\
 Return the name of the shared library holding a given address, or None."""
     return current_progspace().solib_name(addr)
 
+
 def block_for_pc(pc):
     "Return the block containing the given pc value, or None."
     return current_progspace().block_for_pc(pc)
 
+
 def find_pc_line(pc):
     """find_pc_line (pc) -> Symtab_and_line.
-Return the gdb.Symtab_and_line object corresponding to the pc value."""
+    Return the gdb.Symtab_and_line object corresponding to the pc value."""
     return current_progspace().find_pc_line(pc)
 
+
 try:
     from pygments import formatters, lexers, highlight
+
     def colorize(filename, contents):
         # Don't want any errors.
         try:
@@ -223,6 +236,9 @@ try:
             return highlight(contents, lexer, formatter)
         except:
             return None
+
+
 except:
+
     def colorize(filename, contents):
         return None
diff --git a/gdb/python/lib/gdb/command/__init__.py b/gdb/python/lib/gdb/command/__init__.py
index 5ba92a8c2e1..ac45a0da815 100644
--- a/gdb/python/lib/gdb/command/__init__.py
+++ b/gdb/python/lib/gdb/command/__init__.py
@@ -12,5 +12,3 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-
diff --git a/gdb/python/lib/gdb/command/explore.py b/gdb/python/lib/gdb/command/explore.py
index 3a265be5baf..3b76d36cfb4 100644
--- a/gdb/python/lib/gdb/command/explore.py
+++ b/gdb/python/lib/gdb/command/explore.py
@@ -22,12 +22,13 @@ import sys
 if sys.version_info[0] > 2:
     # Python 3 renamed raw_input to input
     raw_input = input
-    
+
+
 class Explorer(object):
     """Internal class which invokes other explorers."""
 
     # This map is filled by the Explorer.init_env() function
-    type_code_to_explorer_map = { }
+    type_code_to_explorer_map = {}
 
     _SCALAR_TYPE_LIST = (
         gdb.TYPE_CODE_CHAR,
@@ -43,14 +44,18 @@ class Explorer(object):
         length = len(expr)
         guard = False
 
-        if expr[0] == '(' and expr[length-1] == ')':
+        if expr[0] == "(" and expr[length - 1] == ")":
             pass
         else:
             i = 0
             while i < length:
                 c = expr[i]
-                if (c == '_' or ('a' <= c and c <= 'z') or
-                    ('A' <= c and c <= 'Z') or ('0' <= c and c <= '9')):
+                if (
+                    c == "_"
+                    or ("a" <= c and c <= "z")
+                    or ("A" <= c and c <= "Z")
+                    or ("0" <= c and c <= "9")
+                ):
                     pass
                 else:
                     guard = True
@@ -85,8 +90,7 @@ class Explorer(object):
             while explorer_class.explore_expr(expr, value, is_child):
                 pass
         else:
-            print ("Explorer for type '%s' not yet available.\n" %
-                   str(value.type))
+            print("Explorer for type '%s' not yet available.\n" % str(value.type))
 
     @staticmethod
     def explore_type(name, datatype, is_child):
@@ -111,8 +115,7 @@ class Explorer(object):
             while explorer_class.explore_type(name, datatype, is_child):
                 pass
         else:
-            print ("Explorer for type '%s' not yet available.\n" %
-                   str(datatype))
+            print("Explorer for type '%s' not yet available.\n" % str(datatype))
 
     @staticmethod
     def init_env():
@@ -122,19 +125,19 @@ class Explorer(object):
         explorations.
         """
         Explorer.type_code_to_explorer_map = {
-            gdb.TYPE_CODE_CHAR : ScalarExplorer,
-            gdb.TYPE_CODE_INT : ScalarExplorer,
-            gdb.TYPE_CODE_BOOL : ScalarExplorer,
-            gdb.TYPE_CODE_FLT : ScalarExplorer,
-            gdb.TYPE_CODE_VOID : ScalarExplorer,
-            gdb.TYPE_CODE_ENUM : ScalarExplorer,
-            gdb.TYPE_CODE_STRUCT : CompoundExplorer,
-            gdb.TYPE_CODE_UNION : CompoundExplorer,
-            gdb.TYPE_CODE_PTR : PointerExplorer,
-            gdb.TYPE_CODE_REF : ReferenceExplorer,
-            gdb.TYPE_CODE_RVALUE_REF : ReferenceExplorer,
-            gdb.TYPE_CODE_TYPEDEF : TypedefExplorer,
-            gdb.TYPE_CODE_ARRAY : ArrayExplorer
+            gdb.TYPE_CODE_CHAR: ScalarExplorer,
+            gdb.TYPE_CODE_INT: ScalarExplorer,
+            gdb.TYPE_CODE_BOOL: ScalarExplorer,
+            gdb.TYPE_CODE_FLT: ScalarExplorer,
+            gdb.TYPE_CODE_VOID: ScalarExplorer,
+            gdb.TYPE_CODE_ENUM: ScalarExplorer,
+            gdb.TYPE_CODE_STRUCT: CompoundExplorer,
+            gdb.TYPE_CODE_UNION: CompoundExplorer,
+            gdb.TYPE_CODE_PTR: PointerExplorer,
+            gdb.TYPE_CODE_REF: ReferenceExplorer,
+            gdb.TYPE_CODE_RVALUE_REF: ReferenceExplorer,
+            gdb.TYPE_CODE_TYPEDEF: TypedefExplorer,
+            gdb.TYPE_CODE_ARRAY: ArrayExplorer,
         }
 
     @staticmethod
@@ -161,8 +164,8 @@ class Explorer(object):
         """A utility function which prints that the current exploration session
         is returning to the parent value. Useful when exploring values.
         """
-        print ("\nReturning to parent value...\n")
-        
+        print("\nReturning to parent value...\n")
+
     @staticmethod
     def return_to_parent_value_prompt():
         """A utility function which prompts the user to press the 'enter' key
@@ -170,14 +173,14 @@ class Explorer(object):
         Useful when exploring values.
         """
         raw_input("\nPress enter to return to parent value: ")
-        
+
     @staticmethod
     def return_to_enclosing_type():
         """A utility function which prints that the current exploration session
         is returning to the enclosing type.  Useful when exploring types.
         """
-        print ("\nReturning to enclosing type...\n")
-        
+        print("\nReturning to enclosing type...\n")
+
     @staticmethod
     def return_to_enclosing_type_prompt():
         """A utility function which prompts the user to press the 'enter' key
@@ -196,9 +199,8 @@ class ScalarExplorer(object):
         See Explorer.explore_expr and Explorer.is_scalar_type for more
         information.
         """
-        print ("'%s' is a scalar value of type '%s'." %
-               (expr, value.type))
-        print ("%s = %s" % (expr, str(value)))
+        print("'%s' is a scalar value of type '%s'." % (expr, value.type))
+        print("%s = %s" % (expr, str(value)))
 
         if is_child:
             Explorer.return_to_parent_value_prompt()
@@ -214,16 +216,14 @@ class ScalarExplorer(object):
         """
         if datatype.code == gdb.TYPE_CODE_ENUM:
             if is_child:
-                print ("%s is of an enumerated type '%s'." %
-                       (name, str(datatype)))
+                print("%s is of an enumerated type '%s'." % (name, str(datatype)))
             else:
-                print ("'%s' is an enumerated type." % name)
+                print("'%s' is an enumerated type." % name)
         else:
             if is_child:
-                print ("%s is of a scalar type '%s'." %
-                       (name, str(datatype)))
+                print("%s is of a scalar type '%s'." % (name, str(datatype)))
             else:
-                print ("'%s' is a scalar type." % name)
+                print("'%s' is a scalar type." % name)
 
         if is_child:
             Explorer.return_to_enclosing_type_prompt()
@@ -240,33 +240,41 @@ class PointerExplorer(object):
         """Function to explore pointer values.
         See Explorer.explore_expr for more information.
         """
-        print ("'%s' is a pointer to a value of type '%s'" %
-               (expr, str(value.type.target())))
-        option  = raw_input("Continue exploring it as a pointer to a single "
-                            "value [y/n]: ")
+        print(
+            "'%s' is a pointer to a value of type '%s'"
+            % (expr, str(value.type.target()))
+        )
+        option = raw_input(
+            "Continue exploring it as a pointer to a single " "value [y/n]: "
+        )
         if option == "y":
             deref_value = None
             try:
                 deref_value = value.dereference()
                 str(deref_value)
             except gdb.MemoryError:
-                print ("'%s' a pointer pointing to an invalid memory "
-                       "location." % expr)
+                print(
+                    "'%s' a pointer pointing to an invalid memory " "location." % expr
+                )
                 if is_child:
                     Explorer.return_to_parent_value_prompt()
                 return False
-            Explorer.explore_expr("*%s" % Explorer.guard_expr(expr),
-                                  deref_value, is_child)
+            Explorer.explore_expr(
+                "*%s" % Explorer.guard_expr(expr), deref_value, is_child
+            )
             return False
-        
-        option  = raw_input("Continue exploring it as a pointer to an "
-                            "array [y/n]: ")
+
+        option = raw_input("Continue exploring it as a pointer to an " "array [y/n]: ")
         if option == "y":
             while True:
                 index = 0
                 try:
-                    index = int(raw_input("Enter the index of the element you "
-                                          "want to explore in '%s': " % expr))
+                    index = int(
+                        raw_input(
+                            "Enter the index of the element you "
+                            "want to explore in '%s': " % expr
+                        )
+                    )
                 except ValueError:
                     break
                 element_expr = "%s[%d]" % (Explorer.guard_expr(expr), index)
@@ -274,7 +282,7 @@ class PointerExplorer(object):
                 try:
                     str(element)
                 except gdb.MemoryError:
-                    print ("Cannot read value at index %d." % index)
+                    print("Cannot read value at index %d." % index)
                     continue
                 Explorer.explore_expr(element_expr, element, True)
             return False
@@ -289,12 +297,9 @@ class PointerExplorer(object):
         See Explorer.explore_type for more information.
         """
         target_type = datatype.target()
-        print ("\n%s is a pointer to a value of type '%s'." %
-               (name, str(target_type)))
+        print("\n%s is a pointer to a value of type '%s'." % (name, str(target_type)))
 
-        Explorer.explore_type("the pointee type of %s" % name,
-                              target_type,
-                              is_child)
+        Explorer.explore_type("the pointee type of %s" % name, target_type, is_child)
         return False
 
 
@@ -319,6 +324,7 @@ class ReferenceExplorer(object):
         Explorer.explore_type(name, target_type, is_child)
         return False
 
+
 class ArrayExplorer(object):
     """Internal class used to explore arrays."""
 
@@ -328,11 +334,15 @@ class ArrayExplorer(object):
         See Explorer.explore_expr for more information.
         """
         target_type = value.type.target()
-        print ("'%s' is an array of '%s'." % (expr, str(target_type)))
+        print("'%s' is an array of '%s'." % (expr, str(target_type)))
         index = 0
         try:
-            index = int(raw_input("Enter the index of the element you want to "
-                                  "explore in '%s': " % expr))
+            index = int(
+                raw_input(
+                    "Enter the index of the element you want to "
+                    "explore in '%s': " % expr
+                )
+            )
         except ValueError:
             if is_child:
                 Explorer.return_to_parent_value()
@@ -343,12 +353,13 @@ class ArrayExplorer(object):
             element = value[index]
             str(element)
         except gdb.MemoryError:
-            print ("Cannot read value at index %d." % index)
+            print("Cannot read value at index %d." % index)
             raw_input("Press enter to continue... ")
             return True
-            
-        Explorer.explore_expr("%s[%d]" % (Explorer.guard_expr(expr), index),
-                              element, True)
+
+        Explorer.explore_expr(
+            "%s[%d]" % (Explorer.guard_expr(expr), index), element, True
+        )
         return True
 
     @staticmethod
@@ -357,10 +368,9 @@ class ArrayExplorer(object):
         See Explorer.explore_type for more information.
         """
         target_type = datatype.target()
-        print ("%s is an array of '%s'." % (name, str(target_type)))
+        print("%s is an array of '%s'." % (name, str(target_type)))
 
-        Explorer.explore_type("the array element of %s" % name, target_type,
-                              is_child)
+        Explorer.explore_type("the array element of %s" % name, target_type, is_child)
         return False
 
 
@@ -369,19 +379,18 @@ class CompoundExplorer(object):
 
     @staticmethod
     def _print_fields(print_list):
-        """Internal function which prints the fields of a struct/class/union.
-        """
+        """Internal function which prints the fields of a struct/class/union."""
         max_field_name_length = 0
         for pair in print_list:
             if max_field_name_length < len(pair[0]):
                 max_field_name_length = len(pair[0])
 
         for pair in print_list:
-            print ("  %*s = %s" % (max_field_name_length, pair[0], pair[1]))
+            print("  %*s = %s" % (max_field_name_length, pair[0], pair[1]))
 
     @staticmethod
     def _get_real_field_count(fields):
-        real_field_count = 0;
+        real_field_count = 0
         for field in fields:
             if not field.artificial:
                 real_field_count = real_field_count + 1
@@ -403,19 +412,23 @@ class CompoundExplorer(object):
             type_desc = "union"
 
         if CompoundExplorer._get_real_field_count(fields) == 0:
-            print ("The value of '%s' is a %s of type '%s' with no fields." %
-                   (expr, type_desc, str(value.type)))
+            print(
+                "The value of '%s' is a %s of type '%s' with no fields."
+                % (expr, type_desc, str(value.type))
+            )
             if is_child:
                 Explorer.return_to_parent_value_prompt()
             return False
 
-        print ("The value of '%s' is a %s of type '%s' with the following "
-              "fields:\n" % (expr, type_desc, str(value.type)))
+        print(
+            "The value of '%s' is a %s of type '%s' with the following "
+            "fields:\n" % (expr, type_desc, str(value.type))
+        )
 
         has_explorable_fields = False
-        choice_to_compound_field_map = { }
+        choice_to_compound_field_map = {}
         current_choice = 0
-        print_list = [ ]
+        print_list = []
         for field in fields:
             if field.artificial:
                 continue
@@ -426,39 +439,48 @@ class CompoundExplorer(object):
                 field_value = value[field.name]
             literal_value = ""
             if type_code == gdb.TYPE_CODE_UNION:
-                literal_value = ("<Enter %d to explore this field of type "
-                                 "'%s'>" % (current_choice, str(field.type)))
+                literal_value = "<Enter %d to explore this field of type " "'%s'>" % (
+                    current_choice,
+                    str(field.type),
+                )
                 has_explorable_fields = True
             else:
                 if Explorer.is_scalar_type(field.type):
-                    literal_value = ("%s .. (Value of type '%s')" %
-                                     (str(field_value), str(field.type)))
+                    literal_value = "%s .. (Value of type '%s')" % (
+                        str(field_value),
+                        str(field.type),
+                    )
                 else:
                     if field.is_base_class:
                         field_desc = "base class"
                     else:
                         field_desc = "field"
-                    literal_value = ("<Enter %d to explore this %s of type "
-                                     "'%s'>" %
-                                     (current_choice, field_desc,
-                                      str(field.type)))
+                    literal_value = "<Enter %d to explore this %s of type " "'%s'>" % (
+                        current_choice,
+                        field_desc,
+                        str(field.type),
+                    )
                     has_explorable_fields = True
 
             choice_to_compound_field_map[str(current_choice)] = (
-                field_full_name, field_value)
+                field_full_name,
+                field_value,
+            )
             current_choice = current_choice + 1
 
             print_list.append((field.name, literal_value))
 
         CompoundExplorer._print_fields(print_list)
-        print ("")
+        print("")
 
         if has_explorable_fields:
             choice = raw_input("Enter the field number of choice: ")
             if choice in choice_to_compound_field_map:
-                Explorer.explore_expr(choice_to_compound_field_map[choice][0],
-                                      choice_to_compound_field_map[choice][1],
-                                      True)
+                Explorer.explore_expr(
+                    choice_to_compound_field_map[choice][0],
+                    choice_to_compound_field_map[choice][1],
+                    True,
+                )
                 return True
             else:
                 if is_child:
@@ -484,26 +506,27 @@ class CompoundExplorer(object):
         fields = datatype.fields()
         if CompoundExplorer._get_real_field_count(fields) == 0:
             if is_child:
-                print ("%s is a %s of type '%s' with no fields." %
-                       (name, type_desc, str(datatype)))
+                print(
+                    "%s is a %s of type '%s' with no fields."
+                    % (name, type_desc, str(datatype))
+                )
                 Explorer.return_to_enclosing_type_prompt()
             else:
-                print ("'%s' is a %s with no fields." % (name, type_desc))
+                print("'%s' is a %s with no fields." % (name, type_desc))
             return False
 
         if is_child:
-            print ("%s is a %s of type '%s' "
-                   "with the following fields:\n" %
-                   (name, type_desc, str(datatype)))
+            print(
+                "%s is a %s of type '%s' "
+                "with the following fields:\n" % (name, type_desc, str(datatype))
+            )
         else:
-            print ("'%s' is a %s with the following "
-                   "fields:\n" %
-                   (name, type_desc))
+            print("'%s' is a %s with the following " "fields:\n" % (name, type_desc))
 
         has_explorable_fields = False
         current_choice = 0
-        choice_to_compound_field_map = { }
-        print_list = [ ]
+        choice_to_compound_field_map = {}
+        print_list = []
         for field in fields:
             if field.artificial:
                 continue
@@ -511,31 +534,40 @@ class CompoundExplorer(object):
                 field_desc = "base class"
             else:
                 field_desc = "field"
-            rhs = ("<Enter %d to explore this %s of type '%s'>" %
-                   (current_choice, field_desc, str(field.type)))
+            rhs = "<Enter %d to explore this %s of type '%s'>" % (
+                current_choice,
+                field_desc,
+                str(field.type),
+            )
             print_list.append((field.name, rhs))
             choice_to_compound_field_map[str(current_choice)] = (
-                field.name, field.type, field_desc)
+                field.name,
+                field.type,
+                field_desc,
+            )
             current_choice = current_choice + 1
 
         CompoundExplorer._print_fields(print_list)
-        print ("")
+        print("")
 
         if len(choice_to_compound_field_map) > 0:
             choice = raw_input("Enter the field number of choice: ")
             if choice in choice_to_compound_field_map:
                 if is_child:
-                    new_name = ("%s '%s' of %s" % 
-                                (choice_to_compound_field_map[choice][2],
-                                 choice_to_compound_field_map[choice][0],
-                                 name))
+                    new_name = "%s '%s' of %s" % (
+                        choice_to_compound_field_map[choice][2],
+                        choice_to_compound_field_map[choice][0],
+                        name,
+                    )
                 else:
-                    new_name = ("%s '%s' of '%s'" % 
-                                (choice_to_compound_field_map[choice][2],
-                                 choice_to_compound_field_map[choice][0],
-                                 name))
-                Explorer.explore_type(new_name,
-                    choice_to_compound_field_map[choice][1], True)
+                    new_name = "%s '%s' of '%s'" % (
+                        choice_to_compound_field_map[choice][2],
+                        choice_to_compound_field_map[choice][0],
+                        name,
+                    )
+                Explorer.explore_type(
+                    new_name, choice_to_compound_field_map[choice][1], True
+                )
                 return True
             else:
                 if is_child:
@@ -545,7 +577,7 @@ class CompoundExplorer(object):
                 Explorer.return_to_enclosing_type_prompt()
 
         return False
-           
+
 
 class TypedefExplorer(object):
     """Internal class used to explore values whose type is a typedef."""
@@ -556,9 +588,11 @@ class TypedefExplorer(object):
         See Explorer.explore_expr for more information.
         """
         actual_type = value.type.strip_typedefs()
-        print ("The value of '%s' is of type '%s' "
-               "which is a typedef of type '%s'" %
-               (expr, str(value.type), str(actual_type)))
+        print(
+            "The value of '%s' is of type '%s' "
+            "which is a typedef of type '%s'"
+            % (expr, str(value.type), str(actual_type))
+        )
 
         Explorer.explore_expr(expr, value.cast(actual_type), is_child)
         return False
@@ -570,11 +604,11 @@ class TypedefExplorer(object):
         """
         actual_type = datatype.strip_typedefs()
         if is_child:
-            print ("The type of %s is a typedef of type '%s'." %
-                   (name, str(actual_type)))
+            print(
+                "The type of %s is a typedef of type '%s'." % (name, str(actual_type))
+            )
         else:
-            print ("The type '%s' is a typedef of type '%s'." %
-                   (name, str(actual_type)))
+            print("The type '%s' is a typedef of type '%s'." % (name, str(actual_type)))
 
         Explorer.explore_type(name, actual_type, is_child)
         return False
@@ -599,8 +633,7 @@ class ExploreUtils(object):
             gdb.GdbError if adequate arguments are not passed.
         """
         if len(arg_str) < 1:
-            raise gdb.GdbError("ERROR: '%s' requires an argument."
-                               % name)
+            raise gdb.GdbError("ERROR: '%s' requires an argument." % name)
             return False
         else:
             return True
@@ -649,16 +682,16 @@ class ExploreUtils(object):
 class ExploreCommand(gdb.Command):
     """Explore a value or a type valid in the current context.
 
-Usage: explore ARG
+    Usage: explore ARG
 
-- ARG is either a valid expression or a type name.
-- At any stage of exploration, hit the return key (instead of a
-choice, if any) to return to the enclosing type or value."""
+    - ARG is either a valid expression or a type name.
+    - At any stage of exploration, hit the return key (instead of a
+    choice, if any) to return to the enclosing type or value."""
 
     def __init__(self):
-        super(ExploreCommand, self).__init__(name = "explore",
-                                             command_class = gdb.COMMAND_DATA,
-                                             prefix = True)
+        super(ExploreCommand, self).__init__(
+            name="explore", command_class=gdb.COMMAND_DATA, prefix=True
+        )
 
     def invoke(self, arg_str, from_tty):
         if ExploreUtils.check_args("explore", arg_str) == False:
@@ -678,23 +711,26 @@ choice, if any) to return to the enclosing type or value."""
 
         # If it is neither a value nor a type, raise an error.
         raise gdb.GdbError(
-            ("'%s' neither evaluates to a value nor is a type "
-             "in the current context." %
-             arg_str))
+            (
+                "'%s' neither evaluates to a value nor is a type "
+                "in the current context." % arg_str
+            )
+        )
 
 
 class ExploreValueCommand(gdb.Command):
     """Explore value of an expression valid in the current context.
 
-Usage: explore value ARG
+    Usage: explore value ARG
+
+    - ARG is a valid expression.
+    - At any stage of exploration, hit the return key (instead of a
+    choice, if any) to return to the enclosing value."""
 
-- ARG is a valid expression.
-- At any stage of exploration, hit the return key (instead of a
-choice, if any) to return to the enclosing value."""
- 
     def __init__(self):
         super(ExploreValueCommand, self).__init__(
-            name = "explore value", command_class = gdb.COMMAND_DATA)
+            name="explore value", command_class=gdb.COMMAND_DATA
+        )
 
     def invoke(self, arg_str, from_tty):
         if ExploreUtils.check_args("explore value", arg_str) == False:
@@ -703,26 +739,29 @@ choice, if any) to return to the enclosing value."""
         value = ExploreUtils.get_value_from_str(arg_str)
         if value is None:
             raise gdb.GdbError(
-                (" '%s' does not evaluate to a value in the current "
-                 "context." %
-                 arg_str))
+                (
+                    " '%s' does not evaluate to a value in the current "
+                    "context." % arg_str
+                )
+            )
             return
 
         Explorer.explore_expr(arg_str, value, False)
 
 
-class ExploreTypeCommand(gdb.Command):            
+class ExploreTypeCommand(gdb.Command):
     """Explore a type or the type of an expression.
 
-Usage: explore type ARG
+    Usage: explore type ARG
 
-- ARG is a valid expression or a type name.
-- At any stage of exploration, hit the return key (instead of a
-choice, if any) to return to the enclosing type."""
+    - ARG is a valid expression or a type name.
+    - At any stage of exploration, hit the return key (instead of a
+    choice, if any) to return to the enclosing type."""
 
     def __init__(self):
         super(ExploreTypeCommand, self).__init__(
-            name = "explore type", command_class = gdb.COMMAND_DATA)
+            name="explore type", command_class=gdb.COMMAND_DATA
+        )
 
     def invoke(self, arg_str, from_tty):
         if ExploreUtils.check_args("explore type", arg_str) == False:
@@ -735,12 +774,13 @@ choice, if any) to return to the enclosing type."""
 
         value = ExploreUtils.get_value_from_str(arg_str)
         if value is not None:
-            print ("'%s' is of type '%s'." % (arg_str, str(value.type)))
+            print("'%s' is of type '%s'." % (arg_str, str(value.type)))
             Explorer.explore_type(str(value.type), value.type, False)
             return
 
-        raise gdb.GdbError(("'%s' is not a type or value in the current "
-                            "context." % arg_str))
+        raise gdb.GdbError(
+            ("'%s' is not a type or value in the current " "context." % arg_str)
+        )
 
 
 Explorer.init_env()
diff --git a/gdb/python/lib/gdb/command/frame_filters.py b/gdb/python/lib/gdb/command/frame_filters.py
index 09e1f9aa5ad..91e8ca2d43c 100644
--- a/gdb/python/lib/gdb/command/frame_filters.py
+++ b/gdb/python/lib/gdb/command/frame_filters.py
@@ -29,24 +29,28 @@ class SetFilterPrefixCmd(gdb.Command):
     """Prefix command for 'set' frame-filter related operations."""
 
     def __init__(self):
-        super(SetFilterPrefixCmd, self).__init__("set frame-filter",
-                                                 gdb.COMMAND_OBSCURE,
-                                                 gdb.COMPLETE_NONE, True)
+        super(SetFilterPrefixCmd, self).__init__(
+            "set frame-filter", gdb.COMMAND_OBSCURE, gdb.COMPLETE_NONE, True
+        )
+
 
 class ShowFilterPrefixCmd(gdb.Command):
     """Prefix command for 'show' frame-filter related operations."""
+
     def __init__(self):
-        super(ShowFilterPrefixCmd, self).__init__("show frame-filter",
-                                                  gdb.COMMAND_OBSCURE,
-                                                  gdb.COMPLETE_NONE, True)
+        super(ShowFilterPrefixCmd, self).__init__(
+            "show frame-filter", gdb.COMMAND_OBSCURE, gdb.COMPLETE_NONE, True
+        )
+
+
 class InfoFrameFilter(gdb.Command):
     """List all registered Python frame-filters.
 
-Usage: info frame-filters"""
+    Usage: info frame-filters"""
 
     def __init__(self):
-        super(InfoFrameFilter, self).__init__("info frame-filter",
-                                              gdb.COMMAND_DATA)
+        super(InfoFrameFilter, self).__init__("info frame-filter", gdb.COMMAND_DATA)
+
     @staticmethod
     def enabled_string(state):
         """Return "Yes" if filter is enabled, otherwise "No"."""
@@ -56,9 +60,11 @@ Usage: info frame-filters"""
             return "No"
 
     def print_list(self, title, frame_filters, blank_line):
-        sorted_frame_filters = sorted(frame_filters.items(),
-                                      key=lambda i: gdb.frames.get_priority(i[1]),
-                                      reverse=True)
+        sorted_frame_filters = sorted(
+            frame_filters.items(),
+            key=lambda i: gdb.frames.get_priority(i[1]),
+            reverse=True,
+        )
 
         if len(sorted_frame_filters) == 0:
             return 0
@@ -68,14 +74,14 @@ Usage: info frame-filters"""
         for frame_filter in sorted_frame_filters:
             name = frame_filter[0]
             try:
-                priority = '{:<8}'.format(
-                    str(gdb.frames.get_priority(frame_filter[1])))
-                enabled = '{:<7}'.format(
-                    self.enabled_string(gdb.frames.get_enabled(frame_filter[1])))
+                priority = "{:<8}".format(str(gdb.frames.get_priority(frame_filter[1])))
+                enabled = "{:<7}".format(
+                    self.enabled_string(gdb.frames.get_enabled(frame_filter[1]))
+                )
                 print("  %s  %s  %s" % (priority, enabled, name))
             except Exception:
                 e = sys.exc_info()[1]
-                print("  Error printing filter '"+name+"': "+str(e))
+                print("  Error printing filter '" + name + "': " + str(e))
         if blank_line:
             print("")
         return 1
@@ -84,20 +90,26 @@ Usage: info frame-filters"""
         any_printed = self.print_list("global frame-filters:", gdb.frame_filters, True)
 
         cp = gdb.current_progspace()
-        any_printed += self.print_list("progspace %s frame-filters:" % cp.filename,
-                                       cp.frame_filters, True)
+        any_printed += self.print_list(
+            "progspace %s frame-filters:" % cp.filename, cp.frame_filters, True
+        )
 
         for objfile in gdb.objfiles():
-            any_printed += self.print_list("objfile %s frame-filters:" % objfile.filename,
-                                           objfile.frame_filters, False)
+            any_printed += self.print_list(
+                "objfile %s frame-filters:" % objfile.filename,
+                objfile.frame_filters,
+                False,
+            )
 
         if any_printed == 0:
-            print ("No frame filters.")
+            print("No frame filters.")
+
 
 # Internal enable/disable functions.
 
+
 def _enable_parse_arg(cmd_name, arg):
-    """ Internal worker function to take an argument from
+    """Internal worker function to take an argument from
     enable/disable and return a tuple of arguments.
 
     Arguments:
@@ -109,19 +121,21 @@ def _enable_parse_arg(cmd_name, arg):
         the dictionary in the case of "all".
     """
 
-    argv = gdb.string_to_argv(arg);
+    argv = gdb.string_to_argv(arg)
     argc = len(argv)
     if argc == 0:
         raise gdb.GdbError(cmd_name + " requires an argument")
     if argv[0] == "all":
         if argc > 1:
-            raise gdb.GdbError(cmd_name + ": with 'all' " \
-                               "you may not specify a filter.")
+            raise gdb.GdbError(
+                cmd_name + ": with 'all' " "you may not specify a filter."
+            )
     elif argc != 2:
-            raise gdb.GdbError(cmd_name + " takes exactly two arguments.")
+        raise gdb.GdbError(cmd_name + " takes exactly two arguments.")
 
     return argv
 
+
 def _do_enable_frame_filter(command_tuple, flag):
     """Worker for enabling/disabling frame_filters.
 
@@ -148,6 +162,7 @@ def _do_enable_frame_filter(command_tuple, flag):
 
         gdb.frames.set_enabled(ff, flag)
 
+
 def _complete_frame_filter_list(text, word, all_flag):
     """Worker for frame filter dictionary name completion.
 
@@ -160,7 +175,7 @@ def _complete_frame_filter_list(text, word, all_flag):
         A list of suggested frame filter dictionary name completions
         from text/word analysis.  This list can be empty when there
         are no suggestions for completion.
-        """
+    """
     if all_flag == True:
         filter_locations = ["all", "global", "progspace"]
     else:
@@ -171,20 +186,21 @@ def _complete_frame_filter_list(text, word, all_flag):
     # If the user just asked for completions with no completion
     # hints, just return all the frame filter dictionaries we know
     # about.
-    if (text == ""):
+    if text == "":
         return filter_locations
 
     # Otherwise filter on what we know.
-    flist = filter(lambda x,y=text:x.startswith(y), filter_locations)
+    flist = filter(lambda x, y=text: x.startswith(y), filter_locations)
 
     # If we only have one completion, complete it and return it.
     if len(flist) == 1:
-        flist[0] = flist[0][len(text)-len(word):]
+        flist[0] = flist[0][len(text) - len(word) :]
 
     # Otherwise, return an empty list, or a list of frame filter
     # dictionaries that the previous filter operation returned.
     return flist
 
+
 def _complete_frame_filter_name(word, printer_dict):
     """Worker for frame filter name completion.
 
@@ -201,29 +217,31 @@ def _complete_frame_filter_name(word, printer_dict):
     """
 
     printer_keys = printer_dict.keys()
-    if (word == ""):
+    if word == "":
         return printer_keys
 
-    flist = filter(lambda x,y=word:x.startswith(y), printer_keys)
+    flist = filter(lambda x, y=word: x.startswith(y), printer_keys)
     return flist
 
+
 class EnableFrameFilter(gdb.Command):
     """GDB command to enable the specified frame-filter.
 
-Usage: enable frame-filter DICTIONARY [NAME]
+    Usage: enable frame-filter DICTIONARY [NAME]
 
-DICTIONARY is the name of the frame filter dictionary on which to
-operate.  If dictionary is set to "all", perform operations on all
-dictionaries.  Named dictionaries are: "global" for the global
-frame filter dictionary, "progspace" for the program space's frame
-filter dictionary.  If either all, or the two named dictionaries
-are not specified, the dictionary name is assumed to be the name
-of an "objfile" -- a shared library or an executable.
+    DICTIONARY is the name of the frame filter dictionary on which to
+    operate.  If dictionary is set to "all", perform operations on all
+    dictionaries.  Named dictionaries are: "global" for the global
+    frame filter dictionary, "progspace" for the program space's frame
+    filter dictionary.  If either all, or the two named dictionaries
+    are not specified, the dictionary name is assumed to be the name
+    of an "objfile" -- a shared library or an executable.
+
+    NAME matches the name of the frame-filter to operate on."""
 
-NAME matches the name of the frame-filter to operate on."""
     def __init__(self):
-        super(EnableFrameFilter, self).__init__("enable frame-filter",
-                                                 gdb.COMMAND_DATA)
+        super(EnableFrameFilter, self).__init__("enable frame-filter", gdb.COMMAND_DATA)
+
     def complete(self, text, word):
         """Completion function for both frame filter dictionary, and
         frame filter name."""
@@ -241,20 +259,22 @@ NAME matches the name of the frame-filter to operate on."""
 class DisableFrameFilter(gdb.Command):
     """GDB command to disable the specified frame-filter.
 
-Usage: disable frame-filter DICTIONARY [NAME]
+    Usage: disable frame-filter DICTIONARY [NAME]
 
-DICTIONARY is the name of the frame filter dictionary on which to
-operate.  If dictionary is set to "all", perform operations on all
-dictionaries.  Named dictionaries are: "global" for the global
-frame filter dictionary, "progspace" for the program space's frame
-filter dictionary.  If either all, or the two named dictionaries
-are not specified, the dictionary name is assumed to be the name
-of an "objfile" -- a shared library or an executable.
+    DICTIONARY is the name of the frame filter dictionary on which to
+    operate.  If dictionary is set to "all", perform operations on all
+    dictionaries.  Named dictionaries are: "global" for the global
+    frame filter dictionary, "progspace" for the program space's frame
+    filter dictionary.  If either all, or the two named dictionaries
+    are not specified, the dictionary name is assumed to be the name
+    of an "objfile" -- a shared library or an executable.
+
+    NAME matches the name of the frame-filter to operate on."""
 
-NAME matches the name of the frame-filter to operate on."""
     def __init__(self):
-        super(DisableFrameFilter, self).__init__("disable frame-filter",
-                                                  gdb.COMMAND_DATA)
+        super(DisableFrameFilter, self).__init__(
+            "disable frame-filter", gdb.COMMAND_DATA
+        )
 
     def complete(self, text, word):
         """Completion function for both frame filter dictionary, and
@@ -269,27 +289,28 @@ NAME matches the name of the frame-filter to operate on."""
         command_tuple = _enable_parse_arg("disable frame-filter", arg)
         _do_enable_frame_filter(command_tuple, False)
 
+
 class SetFrameFilterPriority(gdb.Command):
     """GDB command to set the priority of the specified frame-filter.
 
-Usage: set frame-filter priority DICTIONARY NAME PRIORITY
+    Usage: set frame-filter priority DICTIONARY NAME PRIORITY
 
-DICTIONARY is the name of the frame filter dictionary on which to
-operate.  Named dictionaries are: "global" for the global frame
-filter dictionary, "progspace" for the program space's framefilter
-dictionary.  If either of these two are not specified, the
-dictionary name is assumed to be the name of an "objfile" -- a
-shared library or an executable.
+    DICTIONARY is the name of the frame filter dictionary on which to
+    operate.  Named dictionaries are: "global" for the global frame
+    filter dictionary, "progspace" for the program space's framefilter
+    dictionary.  If either of these two are not specified, the
+    dictionary name is assumed to be the name of an "objfile" -- a
+    shared library or an executable.
 
-NAME matches the name of the frame filter to operate on.
+    NAME matches the name of the frame filter to operate on.
 
-PRIORITY is the an integer to assign the new priority to the frame
-filter."""
+    PRIORITY is the an integer to assign the new priority to the frame
+    filter."""
 
     def __init__(self):
-        super(SetFrameFilterPriority, self).__init__("set frame-filter " \
-                                                     "priority",
-                                                     gdb.COMMAND_DATA)
+        super(SetFrameFilterPriority, self).__init__(
+            "set frame-filter " "priority", gdb.COMMAND_DATA
+        )
 
     def _parse_pri_arg(self, arg):
         """Internal worker to parse a priority from a tuple.
@@ -305,11 +326,10 @@ filter."""
             gdb.GdbError: An error parsing the arguments.
         """
 
-        argv = gdb.string_to_argv(arg);
+        argv = gdb.string_to_argv(arg)
         argc = len(argv)
         if argc != 3:
-            print("set frame-filter priority " \
-                  "takes exactly three arguments.")
+            print("set frame-filter priority " "takes exactly three arguments.")
             return None
 
         return argv
@@ -355,24 +375,25 @@ filter."""
         if command_tuple != None:
             self._set_filter_priority(command_tuple)
 
+
 class ShowFrameFilterPriority(gdb.Command):
     """GDB command to show the priority of the specified frame-filter.
 
-Usage: show frame-filter priority DICTIONARY NAME
+    Usage: show frame-filter priority DICTIONARY NAME
 
-DICTIONARY is the name of the frame filter dictionary on which to
-operate.  Named dictionaries are: "global" for the global frame
-filter dictionary, "progspace" for the program space's framefilter
-dictionary.  If either of these two are not specified, the
-dictionary name is assumed to be the name of an "objfile" -- a
-shared library or an executable.
+    DICTIONARY is the name of the frame filter dictionary on which to
+    operate.  Named dictionaries are: "global" for the global frame
+    filter dictionary, "progspace" for the program space's framefilter
+    dictionary.  If either of these two are not specified, the
+    dictionary name is assumed to be the name of an "objfile" -- a
+    shared library or an executable.
 
-NAME matches the name of the frame-filter to operate on."""
+    NAME matches the name of the frame-filter to operate on."""
 
     def __init__(self):
-        super(ShowFrameFilterPriority, self).__init__("show frame-filter " \
-                                                      "priority",
-                                                      gdb.COMMAND_DATA)
+        super(ShowFrameFilterPriority, self).__init__(
+            "show frame-filter " "priority", gdb.COMMAND_DATA
+        )
 
     def _parse_pri_arg(self, arg):
         """Internal worker to parse a dictionary and name from a
@@ -388,11 +409,10 @@ NAME matches the name of the frame-filter to operate on."""
             gdb.GdbError: An error parsing the arguments.
         """
 
-        argv = gdb.string_to_argv(arg);
+        argv = gdb.string_to_argv(arg)
         argc = len(argv)
         if argc != 2:
-            print("show frame-filter priority " \
-                  "takes exactly two arguments.")
+            print("show frame-filter priority " "takes exactly two arguments.")
             return None
 
         return argv
@@ -438,13 +458,20 @@ NAME matches the name of the frame-filter to operate on."""
         filter_name = command_tuple[1]
         list_name = command_tuple[0]
         try:
-            priority = self.get_filter_priority(list_name, filter_name);
+            priority = self.get_filter_priority(list_name, filter_name)
         except Exception:
             e = sys.exc_info()[1]
-            print("Error printing filter priority for '"+name+"':"+str(e))
+            print("Error printing filter priority for '" + name + "':" + str(e))
         else:
-            print("Priority of filter '" + filter_name + "' in list '" \
-                + list_name + "' is: " + str(priority))
+            print(
+                "Priority of filter '"
+                + filter_name
+                + "' in list '"
+                + list_name
+                + "' is: "
+                + str(priority)
+            )
+
 
 # Register commands
 SetFilterPrefixCmd()
diff --git a/gdb/python/lib/gdb/command/pretty_printers.py b/gdb/python/lib/gdb/command/pretty_printers.py
index 57953236c93..9d579bcf0bd 100644
--- a/gdb/python/lib/gdb/command/pretty_printers.py
+++ b/gdb/python/lib/gdb/command/pretty_printers.py
@@ -38,7 +38,7 @@ def parse_printer_regexps(arg):
         SyntaxError: an error processing ARG
     """
 
-    argv = gdb.string_to_argv(arg);
+    argv = gdb.string_to_argv(arg)
     argc = len(argv)
     object_regexp = ""  # match everything
     name_regexp = ""  # match everything
@@ -60,7 +60,7 @@ def parse_printer_regexps(arg):
     except SyntaxError:
         raise SyntaxError("invalid object regexp: %s" % object_regexp)
     try:
-        name_re = re.compile (name_regexp)
+        name_re = re.compile(name_regexp)
     except SyntaxError:
         raise SyntaxError("invalid name regexp: %s" % name_regexp)
     if subname_regexp is not None:
@@ -70,7 +70,7 @@ def parse_printer_regexps(arg):
             raise SyntaxError("invalid subname regexp: %s" % subname_regexp)
     else:
         subname_re = None
-    return(object_re, name_re, subname_re)
+    return (object_re, name_re, subname_re)
 
 
 def printer_enabled_p(printer):
@@ -84,19 +84,18 @@ def printer_enabled_p(printer):
 class InfoPrettyPrinter(gdb.Command):
     """GDB command to list all registered pretty-printers.
 
-Usage: info pretty-printer [OBJECT-REGEXP [NAME-REGEXP]]
+    Usage: info pretty-printer [OBJECT-REGEXP [NAME-REGEXP]]
 
-OBJECT-REGEXP is a regular expression matching the objects to list.
-Objects are "global", the program space's file, and the objfiles within
-that program space.
+    OBJECT-REGEXP is a regular expression matching the objects to list.
+    Objects are "global", the program space's file, and the objfiles within
+    that program space.
 
-NAME-REGEXP matches the name of the pretty-printer.
-Individual printers in a collection are named as
-printer-name;subprinter-name."""
+    NAME-REGEXP matches the name of the pretty-printer.
+    Individual printers in a collection are named as
+    printer-name;subprinter-name."""
 
-    def __init__ (self):
-        super(InfoPrettyPrinter, self).__init__("info pretty-printer",
-                                                 gdb.COMMAND_DATA)
+    def __init__(self):
+        super(InfoPrettyPrinter, self).__init__("info pretty-printer", gdb.COMMAND_DATA)
 
     @staticmethod
     def enabled_string(printer):
@@ -123,44 +122,62 @@ printer-name;subprinter-name."""
         """Print a list of pretty-printers."""
         # A potential enhancement is to provide an option to list printers in
         # "lookup order" (i.e. unsorted).
-        sorted_pretty_printers = sorted (copy.copy(pretty_printers),
-                                         key = self.printer_name)
+        sorted_pretty_printers = sorted(
+            copy.copy(pretty_printers), key=self.printer_name
+        )
         for printer in sorted_pretty_printers:
             name = self.printer_name(printer)
             enabled = self.enabled_string(printer)
             if name_re.match(name):
-                print ("  %s%s" % (name, enabled))
-                if (hasattr(printer, "subprinters") and
-                    printer.subprinters is not None):
-                    sorted_subprinters = sorted (copy.copy(printer.subprinters),
-                                                 key = self.printer_name)
+                print("  %s%s" % (name, enabled))
+                if hasattr(printer, "subprinters") and printer.subprinters is not None:
+                    sorted_subprinters = sorted(
+                        copy.copy(printer.subprinters), key=self.printer_name
+                    )
                     for subprinter in sorted_subprinters:
-                        if (not subname_re or
-                            subname_re.match(subprinter.name)):
-                            print ("    %s%s" %
-                                   (subprinter.name,
-                                    self.enabled_string(subprinter)))
-
-    def invoke1(self, title, printer_list,
-                obj_name_to_match, object_re, name_re, subname_re):
+                        if not subname_re or subname_re.match(subprinter.name):
+                            print(
+                                "    %s%s"
+                                % (subprinter.name, self.enabled_string(subprinter))
+                            )
+
+    def invoke1(
+        self, title, printer_list, obj_name_to_match, object_re, name_re, subname_re
+    ):
         """Subroutine of invoke to simplify it."""
         if printer_list and object_re.match(obj_name_to_match):
-            print (title)
+            print(title)
             self.list_pretty_printers(printer_list, name_re, subname_re)
 
     def invoke(self, arg, from_tty):
         """GDB calls this to perform the command."""
         (object_re, name_re, subname_re) = parse_printer_regexps(arg)
-        self.invoke1("global pretty-printers:", gdb.pretty_printers,
-                     "global", object_re, name_re, subname_re)
+        self.invoke1(
+            "global pretty-printers:",
+            gdb.pretty_printers,
+            "global",
+            object_re,
+            name_re,
+            subname_re,
+        )
         cp = gdb.current_progspace()
-        self.invoke1("progspace %s pretty-printers:" % cp.filename,
-                     cp.pretty_printers, "progspace",
-                     object_re, name_re, subname_re)
+        self.invoke1(
+            "progspace %s pretty-printers:" % cp.filename,
+            cp.pretty_printers,
+            "progspace",
+            object_re,
+            name_re,
+            subname_re,
+        )
         for objfile in gdb.objfiles():
-            self.invoke1("objfile %s pretty-printers:" % objfile.filename,
-                         objfile.pretty_printers, objfile.filename,
-                         object_re, name_re, subname_re)
+            self.invoke1(
+                "objfile %s pretty-printers:" % objfile.filename,
+                objfile.pretty_printers,
+                objfile.filename,
+                object_re,
+                name_re,
+                subname_re,
+            )
 
 
 def count_enabled_printers(pretty_printers):
@@ -168,8 +185,7 @@ def count_enabled_printers(pretty_printers):
     enabled = 0
     total = 0
     for printer in pretty_printers:
-        if (hasattr(printer, "subprinters")
-            and printer.subprinters is not None):
+        if hasattr(printer, "subprinters") and printer.subprinters is not None:
             if printer_enabled_p(printer):
                 for subprinter in printer.subprinters:
                     if printer_enabled_p(subprinter):
@@ -191,7 +207,9 @@ def count_all_enabled_printers():
     (t_enabled, t_total) = count_enabled_printers(gdb.pretty_printers)
     enabled_count += t_enabled
     total_count += t_total
-    (t_enabled, t_total) = count_enabled_printers(gdb.current_progspace().pretty_printers)
+    (t_enabled, t_total) = count_enabled_printers(
+        gdb.current_progspace().pretty_printers
+    )
     enabled_count += t_enabled
     total_count += t_total
     for objfile in gdb.objfiles():
@@ -214,10 +232,10 @@ def show_pretty_printer_enabled_summary():
     We count subprinters individually.
     """
     (enabled_count, total_count) = count_all_enabled_printers()
-    print ("%d of %d printers enabled" % (enabled_count, total_count))
+    print("%d of %d printers enabled" % (enabled_count, total_count))
 
 
-def do_enable_pretty_printer_1 (pretty_printers, name_re, subname_re, flag):
+def do_enable_pretty_printer_1(pretty_printers, name_re, subname_re, flag):
     """Worker for enabling/disabling pretty-printers.
 
     Arguments:
@@ -233,10 +251,13 @@ def do_enable_pretty_printer_1 (pretty_printers, name_re, subname_re, flag):
     """
     total = 0
     for printer in pretty_printers:
-        if (hasattr(printer, "name") and name_re.match(printer.name) or
-            hasattr(printer, "__name__") and name_re.match(printer.__name__)):
-            if (hasattr(printer, "subprinters") and
-                printer.subprinters is not None):
+        if (
+            hasattr(printer, "name")
+            and name_re.match(printer.name)
+            or hasattr(printer, "__name__")
+            and name_re.match(printer.__name__)
+        ):
+            if hasattr(printer, "subprinters") and printer.subprinters is not None:
                 if not subname_re:
                     # Only record printers that change state.
                     if printer_enabled_p(printer) != flag:
@@ -252,10 +273,12 @@ def do_enable_pretty_printer_1 (pretty_printers, name_re, subname_re, flag):
                     for subprinter in printer.subprinters:
                         if subname_re.match(subprinter.name):
                             # Only record printers that change state.
-                           if (printer_enabled_p(printer) and
-                               printer_enabled_p(subprinter) != flag):
-                               total += 1
-                           subprinter.enabled = flag
+                            if (
+                                printer_enabled_p(printer)
+                                and printer_enabled_p(subprinter) != flag
+                            ):
+                                total += 1
+                            subprinter.enabled = flag
             else:
                 # This printer has no subprinters.
                 # If the user does "disable pretty-printer .* .* foo"
@@ -275,28 +298,31 @@ def do_enable_pretty_printer_1 (pretty_printers, name_re, subname_re, flag):
     return total
 
 
-def do_enable_pretty_printer (arg, flag):
+def do_enable_pretty_printer(arg, flag):
     """Internal worker for enabling/disabling pretty-printers."""
     (object_re, name_re, subname_re) = parse_printer_regexps(arg)
 
     total = 0
     if object_re.match("global"):
-        total += do_enable_pretty_printer_1(gdb.pretty_printers,
-                                            name_re, subname_re, flag)
+        total += do_enable_pretty_printer_1(
+            gdb.pretty_printers, name_re, subname_re, flag
+        )
     cp = gdb.current_progspace()
     if object_re.match("progspace"):
-        total += do_enable_pretty_printer_1(cp.pretty_printers,
-                                            name_re, subname_re, flag)
+        total += do_enable_pretty_printer_1(
+            cp.pretty_printers, name_re, subname_re, flag
+        )
     for objfile in gdb.objfiles():
         if object_re.match(objfile.filename):
-            total += do_enable_pretty_printer_1(objfile.pretty_printers,
-                                                name_re, subname_re, flag)
+            total += do_enable_pretty_printer_1(
+                objfile.pretty_printers, name_re, subname_re, flag
+            )
 
     if flag:
         state = "enabled"
     else:
         state = "disabled"
-    print ("%d %s %s" % (total, pluralize("printer", total), state))
+    print("%d %s %s" % (total, pluralize("printer", total), state))
 
     # Print the total list of printers currently enabled/disabled.
     # This is to further assist the user in determining whether the result
@@ -312,44 +338,47 @@ def do_enable_pretty_printer (arg, flag):
 #
 # A useful addition would be -v (verbose) to show each printer affected.
 
-class EnablePrettyPrinter (gdb.Command):
+
+class EnablePrettyPrinter(gdb.Command):
     """GDB command to enable the specified pretty-printer.
 
-Usage: enable pretty-printer [OBJECT-REGEXP [NAME-REGEXP]]
+    Usage: enable pretty-printer [OBJECT-REGEXP [NAME-REGEXP]]
 
-OBJECT-REGEXP is a regular expression matching the objects to examine.
-Objects are "global", the program space's file, and the objfiles within
-that program space.
+    OBJECT-REGEXP is a regular expression matching the objects to examine.
+    Objects are "global", the program space's file, and the objfiles within
+    that program space.
 
-NAME-REGEXP matches the name of the pretty-printer.
-Individual printers in a collection are named as
-printer-name;subprinter-name."""
+    NAME-REGEXP matches the name of the pretty-printer.
+    Individual printers in a collection are named as
+    printer-name;subprinter-name."""
 
     def __init__(self):
-        super(EnablePrettyPrinter, self).__init__("enable pretty-printer",
-                                                   gdb.COMMAND_DATA)
+        super(EnablePrettyPrinter, self).__init__(
+            "enable pretty-printer", gdb.COMMAND_DATA
+        )
 
     def invoke(self, arg, from_tty):
         """GDB calls this to perform the command."""
         do_enable_pretty_printer(arg, True)
 
 
-class DisablePrettyPrinter (gdb.Command):
+class DisablePrettyPrinter(gdb.Command):
     """GDB command to disable the specified pretty-printer.
 
-Usage: disable pretty-printer [OBJECT-REGEXP [NAME-REGEXP]]
+    Usage: disable pretty-printer [OBJECT-REGEXP [NAME-REGEXP]]
 
-OBJECT-REGEXP is a regular expression matching the objects to examine.
-Objects are "global", the program space's file, and the objfiles within
-that program space.
+    OBJECT-REGEXP is a regular expression matching the objects to examine.
+    Objects are "global", the program space's file, and the objfiles within
+    that program space.
 
-NAME-REGEXP matches the name of the pretty-printer.
-Individual printers in a collection are named as
-printer-name;subprinter-name."""
+    NAME-REGEXP matches the name of the pretty-printer.
+    Individual printers in a collection are named as
+    printer-name;subprinter-name."""
 
     def __init__(self):
-        super(DisablePrettyPrinter, self).__init__("disable pretty-printer",
-                                           [...]

[diff truncated at 100000 bytes]


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-07 14:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 14:57 [binutils-gdb] gdb: re-format Python files using black 21.4b0 Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).