Remove trailing blanks from the results.

And also from the afflicted source file.  It is better if line ends
with what it seems to be ending in.
Use basestring instead of str for type check.

This avoids spurious errors when variable name is of unicode type.
Also removed trailing spaces and unnecessary blank lines from the
affected source files.