mercurial/encoding.py
changeset 44452 9d2b2df2c2ba
parent 43787 be8552f25cab
child 45681 a736ab681b78
equal deleted inserted replaced
44449:ff72bd52d56a 44452:9d2b2df2c2ba
    84 elif _nativeenviron:
    84 elif _nativeenviron:
    85     environ = os.environb  # re-exports
    85     environ = os.environb  # re-exports
    86 else:
    86 else:
    87     # preferred encoding isn't known yet; use utf-8 to avoid unicode error
    87     # preferred encoding isn't known yet; use utf-8 to avoid unicode error
    88     # and recreate it once encoding is settled
    88     # and recreate it once encoding is settled
    89     environ = dict(
    89     environ = {
    90         (k.encode('utf-8'), v.encode('utf-8'))
    90         k.encode('utf-8'): v.encode('utf-8')
    91         for k, v in os.environ.items()  # re-exports
    91         for k, v in os.environ.items()  # re-exports
    92     )
    92     }
    93 
    93 
    94 _encodingrewrites = {
    94 _encodingrewrites = {
    95     b'646': b'ascii',
    95     b'646': b'ascii',
    96     b'ANSI_X3.4-1968': b'ascii',
    96     b'ANSI_X3.4-1968': b'ascii',
    97 }
    97 }
   283     strmethod = pycompat.identity
   283     strmethod = pycompat.identity
   284 
   284 
   285 if not _nativeenviron:
   285 if not _nativeenviron:
   286     # now encoding and helper functions are available, recreate the environ
   286     # now encoding and helper functions are available, recreate the environ
   287     # dict to be exported to other modules
   287     # dict to be exported to other modules
   288     environ = dict(
   288     environ = {
   289         (tolocal(k.encode('utf-8')), tolocal(v.encode('utf-8')))
   289         tolocal(k.encode('utf-8')): tolocal(v.encode('utf-8'))
   290         for k, v in os.environ.items()  # re-exports
   290         for k, v in os.environ.items()  # re-exports
   291     )
   291     }
   292 
   292 
   293 if pycompat.ispy3:
   293 if pycompat.ispy3:
   294     # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
   294     # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
   295     # returns bytes.
   295     # returns bytes.
   296     if pycompat.iswindows:
   296     if pycompat.iswindows: