def getvalue(self): result = StringIO.getvalue(self) if result and not result.endswith("\n"): result += "\n" if hasattr(self, "softspace"): del self.softspace return result