Page MenuHomePhabricator

UnicodeEncoding:change the default encoding of the whole script to be 'UTF-8' (issue6040)
Needs RevisionPublic

Authored by akshjain.jain74 on Mar 2 2019, 9:15 AM.

Details

Reviewers
indygreg
Group Reviewers
hg-reviewers

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

akshjain.jain74 created this revision.Mar 2 2019, 9:15 AM
indygreg requested changes to this revision.EditedMar 2 2019, 3:41 PM
indygreg added a subscriber: indygreg.

If we wanted to call sys.setdefaultencoding(), we should call it once during hg or at the top of mercurial/__init__.py.

But we don't want to call sys.setdefaultencoding(). This topic has been discussed heavily over the years. The various answers at https://stackoverflow.com/questions/3828723/why-should-we-not-use-sys-setdefaultencodingutf-8-in-a-py-script have a lot of context and I won't rehash the reasons here.

May I ask what compelled you to want to do this? Any bug you encountered that was fixed by this change represents a place where Mercurial isn't handling encoding properly. We should fix the actual places where that is occurring. Because even if we switch to UTF-8 as the default string encoding, UTF-8 isn't used everywhere and the underlying encoding problem may still exist!

Any patch to introduce sys.setdefaultencoding() into the code base will likely never be accepted (unless it is doing something special like what HGUNICODEPEDANTRY is doing). So you may want to mark this code review as abandoned.

This revision now requires changes to proceed.Mar 2 2019, 3:41 PM