Mercurial > public > mercurial-scm > hg
comparison mercurial/pycompat.py @ 31372:06440ba06bc0
pycompat: move imports of cStringIO/io to where they are used
There's no point to import cStringIO as io since we have to select StringIO
or BytesIO conditionally.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 12 Mar 2017 12:54:11 -0700 |
parents | 73b3bee8febe |
children | c9fd842dc886 |
comparison
equal
deleted
inserted
replaced
31371:7dd2f51f38ac | 31372:06440ba06bc0 |
---|---|
17 | 17 |
18 ispy3 = (sys.version_info[0] >= 3) | 18 ispy3 = (sys.version_info[0] >= 3) |
19 | 19 |
20 if not ispy3: | 20 if not ispy3: |
21 import cPickle as pickle | 21 import cPickle as pickle |
22 import cStringIO as io | |
23 import httplib | 22 import httplib |
24 import Queue as _queue | 23 import Queue as _queue |
25 import SocketServer as socketserver | 24 import SocketServer as socketserver |
26 import urlparse | 25 import urlparse |
27 urlunquote = urlparse.unquote | 26 urlunquote = urlparse.unquote |
28 import xmlrpclib | 27 import xmlrpclib |
29 else: | 28 else: |
30 import http.client as httplib | 29 import http.client as httplib |
31 import io | |
32 import pickle | 30 import pickle |
33 import queue as _queue | 31 import queue as _queue |
34 import socketserver | 32 import socketserver |
35 import urllib.parse as urlparse | 33 import urllib.parse as urlparse |
36 urlunquote = urlparse.unquote_to_bytes | 34 urlunquote = urlparse.unquote_to_bytes |
37 import xmlrpc.client as xmlrpclib | 35 import xmlrpc.client as xmlrpclib |
38 | 36 |
39 if ispy3: | 37 if ispy3: |
40 import builtins | 38 import builtins |
41 import functools | 39 import functools |
40 import io | |
41 | |
42 fsencode = os.fsencode | 42 fsencode = os.fsencode |
43 fsdecode = os.fsdecode | 43 fsdecode = os.fsdecode |
44 # A bytes version of os.name. | 44 # A bytes version of os.name. |
45 osname = os.name.encode('ascii') | 45 osname = os.name.encode('ascii') |
46 ospathsep = os.pathsep.encode('ascii') | 46 ospathsep = os.pathsep.encode('ascii') |
137 def shlexsplit(s): | 137 def shlexsplit(s): |
138 ret = shlex.split(s.decode('latin-1')) | 138 ret = shlex.split(s.decode('latin-1')) |
139 return [a.encode('latin-1') for a in ret] | 139 return [a.encode('latin-1') for a in ret] |
140 | 140 |
141 else: | 141 else: |
142 import cStringIO | |
143 | |
142 bytechr = chr | 144 bytechr = chr |
143 | 145 |
144 def sysstr(s): | 146 def sysstr(s): |
145 return s | 147 return s |
146 | 148 |
179 sysargv = sys.argv | 181 sysargv = sys.argv |
180 sysplatform = sys.platform | 182 sysplatform = sys.platform |
181 getcwd = os.getcwd | 183 getcwd = os.getcwd |
182 sysexecutable = sys.executable | 184 sysexecutable = sys.executable |
183 shlexsplit = shlex.split | 185 shlexsplit = shlex.split |
184 stringio = io.StringIO | 186 stringio = cStringIO.StringIO |
185 | 187 |
186 empty = _queue.Empty | 188 empty = _queue.Empty |
187 queue = _queue.Queue | 189 queue = _queue.Queue |
188 | 190 |
189 class _pycompatstub(object): | 191 class _pycompatstub(object): |