This is an archive of the discontinued Mercurial Phabricator instance.

py3: replace file() with open() in test-convert-git.t
ClosedPublic

Authored by pulkit on Feb 11 2018, 7:42 AM.

Details

Summary

file() is not present in Python 3.
It also makes sure we write bytes on Python 3.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

pulkit created this revision.Feb 11 2018, 7:42 AM
yuja requested changes to this revision.Feb 11 2018, 9:07 AM
yuja added a subscriber: yuja.
yuja added inline comments.
tests/test-convert-git.t
423

We'll need b"' and make chr() return bytes.

This revision now requires changes to proceed.Feb 11 2018, 9:07 AM
pulkit added inline comments.Feb 12 2018, 3:46 AM
tests/test-convert-git.t
423

To make chr() return bytes, I did chr().encode('latin-1') but there is UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 0: ordinal not in range(128) error while writing to file. Python 2 also don't have the encoding argument to open which Python 3 has. Looks like need to write a .py file and execute that.

yuja added inline comments.Feb 12 2018, 5:37 AM
tests/test-convert-git.t
423

Maybe we can steal pycompat.bytechr of py3. It should work on both Pythons.

pulkit edited the summary of this revision. (Show Details)Feb 17 2018, 5:27 AM
pulkit updated this revision to Diff 5808.
yuja accepted this revision.Feb 17 2018, 7:29 AM
This revision is now accepted and ready to land.Feb 17 2018, 7:29 AM
This revision was automatically updated to reflect the committed changes.