equal
deleted
inserted
replaced
160 # PEP-0333 states that environment keys and values are native strings |
160 # PEP-0333 states that environment keys and values are native strings |
161 # (bytes on Python 2 and str on Python 3). The code points for the Unicode |
161 # (bytes on Python 2 and str on Python 3). The code points for the Unicode |
162 # strings on Python 3 must be between \00000-\000FF. We deal with bytes |
162 # strings on Python 3 must be between \00000-\000FF. We deal with bytes |
163 # in Mercurial, so mass convert string keys and values to bytes. |
163 # in Mercurial, so mass convert string keys and values to bytes. |
164 if pycompat.ispy3: |
164 if pycompat.ispy3: |
165 env = {k.encode('latin-1'): v for k, v in pycompat.iteritems(env)} |
165 def tobytes(s): |
166 env = { |
166 if not isinstance(s, str): |
167 k: v.encode('latin-1') if isinstance(v, str) else v |
167 return s |
168 for k, v in pycompat.iteritems(env) |
168 return s.encode('latin-1') |
169 } |
169 env = {tobytes(k): tobytes(v) for k, v in pycompat.iteritems(env)} |
170 |
170 |
171 # Some hosting solutions are emulating hgwebdir, and dispatching directly |
171 # Some hosting solutions are emulating hgwebdir, and dispatching directly |
172 # to an hgweb instance using this environment variable. This was always |
172 # to an hgweb instance using this environment variable. This was always |
173 # checked prior to d7fd203e36cc; keep doing so to avoid breaking them. |
173 # checked prior to d7fd203e36cc; keep doing so to avoid breaking them. |
174 if not reponame: |
174 if not reponame: |