This is an archive of the discontinued Mercurial Phabricator instance.

py3: backout 7c54917b31f6 to make sure second argument of open() is str
AbandonedPublic

Authored by pulkit on Feb 17 2018, 5:03 AM.

Details

Reviewers
None
Group Reviewers
hg-reviewers
Summary

This backouts changeset 7c54917b31f6 in which code to prevent adding b'' in
front of second argument of open() was deleted in favour of pycompat.open().
Looking back, that's looks like a wrong decision as replacing open() with
pycompat.open() is not a good idea because of the following reasons:

  • There are around 100 occurences of open() call, it's better if we can prevent replacing all these calls
  • In future, when we will dropping all the compatibility code, we don't have to take care of changing pycompat.open back to open

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

pulkit created this revision.Feb 17 2018, 5:03 AM
yuja added a subscriber: yuja.Feb 17 2018, 5:16 AM

Can you elaborate why you think it wasn't a good idea to replace open()?

IMHO, it's as hackish as replacing '' with b''.

pulkit edited the summary of this revision. (Show Details)Feb 18 2018, 12:10 PM
In D2297#37960, @yuja wrote:

Can you elaborate why you think it wasn't a good idea to replace open()?
IMHO, it's as hackish as replacing '' with b''.

Added couple of points.

yuja added a comment.Feb 22 2018, 10:50 AM

"There are around 100 occurences of open() call, it's better if we can
prevent replacing all these calls
"In future, when we will dropping all the compatibility code, we don't have
to take care of changing pycompat.open back to open

Yeah, that's the point why we have from pycompat import open to compensate
the mess introduced by our code transformer. We want to keep 'rb' without b''.
We could do that by the transformer, but I think it's better to keep the
transformer less complicated.

FWIW, we'll need to port many of these 100 open() calls to vfs. I have vague
memory that Python 3.5 or 3.6 introduced another mess on Windows I/O around
ANSI vs Unicode.

pulkit abandoned this revision.Jun 14 2018, 4:03 PM
In D2297#39249, @yuja wrote:

"There are around 100 occurences of open() call, it's better if we can
prevent replacing all these calls
"In future, when we will dropping all the compatibility code, we don't have
to take care of changing pycompat.open back to open
Yeah, that's the point why we have from pycompat import open to compensate
the mess introduced by our code transformer. We want to keep 'rb' without b''.
We could do that by the transformer, but I think it's better to keep the
transformer less complicated.

I agree with you that we should keep transformer less complicated as much possible. Abandoning this revision.