2009-04-06 01:03:02 Greg Stein napisa³(a):
> On Sun, Apr 5, 2009 at 23:10, Arfrever Frehtes Taifersar Arahesis
> <Arfrever.FTA_at_gmail.com> wrote:
> > 2009-04-05 23:06:14 Branko Èibej napisa³(a):
> >> Arfrever Frehtes Taifersar Arahesis wrote:
> >> > I have found a computer with Windows system, I installed Python on that system
> >> > and I tested opening some test files with different line endings.
> >> > When opening a file [1] with either "\r\n" or "\n" or mixed line endings in text mode,
> >> > and reading it, all line endings were automatically transformed into "\n". There
> >> > were no errors. When opening in binary mode [2], actual line endings were used.
> >> > Replacing of line endings [3] was working correctly.
> >> >
> >> > [1] open(file, "r").read()
> >> > [2] open(file, "rb").read()
> >> > [3] open(file, "rb").read().replace("\r\n", "\n")
> >> >
> >>
> >> Sorry, how is that relevant? Anyone who knows anything about how
> >> text-mode files work already knows this.
> >
> > Bert Huijben claimed that opening a file with "\n" line endings on Windows
> > would cause some errors (maybe exceptions throwed by 'raise' from Python internal
> > modules).
> >
> >> You're making the tests less useful by hiding potential errors.
> >
> > What potential errors?
>
> Regressions in our code base. Potential/future errors.
>
> The point is, that you're breaking our test suite's ability to locate
> future problems in our codebase. Rewriting the output loses
> information that may be important to detecting bugs.
I disagree, but what do you think about?:
for dirpath, dirs, files in os.walk(base):
parent = path_to_key(dirpath, base)
if ignore_svn and dot_svn in dirs:
dirs.remove(dot_svn)
for name in dirs + files:
node = os.path.join(dirpath, name)
if os.path.isfile(node):
try:
contents = open(node, 'r').read()
except UnicodeDecodeError:
contents = open(node, 'rb').read()
if sys.platform == 'win32':
contents = contents.replace('\r\n', '\n')
else:
contents = None
desc[repos_join(parent, name)] = StateItem(contents=contents)
--
Arfrever Frehtes Taifersar Arahesis
Received on 2009-04-06 14:57:56 CEST