Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filecmp.cmp can not compare two files from different OS with the same content #50555

Closed
higer mannequin opened this issue Jun 18, 2009 · 2 comments
Closed

filecmp.cmp can not compare two files from different OS with the same content #50555

higer mannequin opened this issue Jun 18, 2009 · 2 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@higer
Copy link
Mannequin

higer mannequin commented Jun 18, 2009

BPO 6306
Nosy @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2010-04-29.18:09:38.308>
created_at = <Date 2009-06-18.10:36:13.071>
labels = ['type-feature', 'library']
title = 'filecmp.cmp can not compare two files from different OS with the same content'
updated_at = <Date 2010-04-29.18:09:38.307>
user = 'https://bugs.python.org/higer'

bugs.python.org fields:

activity = <Date 2010-04-29.18:09:38.307>
actor = 'terry.reedy'
assignee = 'none'
closed = True
closed_date = <Date 2010-04-29.18:09:38.308>
closer = 'terry.reedy'
components = ['Library (Lib)']
creation = <Date 2009-06-18.10:36:13.071>
creator = 'higer'
dependencies = []
files = []
hgrepos = []
issue_num = 6306
keywords = []
message_count = 2.0
messages = ['89498', '89502']
nosy_count = 2.0
nosy_names = ['r.david.murray', 'higer']
pr_nums = []
priority = 'low'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue6306'
versions = ['Python 2.7', 'Python 3.2']

@higer
Copy link
Mannequin Author

higer mannequin commented Jun 18, 2009

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.

@higer higer mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jun 18, 2009
@bitdancer
Copy link
Member

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants