mercurial/pycompat.py
changeset 29584 06587edd1233
parent 29566 075146e85bb6
child 29778 594035c1adc7
equal deleted inserted replaced
29583:6ce870dba6fa 29584:06587edd1233
     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 try:
    13 import sys
       
    14 
       
    15 if sys.version_info[0] < 3:
    14     import cPickle as pickle
    16     import cPickle as pickle
    15     pickle.dumps
    17     import cStringIO as io
    16 except ImportError:
    18     import httplib
       
    19     import Queue as _queue
       
    20     import SocketServer as socketserver
       
    21     import urlparse
       
    22     import xmlrpclib
       
    23 else:
       
    24     import http.client as httplib
       
    25     import io
    17     import pickle
    26     import pickle
    18     pickle.dumps # silence pyflakes
    27     import queue as _queue
       
    28     import socketserver
       
    29     import urllib.parse as urlparse
       
    30     import xmlrpc.client as xmlrpclib
    19 
    31 
    20 try:
    32 stringio = io.StringIO
    21     import httplib
       
    22     httplib.HTTPException
       
    23 except ImportError:
       
    24     import http.client as httplib
       
    25     httplib.HTTPException
       
    26 
       
    27 try:
       
    28     import SocketServer as socketserver
       
    29     socketserver.ThreadingMixIn
       
    30 except ImportError:
       
    31     import socketserver
       
    32     socketserver.ThreadingMixIn
       
    33 
       
    34 try:
       
    35     import xmlrpclib
       
    36     xmlrpclib.Transport
       
    37 except ImportError:
       
    38     import xmlrpc.client as xmlrpclib
       
    39     xmlrpclib.Transport
       
    40 
       
    41 try:
       
    42     import urlparse
       
    43     urlparse.urlparse
       
    44 except ImportError:
       
    45     import urllib.parse as urlparse
       
    46     urlparse.urlparse
       
    47 
       
    48 try:
       
    49     import cStringIO as io
       
    50     stringio = io.StringIO
       
    51 except ImportError:
       
    52     import io
       
    53     stringio = io.StringIO
       
    54 
       
    55 try:
       
    56     import Queue as _queue
       
    57     _queue.Queue
       
    58 except ImportError:
       
    59     import queue as _queue
       
    60 empty = _queue.Empty
    33 empty = _queue.Empty
    61 queue = _queue.Queue
    34 queue = _queue.Queue
    62 
    35 
    63 class _pycompatstub(object):
    36 class _pycompatstub(object):
    64     pass
    37     pass