[PATCH 6/6] Clarify a comment

John Wright jsw at debian.org
Wed Jul 29 13:44:53 UTC 2009


On Wed, Jul 29, 2009 at 03:35:32PM +0200, John Wright wrote:
> There was some confusion (marked with an XXX) in how the
> trailing-whitespace-avoiding code worked.  This patch clarifies the
> comment.
> ---
>  debian_bundle/deb822.py |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/debian_bundle/deb822.py b/debian_bundle/deb822.py
> index 3fffa4a..a71ffcc 100644
> --- a/debian_bundle/deb822.py
> +++ b/debian_bundle/deb822.py
> @@ -332,10 +332,12 @@ class Deb822(Deb822Dict):
>          else:
>              return_string = False
>          for key, value in self.iteritems():
> +            # We want one space between the "Field:" and value, unless
> +            # value starts with a newline (i.e. the value itself started on
> +            # the line *after* the field name in the control file), or is
> +            # empty.  In that case, we avoid trailing whitespace by by not
> +            # including a space after the colon.
>              if not value or value[0] == '\n':
> -                # Avoid trailing whitespace after "Field:" if it's on its own
> -                # line or the value is empty
> -                # XXX Uh, really print value if value == '\n'?
>                  fd.write('%s:%s\n' % (key, value))
>              else:
>                  fd.write('%s: %s\n' % (key, value))

Only now I actually understand what the XXX comment was asking...
Really, we want to make sure that values don't end in a newline, or
we'll effectively be making a new stanza when we add the newline to it
here.

I wonder if it would actually make more sense to have a value-sanitizer
method, which basically returns value.strip() after first making sure
there are no empty lines in value.

-- 
John Wright <jsw at debian.org>



More information about the pkg-python-debian-discuss mailing list