HomePhabricator

crdump: fix the binary file dumping on windows

Authored by mitrandir.

Description

crdump: fix the binary file dumping on windows

Summary:
Stupid bug corrupted files with extra \r on windows.

From python manual:

On Windows, 'b' appended to the mode opens the file in binary mode, so there are also modes like 'rb', 'wb', and 'r+b'. Python on Windows makes a distinction between text and binary files; the end-of-line characters in text files are automatically altered slightly when data is read or written. This behind-the-scenes modification to file data is fine for ASCII text files, but it’ll corrupt binary data like that in JPEG or EXE files. Be very careful to use binary mode when reading and writing such files. On Unix, it doesn’t hurt to append a 'b' to the mode, so you can use it platform-independently for all binary files.

Test Plan: the crdump tests should now pass on windows as well (didn't actually run them on Windows because I don't really know how)

Reviewers: #mercurial, rmcelroy, ikostia, medson

Reviewed By: medson

Subscribers: mjpieters, medson

Differential Revision: https://phabricator.intern.facebook.com/D6151931

Tasks: T23027803

Signature: 6151931:1508964509:65806961cbde26884cd45def17767135ceeac05f

Details

Committed
mitrandirOct 25 2017, 4:59 PM
Parents
rFBHGX5145f78427e3: test-merge-conflictinfo: include expected failures according to sid's hotfix
Branches
Unknown
Tags
Unknown