Submitter | Gregory Szorc |
---|---|
Date | May 10, 2014, 11:39 p.m. |
Message ID | <e48f8388eca0c1165515.1399765197@vm-ubuntu-main.gateway.sonic.net> |
Download | mbox | patch |
Permalink | /patch/4728/ |
State | Accepted |
Commit | 007d276f8c9461384be3e7b75ee0aa69b33125fb |
Headers | show |
Comments
On Sat, May 10, 2014 at 04:39:57PM -0700, Gregory Szorc wrote: > # HG changeset patch > # User Gregory Szorc <gregory.szorc@gmail.com> > # Date 1399760524 25200 > # Sat May 10 15:22:04 2014 -0700 > # Node ID e48f8388eca0c1165515769adc191fd935b1237f > # Parent 8a49e0cb7f14a69662da24d71ec2d4ab3f536df3 > py3kcompat: don't convert os.environ to bytes I'm queueing patches 1 and 3. (Patch 1 looks like it'll probably combine well with some of my pending py3 patches, which might let demandimport work. Relatedly, we should look into using Brett Cannon's demandimporter on Python 3.x - he thinks it should be good enough for us, but I've been lazy.) > > os.environ accepts str not bytes. Assigning bytes will result in a > run-time error. > > diff --git a/mercurial/py3kcompat.py b/mercurial/py3kcompat.py > --- a/mercurial/py3kcompat.py > +++ b/mercurial/py3kcompat.py > @@ -51,15 +51,8 @@ def bytesformatter(format, args): > ret = format % args > return ret.encode('utf-8', 'surrogateescape') > builtins.bytesformatter = bytesformatter > > -# Create bytes equivalents for os.environ values > -for key in list(os.environ.keys()): > - # UTF-8 is fine for us > - bkey = key.encode('utf-8', 'surrogateescape') > - bvalue = os.environ[key].encode('utf-8', 'surrogateescape') > - os.environ[bkey] = bvalue > - > origord = builtins.ord > def fakeord(char): > if isinstance(char, int): > return char > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/py3kcompat.py b/mercurial/py3kcompat.py --- a/mercurial/py3kcompat.py +++ b/mercurial/py3kcompat.py @@ -51,15 +51,8 @@ def bytesformatter(format, args): ret = format % args return ret.encode('utf-8', 'surrogateescape') builtins.bytesformatter = bytesformatter -# Create bytes equivalents for os.environ values -for key in list(os.environ.keys()): - # UTF-8 is fine for us - bkey = key.encode('utf-8', 'surrogateescape') - bvalue = os.environ[key].encode('utf-8', 'surrogateescape') - os.environ[bkey] = bvalue - origord = builtins.ord def fakeord(char): if isinstance(char, int): return char