Show More
@@ -160,24 +160,22 b' def parserequestfromenv(env, reponame=No' | |||
|
160 | 160 | # TODO enable this once we fix internal violations. |
|
161 | 161 | # wsgiref.validate.check_environ(env) |
|
162 | 162 | |
|
163 | # PEP-0333 states that environment keys and values are native strings | |
|
164 | # (bytes on Python 2 and str on Python 3). The code points for the Unicode | |
|
165 | # strings on Python 3 must be between \00000-\000FF. We deal with bytes | |
|
166 |
# |
|
|
167 | if pycompat.ispy3: | |
|
163 | # PEP-0333 states that environment keys and values are native strings. | |
|
164 | # The code points for the Unicode strings on Python 3 must be between | |
|
165 | # \00000-\000FF. We deal with bytes in Mercurial, so mass convert string | |
|
166 | # keys and values to bytes. | |
|
167 | def tobytes(s): | |
|
168 | if not isinstance(s, str): | |
|
169 | return s | |
|
170 | if pycompat.iswindows: | |
|
171 | # This is what mercurial.encoding does for os.environ on | |
|
172 | # Windows. | |
|
173 | return encoding.strtolocal(s) | |
|
174 | else: | |
|
175 | # This is what is documented to be used for os.environ on Unix. | |
|
176 | return pycompat.fsencode(s) | |
|
168 | 177 | |
|
169 | def tobytes(s): | |
|
170 | if not isinstance(s, str): | |
|
171 | return s | |
|
172 | if pycompat.iswindows: | |
|
173 | # This is what mercurial.encoding does for os.environ on | |
|
174 | # Windows. | |
|
175 | return encoding.strtolocal(s) | |
|
176 | else: | |
|
177 | # This is what is documented to be used for os.environ on Unix. | |
|
178 | return pycompat.fsencode(s) | |
|
179 | ||
|
180 | env = {tobytes(k): tobytes(v) for k, v in pycompat.iteritems(env)} | |
|
178 | env = {tobytes(k): tobytes(v) for k, v in pycompat.iteritems(env)} | |
|
181 | 179 | |
|
182 | 180 | # Some hosting solutions are emulating hgwebdir, and dispatching directly |
|
183 | 181 | # to an hgweb instance using this environment variable. This was always |
General Comments 0
You need to be logged in to leave comments.
Login now