D6052: global: use raw string for setlocale() argument
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Sat Mar 2 16:32:20 EST 2019
indygreg added a subscriber: yuja.
indygreg added a comment.
The context for this series is that `HGUNICODEPEDANTRY` is completely broken without it.
For those not aware, on Python 2, if you call `sys.setdefaultencoding('undefined')`, it loads a special codec (https://docs.python.org/2/library/codecs.html#python-specific-encodings) which makes automatic coercion raise an exception instead of silently proceeding. It essentially finds all the places where you are using `str`/`unicode` improperly.
After this series, the number of test failures in that mode is ~70. Most of the remaining failures are in `stringutil.wrap()`. Essentially `textwrap` from the standard library wants to operate on native `str`. Our version is feeding in `unicode`. We get into trouble when the standard library code does a `''.join()` and some `unicode` is coerced into `str`. TBH I'm not sure how we're not seeing bugs due to this on Python 2. I'm guessing we're lacking test coverage for something passing non-ASCII into `stringutil.wrap()`?
@yuja you may be interested in the text wrapping issue.
To: indygreg, durin42, #hg-reviewers
Cc: yuja, mercurial-devel
More information about the Mercurial-devel