PR libstdc++/86112 fix printers for Python 2.6

Message ID 20180625210344.GA15790@redhat.com
State New
Headers show
Series
  • PR libstdc++/86112 fix printers for Python 2.6
Related show

Commit Message

Jonathan Wakely June 25, 2018, 9:03 p.m.
Dict comprehensions are only supported since Python 2.7, so use an
alternative syntax that is backwards compatible.

	PR libstdc++/86112
	* python/libstdcxx/v6/printers.py (add_one_template_type_printer):
	Replace dict comprehension.

Tested x86_64-linux, committed to trunk.
commit dfea2551319c1a473f5d9016ff90be1a157d59e9
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Jun 25 21:59:28 2018 +0100

    PR libstdc++/86112 fix printers for Python 2.6
    
    Dict comprehensions are only supported since Python 2.7, so use an
    alternative syntax that is backwards compatible.
    
            PR libstdc++/86112
            * python/libstdcxx/v6/printers.py (add_one_template_type_printer):
            Replace dict comprehension.

Comments

Jonathan Wakely June 25, 2018, 9:06 p.m. | #1
On 25/06/18 22:03 +0100, Jonathan Wakely wrote:
>Dict comprehensions are only supported since Python 2.7, so use an

>alternative syntax that is backwards compatible.

>

>	PR libstdc++/86112

>	* python/libstdcxx/v6/printers.py (add_one_template_type_printer):

>	Replace dict comprehension.

>

>Tested x86_64-linux, committed to trunk.


Oh, and gcc-8-branch.

Patch

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 45aaa1211ec..34d8b4e6606 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -1438,7 +1438,8 @@  def add_one_template_type_printer(obj, name, defargs):
     if _versioned_namespace:
         # Add second type printer for same type in versioned namespace:
         ns = 'std::' + _versioned_namespace
-        defargs = { n: d.replace('std::', ns) for n,d in defargs.items() }
+        # PR 86112 Cannot use dict comprehension here:
+        defargs = dict((n, d.replace('std::', ns)) for (n,d) in defargs.items())
         printer = TemplateTypePrinter(ns+name, defargs)
         gdb.types.register_type_printer(obj, printer)