classification
Title: filecmp.cmp can not compare two files from different OS with the same content
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: higer, r.david.murray
Priority: low Keywords:

Created on 2009-06-18 10:36 by higer, last changed 2010-04-29 18:09 by terry.reedy. This issue is now closed.

Messages (2)
msg89498 - (view) Author: higer (higer) Date: 2009-06-18 10:36
I just want to compare two files,one from windows and the other from
unix. But I do not want to compare them through reading them line by
line. Then I found there is a filecmp module which is used as file and
directory comparisons. However,when I use two same files (one from
unix,one from windows,the content of them is the same) to test its cmp
function, filecmp.cmp told me false.
Later, I found that windows use '\n\r' as new line flag but unix use
'\n', so filecmp.cmp think that they are different,then return false.

I think maybe it's a bug.
If filecmp.cmp can support two platform files with the same content
and only the diffrent last newline flag, that's would be wonderful.
msg89502 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-06-18 12:50
If you do not want to compare them by reading line by line, then you are
doing a binary comparison (which is what filecmp does) and the two files
are, indeed, different.  If you want to compare them in text mode, you
are moving into 'diff' territory and could use difflib instead.

If you nevertheless want to propose an additional
text-and-universal-newline-mode version of cmp (it would be best if you
were prepared to write the patch), please bring it up on python-ideas
for community discussion, as it is not clear that it is a good idea.  If
you get a consensus that it is a good idea you can reopen this ticket
with a pointer to the discussion.
History
Date User Action Args
2011-01-17 18:17:09r.david.murraylinkissue10927 superseder
2010-04-29 18:09:38terry.reedysetstatus: pending -> closed
2009-06-18 12:50:20r.david.murraysetstatus: open -> pending
priority: low

versions: + Python 2.7, Python 3.2, - Python 2.5
nosy: + r.david.murray

messages: + msg89502
resolution: rejected
2009-06-18 10:36:13higercreate