#16135: Removal of OS/2 support (Python code partial cleanup)
This commit is contained in:
parent
f1af705720
commit
4791a24268
|
@ -38,7 +38,7 @@ def _find_executable(executable, path=None):
|
||||||
paths = path.split(os.pathsep)
|
paths = path.split(os.pathsep)
|
||||||
base, ext = os.path.splitext(executable)
|
base, ext = os.path.splitext(executable)
|
||||||
|
|
||||||
if (sys.platform == 'win32' or os.name == 'os2') and (ext != '.exe'):
|
if (sys.platform == 'win32') and (ext != '.exe'):
|
||||||
executable = executable + '.exe'
|
executable = executable + '.exe'
|
||||||
|
|
||||||
if not os.path.isfile(executable):
|
if not os.path.isfile(executable):
|
||||||
|
|
|
@ -1709,7 +1709,7 @@ def _setup(sys_module, _imp_module):
|
||||||
builtin_module = sys.modules[builtin_name]
|
builtin_module = sys.modules[builtin_name]
|
||||||
setattr(self_module, builtin_name, builtin_module)
|
setattr(self_module, builtin_name, builtin_module)
|
||||||
|
|
||||||
os_details = ('posix', ['/']), ('nt', ['\\', '/']), ('os2', ['\\', '/'])
|
os_details = ('posix', ['/']), ('nt', ['\\', '/'])
|
||||||
for builtin_os, path_separators in os_details:
|
for builtin_os, path_separators in os_details:
|
||||||
# Assumption made in _path_join()
|
# Assumption made in _path_join()
|
||||||
assert all(len(sep) == 1 for sep in path_separators)
|
assert all(len(sep) == 1 for sep in path_separators)
|
||||||
|
@ -1720,9 +1720,6 @@ def _setup(sys_module, _imp_module):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
os_module = BuiltinImporter.load_module(builtin_os)
|
os_module = BuiltinImporter.load_module(builtin_os)
|
||||||
# TODO: rip out os2 code after 3.3 is released as per PEP 11
|
|
||||||
if builtin_os == 'os2' and 'EMX GCC' in sys.version:
|
|
||||||
path_sep = path_separators[1]
|
|
||||||
break
|
break
|
||||||
except ImportError:
|
except ImportError:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -707,8 +707,7 @@ class _singlefileMailbox(Mailbox):
|
||||||
try:
|
try:
|
||||||
os.rename(new_file.name, self._path)
|
os.rename(new_file.name, self._path)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno == errno.EEXIST or \
|
if e.errno == errno.EEXIST:
|
||||||
(os.name == 'os2' and e.errno == errno.EACCES):
|
|
||||||
os.remove(self._path)
|
os.remove(self._path)
|
||||||
os.rename(new_file.name, self._path)
|
os.rename(new_file.name, self._path)
|
||||||
else:
|
else:
|
||||||
|
@ -2093,8 +2092,7 @@ def _lock_file(f, dotlock=True):
|
||||||
os.rename(pre_lock.name, f.name + '.lock')
|
os.rename(pre_lock.name, f.name + '.lock')
|
||||||
dotlock_done = True
|
dotlock_done = True
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno == errno.EEXIST or \
|
if e.errno == errno.EEXIST:
|
||||||
(os.name == 'os2' and e.errno == errno.EACCES):
|
|
||||||
os.remove(pre_lock.name)
|
os.remove(pre_lock.name)
|
||||||
raise ExternalClashError('dot lock unavailable: %s' %
|
raise ExternalClashError('dot lock unavailable: %s' %
|
||||||
f.name)
|
f.name)
|
||||||
|
|
32
Lib/os.py
32
Lib/os.py
|
@ -1,9 +1,9 @@
|
||||||
r"""OS routines for Mac, NT, or Posix depending on what system we're on.
|
r"""OS routines for Mac, NT, or Posix depending on what system we're on.
|
||||||
|
|
||||||
This exports:
|
This exports:
|
||||||
- all functions from posix, nt, os2, or ce, e.g. unlink, stat, etc.
|
- all functions from posix, nt or ce, e.g. unlink, stat, etc.
|
||||||
- os.path is either posixpath or ntpath
|
- os.path is either posixpath or ntpath
|
||||||
- os.name is either 'posix', 'nt', 'os2' or 'ce'.
|
- os.name is either 'posix', 'nt' or 'ce'.
|
||||||
- os.curdir is a string representing the current directory ('.' or ':')
|
- os.curdir is a string representing the current directory ('.' or ':')
|
||||||
- os.pardir is a string representing the parent directory ('..' or '::')
|
- os.pardir is a string representing the parent directory ('..' or '::')
|
||||||
- os.sep is the (or a most common) pathname separator ('/' or ':' or '\\')
|
- os.sep is the (or a most common) pathname separator ('/' or ':' or '\\')
|
||||||
|
@ -81,30 +81,6 @@ elif 'nt' in _names:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif 'os2' in _names:
|
|
||||||
name = 'os2'
|
|
||||||
linesep = '\r\n'
|
|
||||||
from os2 import *
|
|
||||||
try:
|
|
||||||
from os2 import _exit
|
|
||||||
__all__.append('_exit')
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
if sys.version.find('EMX GCC') == -1:
|
|
||||||
import ntpath as path
|
|
||||||
else:
|
|
||||||
import os2emxpath as path
|
|
||||||
from _emx_link import link
|
|
||||||
|
|
||||||
import os2
|
|
||||||
__all__.extend(_get_exports_list(os2))
|
|
||||||
del os2
|
|
||||||
|
|
||||||
try:
|
|
||||||
from os2 import _have_functions
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
elif 'ce' in _names:
|
elif 'ce' in _names:
|
||||||
name = 'ce'
|
name = 'ce'
|
||||||
linesep = '\r\n'
|
linesep = '\r\n'
|
||||||
|
@ -715,7 +691,7 @@ else:
|
||||||
__all__.append("unsetenv")
|
__all__.append("unsetenv")
|
||||||
|
|
||||||
def _createenviron():
|
def _createenviron():
|
||||||
if name in ('os2', 'nt'):
|
if name == 'nt':
|
||||||
# Where Env Var Names Must Be UPPERCASE
|
# Where Env Var Names Must Be UPPERCASE
|
||||||
def check_str(value):
|
def check_str(value):
|
||||||
if not isinstance(value, str):
|
if not isinstance(value, str):
|
||||||
|
@ -755,7 +731,7 @@ def getenv(key, default=None):
|
||||||
key, default and the result are str."""
|
key, default and the result are str."""
|
||||||
return environ.get(key, default)
|
return environ.get(key, default)
|
||||||
|
|
||||||
supports_bytes_environ = name not in ('os2', 'nt')
|
supports_bytes_environ = (name != 'nt')
|
||||||
__all__.extend(("getenv", "supports_bytes_environ"))
|
__all__.extend(("getenv", "supports_bytes_environ"))
|
||||||
|
|
||||||
if supports_bytes_environ:
|
if supports_bytes_environ:
|
||||||
|
|
|
@ -122,7 +122,7 @@ try:
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# os.devnull was added in Python 2.4, so emulate it for earlier
|
# os.devnull was added in Python 2.4, so emulate it for earlier
|
||||||
# Python versions
|
# Python versions
|
||||||
if sys.platform in ('dos','win32','win16','os2'):
|
if sys.platform in ('dos','win32','win16'):
|
||||||
# Use the old CP/M NUL as device name
|
# Use the old CP/M NUL as device name
|
||||||
DEV_NULL = 'NUL'
|
DEV_NULL = 'NUL'
|
||||||
else:
|
else:
|
||||||
|
@ -896,7 +896,7 @@ def _syscmd_uname(option,default=''):
|
||||||
|
|
||||||
""" Interface to the system's uname command.
|
""" Interface to the system's uname command.
|
||||||
"""
|
"""
|
||||||
if sys.platform in ('dos','win32','win16','os2'):
|
if sys.platform in ('dos','win32','win16'):
|
||||||
# XXX Others too ?
|
# XXX Others too ?
|
||||||
return default
|
return default
|
||||||
try:
|
try:
|
||||||
|
@ -919,7 +919,7 @@ def _syscmd_file(target,default=''):
|
||||||
default in case the command should fail.
|
default in case the command should fail.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if sys.platform in ('dos','win32','win16','os2'):
|
if sys.platform in ('dos','win32','win16'):
|
||||||
# XXX Others too ?
|
# XXX Others too ?
|
||||||
return default
|
return default
|
||||||
target = _follow_symlinks(target)
|
target = _follow_symlinks(target)
|
||||||
|
|
|
@ -1393,7 +1393,7 @@ def getpager():
|
||||||
return lambda text: pipepager(text, os.environ['PAGER'])
|
return lambda text: pipepager(text, os.environ['PAGER'])
|
||||||
if os.environ.get('TERM') in ('dumb', 'emacs'):
|
if os.environ.get('TERM') in ('dumb', 'emacs'):
|
||||||
return plainpager
|
return plainpager
|
||||||
if sys.platform == 'win32' or sys.platform.startswith('os2'):
|
if sys.platform == 'win32':
|
||||||
return lambda text: tempfilepager(plain(text), 'more <')
|
return lambda text: tempfilepager(plain(text), 'more <')
|
||||||
if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0:
|
if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0:
|
||||||
return lambda text: pipepager(text, 'less')
|
return lambda text: pipepager(text, 'less')
|
||||||
|
|
21
Lib/site.py
21
Lib/site.py
|
@ -300,7 +300,7 @@ def getsitepackages(prefixes=None):
|
||||||
continue
|
continue
|
||||||
seen.add(prefix)
|
seen.add(prefix)
|
||||||
|
|
||||||
if sys.platform in ('os2emx', 'riscos'):
|
if sys.platform == 'riscos':
|
||||||
sitepackages.append(os.path.join(prefix, "Lib", "site-packages"))
|
sitepackages.append(os.path.join(prefix, "Lib", "site-packages"))
|
||||||
elif os.sep == '/':
|
elif os.sep == '/':
|
||||||
sitepackages.append(os.path.join(prefix, "lib",
|
sitepackages.append(os.path.join(prefix, "lib",
|
||||||
|
@ -329,23 +329,6 @@ def addsitepackages(known_paths, prefixes=None):
|
||||||
|
|
||||||
return known_paths
|
return known_paths
|
||||||
|
|
||||||
def setBEGINLIBPATH():
|
|
||||||
"""The OS/2 EMX port has optional extension modules that do double duty
|
|
||||||
as DLLs (and must use the .DLL file extension) for other extensions.
|
|
||||||
The library search path needs to be amended so these will be found
|
|
||||||
during module import. Use BEGINLIBPATH so that these are at the start
|
|
||||||
of the library search path.
|
|
||||||
|
|
||||||
"""
|
|
||||||
dllpath = os.path.join(sys.prefix, "Lib", "lib-dynload")
|
|
||||||
libpath = os.environ['BEGINLIBPATH'].split(';')
|
|
||||||
if libpath[-1]:
|
|
||||||
libpath.append(dllpath)
|
|
||||||
else:
|
|
||||||
libpath[-1] = dllpath
|
|
||||||
os.environ['BEGINLIBPATH'] = ';'.join(libpath)
|
|
||||||
|
|
||||||
|
|
||||||
def setquit():
|
def setquit():
|
||||||
"""Define new builtins 'quit' and 'exit'.
|
"""Define new builtins 'quit' and 'exit'.
|
||||||
|
|
||||||
|
@ -595,8 +578,6 @@ def main():
|
||||||
ENABLE_USER_SITE = check_enableusersite()
|
ENABLE_USER_SITE = check_enableusersite()
|
||||||
known_paths = addusersitepackages(known_paths)
|
known_paths = addusersitepackages(known_paths)
|
||||||
known_paths = addsitepackages(known_paths)
|
known_paths = addsitepackages(known_paths)
|
||||||
if sys.platform == 'os2emx':
|
|
||||||
setBEGINLIBPATH()
|
|
||||||
setquit()
|
setquit()
|
||||||
setcopyright()
|
setcopyright()
|
||||||
sethelper()
|
sethelper()
|
||||||
|
|
|
@ -52,25 +52,6 @@ _INSTALL_SCHEMES = {
|
||||||
'scripts': '{base}/Scripts',
|
'scripts': '{base}/Scripts',
|
||||||
'data': '{base}',
|
'data': '{base}',
|
||||||
},
|
},
|
||||||
'os2': {
|
|
||||||
'stdlib': '{installed_base}/Lib',
|
|
||||||
'platstdlib': '{base}/Lib',
|
|
||||||
'purelib': '{base}/Lib/site-packages',
|
|
||||||
'platlib': '{base}/Lib/site-packages',
|
|
||||||
'include': '{installed_base}/Include',
|
|
||||||
'platinclude': '{installed_base}/Include',
|
|
||||||
'scripts': '{base}/Scripts',
|
|
||||||
'data': '{base}',
|
|
||||||
},
|
|
||||||
'os2_home': {
|
|
||||||
'stdlib': '{userbase}/lib/python{py_version_short}',
|
|
||||||
'platstdlib': '{userbase}/lib/python{py_version_short}',
|
|
||||||
'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
|
|
||||||
'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
|
|
||||||
'include': '{userbase}/include/python{py_version_short}',
|
|
||||||
'scripts': '{userbase}/bin',
|
|
||||||
'data': '{userbase}',
|
|
||||||
},
|
|
||||||
'nt_user': {
|
'nt_user': {
|
||||||
'stdlib': '{userbase}/Python{py_version_nodot}',
|
'stdlib': '{userbase}/Python{py_version_nodot}',
|
||||||
'platstdlib': '{userbase}/Python{py_version_nodot}',
|
'platstdlib': '{userbase}/Python{py_version_nodot}',
|
||||||
|
@ -210,7 +191,7 @@ def _getuserbase():
|
||||||
def joinuser(*args):
|
def joinuser(*args):
|
||||||
return os.path.expanduser(os.path.join(*args))
|
return os.path.expanduser(os.path.join(*args))
|
||||||
|
|
||||||
# what about 'os2emx', 'riscos' ?
|
# what about 'riscos' ?
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
base = os.environ.get("APPDATA") or "~"
|
base = os.environ.get("APPDATA") or "~"
|
||||||
if env_base:
|
if env_base:
|
||||||
|
@ -524,7 +505,7 @@ def get_config_vars(*args):
|
||||||
# sys.abiflags may not be defined on all platforms.
|
# sys.abiflags may not be defined on all platforms.
|
||||||
_CONFIG_VARS['abiflags'] = ''
|
_CONFIG_VARS['abiflags'] = ''
|
||||||
|
|
||||||
if os.name in ('nt', 'os2'):
|
if os.name == 'nt':
|
||||||
_init_non_posix(_CONFIG_VARS)
|
_init_non_posix(_CONFIG_VARS)
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
_init_posix(_CONFIG_VARS)
|
_init_posix(_CONFIG_VARS)
|
||||||
|
|
|
@ -2213,8 +2213,7 @@ class TarFile(object):
|
||||||
if tarinfo.issym() and hasattr(os, "lchown"):
|
if tarinfo.issym() and hasattr(os, "lchown"):
|
||||||
os.lchown(targetpath, u, g)
|
os.lchown(targetpath, u, g)
|
||||||
else:
|
else:
|
||||||
if sys.platform != "os2emx":
|
os.chown(targetpath, u, g)
|
||||||
os.chown(targetpath, u, g)
|
|
||||||
except EnvironmentError as e:
|
except EnvironmentError as e:
|
||||||
raise ExtractError("could not change owner")
|
raise ExtractError("could not change owner")
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ class TestMkstempInner(BaseTestCase):
|
||||||
file = self.do_create()
|
file = self.do_create()
|
||||||
mode = stat.S_IMODE(os.stat(file.name).st_mode)
|
mode = stat.S_IMODE(os.stat(file.name).st_mode)
|
||||||
expected = 0o600
|
expected = 0o600
|
||||||
if sys.platform in ('win32', 'os2emx'):
|
if sys.platform == 'win32':
|
||||||
# There's no distinction among 'user', 'group' and 'world';
|
# There's no distinction among 'user', 'group' and 'world';
|
||||||
# replicate the 'user' bits.
|
# replicate the 'user' bits.
|
||||||
user = expected >> 6
|
user = expected >> 6
|
||||||
|
@ -310,7 +310,7 @@ class TestMkstempInner(BaseTestCase):
|
||||||
# On Windows a spawn* /path/ with embedded spaces shouldn't be quoted,
|
# On Windows a spawn* /path/ with embedded spaces shouldn't be quoted,
|
||||||
# but an arg with embedded spaces should be decorated with double
|
# but an arg with embedded spaces should be decorated with double
|
||||||
# quotes on each end
|
# quotes on each end
|
||||||
if sys.platform in ('win32',):
|
if sys.platform == 'win32':
|
||||||
decorated = '"%s"' % sys.executable
|
decorated = '"%s"' % sys.executable
|
||||||
tester = '"%s"' % tester
|
tester = '"%s"' % tester
|
||||||
else:
|
else:
|
||||||
|
@ -479,7 +479,7 @@ class TestMkdtemp(BaseTestCase):
|
||||||
mode = stat.S_IMODE(os.stat(dir).st_mode)
|
mode = stat.S_IMODE(os.stat(dir).st_mode)
|
||||||
mode &= 0o777 # Mask off sticky bits inherited from /tmp
|
mode &= 0o777 # Mask off sticky bits inherited from /tmp
|
||||||
expected = 0o700
|
expected = 0o700
|
||||||
if sys.platform in ('win32', 'os2emx'):
|
if sys.platform == 'win32':
|
||||||
# There's no distinction among 'user', 'group' and 'world';
|
# There's no distinction among 'user', 'group' and 'world';
|
||||||
# replicate the 'user' bits.
|
# replicate the 'user' bits.
|
||||||
user = expected >> 6
|
user = expected >> 6
|
||||||
|
|
|
@ -451,8 +451,7 @@ class ThreadJoinOnShutdown(BaseTestCase):
|
||||||
# #12316 and #11870), and fork() from a worker thread is known to trigger
|
# #12316 and #11870), and fork() from a worker thread is known to trigger
|
||||||
# problems with some operating systems (issue #3863): skip problematic tests
|
# problems with some operating systems (issue #3863): skip problematic tests
|
||||||
# on platforms known to behave badly.
|
# on platforms known to behave badly.
|
||||||
platforms_to_skip = ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5',
|
platforms_to_skip = ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5')
|
||||||
'os2emx')
|
|
||||||
|
|
||||||
def _run_and_join(self, script):
|
def _run_and_join(self, script):
|
||||||
script = """if 1:
|
script = """if 1:
|
||||||
|
|
Loading…
Reference in New Issue