mercurial/pycompat.py
changeset 30315 3874ddba1ab4
parent 30313 42af0590f4b9
child 30316 ad40d307a9f0
equal deleted inserted replaced
30314:8321b083a83d 30315:3874ddba1ab4
     8 This contains aliases to hide python version-specific details from the core.
     8 This contains aliases to hide python version-specific details from the core.
     9 """
     9 """
    10 
    10 
    11 from __future__ import absolute_import
    11 from __future__ import absolute_import
    12 
    12 
       
    13 import os
    13 import sys
    14 import sys
    14 
    15 
    15 ispy3 = (sys.version_info[0] >= 3)
    16 ispy3 = (sys.version_info[0] >= 3)
    16 
    17 
    17 if not ispy3:
    18 if not ispy3:
    32     import xmlrpc.client as xmlrpclib
    33     import xmlrpc.client as xmlrpclib
    33 
    34 
    34 if ispy3:
    35 if ispy3:
    35     import builtins
    36     import builtins
    36     import functools
    37     import functools
    37     import os
       
    38     fsencode = os.fsencode
    38     fsencode = os.fsencode
    39     fsdecode = os.fsdecode
    39     fsdecode = os.fsdecode
       
    40     # A bytes version of os.name.
       
    41     osname = os.name.encode('ascii')
    40 
    42 
    41     def sysstr(s):
    43     def sysstr(s):
    42         """Return a keyword str to be passed to Python functions such as
    44         """Return a keyword str to be passed to Python functions such as
    43         getattr() and str.encode()
    45         getattr() and str.encode()
    44 
    46 
    79 
    81 
    80     # In Python 2, fsdecode() has a very chance to receive bytes. So it's
    82     # In Python 2, fsdecode() has a very chance to receive bytes. So it's
    81     # better not to touch Python 2 part as it's already working fine.
    83     # better not to touch Python 2 part as it's already working fine.
    82     def fsdecode(filename):
    84     def fsdecode(filename):
    83         return filename
    85         return filename
       
    86 
       
    87     osname = os.name
    84 
    88 
    85 stringio = io.StringIO
    89 stringio = io.StringIO
    86 empty = _queue.Empty
    90 empty = _queue.Empty
    87 queue = _queue.Queue
    91 queue = _queue.Queue
    88 
    92