mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Reduce the usage of the types module.
This commit is contained in:
parent
a164574937
commit
f715366f23
8 changed files with 64 additions and 68 deletions
|
@ -372,7 +372,6 @@ import sys
|
|||
mswindows = (sys.platform == "win32")
|
||||
|
||||
import os
|
||||
import types
|
||||
import traceback
|
||||
|
||||
# Exception classes used by this module.
|
||||
|
@ -638,7 +637,7 @@ class Popen(object):
|
|||
# Detach and turn into fd
|
||||
p2cwrite = p2cwrite.Detach()
|
||||
p2cwrite = msvcrt.open_osfhandle(p2cwrite, 0)
|
||||
elif type(stdin) == types.IntType:
|
||||
elif type(stdin) == int:
|
||||
p2cread = msvcrt.get_osfhandle(stdin)
|
||||
else:
|
||||
# Assuming file-like object
|
||||
|
@ -652,7 +651,7 @@ class Popen(object):
|
|||
# Detach and turn into fd
|
||||
c2pread = c2pread.Detach()
|
||||
c2pread = msvcrt.open_osfhandle(c2pread, 0)
|
||||
elif type(stdout) == types.IntType:
|
||||
elif type(stdout) == int:
|
||||
c2pwrite = msvcrt.get_osfhandle(stdout)
|
||||
else:
|
||||
# Assuming file-like object
|
||||
|
@ -668,7 +667,7 @@ class Popen(object):
|
|||
errread = msvcrt.open_osfhandle(errread, 0)
|
||||
elif stderr == STDOUT:
|
||||
errwrite = c2pwrite
|
||||
elif type(stderr) == types.IntType:
|
||||
elif type(stderr) == int:
|
||||
errwrite = msvcrt.get_osfhandle(stderr)
|
||||
else:
|
||||
# Assuming file-like object
|
||||
|
@ -711,7 +710,7 @@ class Popen(object):
|
|||
errread, errwrite):
|
||||
"""Execute program (MS Windows version)"""
|
||||
|
||||
if not isinstance(args, types.StringTypes):
|
||||
if not isinstance(args, basestring):
|
||||
args = list2cmdline(args)
|
||||
|
||||
# Process startup details
|
||||
|
@ -876,7 +875,7 @@ class Popen(object):
|
|||
pass
|
||||
elif stdin == PIPE:
|
||||
p2cread, p2cwrite = os.pipe()
|
||||
elif type(stdin) == types.IntType:
|
||||
elif type(stdin) == int:
|
||||
p2cread = stdin
|
||||
else:
|
||||
# Assuming file-like object
|
||||
|
@ -886,7 +885,7 @@ class Popen(object):
|
|||
pass
|
||||
elif stdout == PIPE:
|
||||
c2pread, c2pwrite = os.pipe()
|
||||
elif type(stdout) == types.IntType:
|
||||
elif type(stdout) == int:
|
||||
c2pwrite = stdout
|
||||
else:
|
||||
# Assuming file-like object
|
||||
|
@ -898,7 +897,7 @@ class Popen(object):
|
|||
errread, errwrite = os.pipe()
|
||||
elif stderr == STDOUT:
|
||||
errwrite = c2pwrite
|
||||
elif type(stderr) == types.IntType:
|
||||
elif type(stderr) == int:
|
||||
errwrite = stderr
|
||||
else:
|
||||
# Assuming file-like object
|
||||
|
@ -937,7 +936,7 @@ class Popen(object):
|
|||
errread, errwrite):
|
||||
"""Execute program (POSIX version)"""
|
||||
|
||||
if isinstance(args, types.StringTypes):
|
||||
if isinstance(args, basestring):
|
||||
args = [args]
|
||||
|
||||
if shell:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue