re PR libstdc++/48362 (pretty printer fails for zero-size std::tuple<>)
authorJonathan Wakely <jwakely.gcc@gmail.com>
Thu, 22 Dec 2011 12:33:15 +0000 (12:33 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 22 Dec 2011 12:33:15 +0000 (12:33 +0000)
PR libstdc++/48362
* python/libstdcxx/v6/printers.py (StdTuplePrinter): Handle empty
tuples.

From-SVN: r182620

libstdc++-v3/ChangeLog
libstdc++-v3/python/libstdcxx/v6/printers.py

index 8775d0ab156b478c366710ad42871a3893f85549..687a1d438301f27b0d90d826b19e786cb10c7e3b 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-22  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       PR libstdc++/48362
+       * python/libstdcxx/v6/printers.py (StdTuplePrinter): Handle empty
+       tuples.
+
 2011-12-20  Jonathan Wakely  <jwakely.gcc@gmail.com>
 
        PR libstdc++/51365
index 241ae042fe643533079ee0c9e6ef07c4409db096..4197c081d9c8e8b9919d51e20fb5a6cfc0e2579c 100644 (file)
@@ -251,11 +251,11 @@ class StdTuplePrinter:
             # Set the base class as the initial head of the
             # tuple.
             nodes = self.head.type.fields ()
-            if len (nodes) != 1:
+            if len (nodes) == 1:
+                # Set the actual head to the first pair.
+                self.head  = self.head.cast (nodes[0].type)
+            elif len (nodes) != 0:
                 raise ValueError, "Top of tuple tree does not consist of a single node."
-
-            # Set the actual head to the first pair.
-            self.head  = self.head.cast (nodes[0].type)
             self.count = 0
 
         def __iter__ (self):
@@ -297,6 +297,8 @@ class StdTuplePrinter:
         return self._iterator (self.val)
 
     def to_string (self):
+        if len (self.val.type.fields ()) == 0:
+            return 'empty %s' % (self.typename)
         return '%s containing' % (self.typename)
 
 class StdStackOrQueuePrinter: