From 9dacb44bf10a5151a0d0e1a2a22865ed00575d40 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 22 Dec 2011 12:33:15 +0000 Subject: [PATCH] re PR libstdc++/48362 (pretty printer fails for zero-size std::tuple<>) PR libstdc++/48362 * python/libstdcxx/v6/printers.py (StdTuplePrinter): Handle empty tuples. From-SVN: r182620 --- libstdc++-v3/ChangeLog | 6 ++++++ libstdc++-v3/python/libstdcxx/v6/printers.py | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8775d0ab156..687a1d43830 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2011-12-22 Jonathan Wakely + + PR libstdc++/48362 + * python/libstdcxx/v6/printers.py (StdTuplePrinter): Handle empty + tuples. + 2011-12-20 Jonathan Wakely PR libstdc++/51365 diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 241ae042fe6..4197c081d9c 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -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: -- 2.30.2