mercurial/pycompat.py
changeset 31400 fb1f70331ee6
parent 31399 1ed169c5e235
child 31424 4acc49335a6e
equal deleted inserted replaced
31399:1ed169c5e235 31400:fb1f70331ee6
   267     ))
   267     ))
   268 
   268 
   269 else:
   269 else:
   270     import urllib.parse
   270     import urllib.parse
   271     urlreq._registeraliases(urllib.parse, (
   271     urlreq._registeraliases(urllib.parse, (
   272         "quote",
       
   273         "splitattr",
   272         "splitattr",
   274         "splitpasswd",
   273         "splitpasswd",
   275         "splitport",
   274         "splitport",
   276         "splituser",
   275         "splituser",
   277         "unquote",
   276         "unquote",
   311         "HTTPServer",
   310         "HTTPServer",
   312         "BaseHTTPRequestHandler",
   311         "BaseHTTPRequestHandler",
   313         "SimpleHTTPRequestHandler",
   312         "SimpleHTTPRequestHandler",
   314         "CGIHTTPRequestHandler",
   313         "CGIHTTPRequestHandler",
   315     ))
   314     ))
       
   315 
       
   316     # urllib.parse.quote() accepts both str and bytes, decodes bytes
       
   317     # (if necessary), and returns str. This is wonky. We provide a custom
       
   318     # implementation that only accepts bytes and emits bytes.
       
   319     def quote(s, safe=r'/'):
       
   320         s = urllib.parse.quote_from_bytes(s, safe=safe)
       
   321         return s.encode('ascii', 'strict')
       
   322 
       
   323     urlreq.quote = quote