diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -113,7 +113,7 @@ elif os.name == "posix": return res.group(0) - if sys.platform == "sunos5": + if sys.platform == "sunos": # use /usr/ccs/bin/dump on solaris def _get_soname(f): if not f: @@ -142,9 +142,7 @@ elif os.name == "posix": return None return res.group(1) - if (sys.platform.startswith("freebsd") - or sys.platform.startswith("openbsd") - or sys.platform.startswith("dragonfly")): + if sys.platform in ("freebsd", "openbsd", "dragonfly"): def _num_version(libname): # "libxyz.so.MAJOR.MINOR" => [ MAJOR, MINOR ] diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py --- a/Lib/distutils/command/build_ext.py +++ b/Lib/distutils/command/build_ext.py @@ -240,8 +240,7 @@ class build_ext(Command): # for extensions under Linux or Solaris with a shared Python library, # Python's library directory must be appended to library_dirs sysconfig.get_config_var('Py_ENABLE_SHARED') - if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu') - or sys.platform.startswith('sunos')) + if (sys.platform.startswith(('linux', 'gnu', 'sunos')) and sysconfig.get_config_var('Py_ENABLE_SHARED')): if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): # building third party extensions diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py --- a/Lib/distutils/unixccompiler.py +++ b/Lib/distutils/unixccompiler.py @@ -283,11 +283,11 @@ class UnixCCompiler(CCompiler): if sys.platform[:6] == "darwin": # MacOSX's linker doesn't understand the -R flag at all return "-L" + dir - elif sys.platform[:5] == "hp-ux": + elif sys.platform.startswith("hp-ux"): if self._is_gcc(compiler): return ["-Wl,+s", "-L" + dir] return ["+s", "-L" + dir] - elif sys.platform[:7] == "irix646" or sys.platform[:6] == "osf1V5": + elif sys.platform.startswith(("irix", "osf")): return ["-rpath", dir] else: if self._is_gcc(compiler): diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py --- a/Lib/distutils/util.py +++ b/Lib/distutils/util.py @@ -64,27 +64,27 @@ def get_platform (): machine = machine.replace(' ', '_') machine = machine.replace('/', '-') - if osname[:5] == "linux": + if osname.startswith("linux"): # At least on Linux/Intel, 'machine' is the processor -- # i386, etc. # XXX what about Alpha, SPARC, etc? return "%s-%s" % (osname, machine) - elif osname[:5] == "sunos": + elif osname.startswith("sunos"): if release[0] >= "5": # SunOS 5 == Solaris 2 osname = "solaris" release = "%d.%s" % (int(release[0]) - 3, release[2:]) # fall through to standard osname-release-machine representation - elif osname[:4] == "irix": # could be "irix64"! + elif osname.startswith("irix"): # could be "irix64"! return "%s-%s" % (osname, release) - elif osname[:3] == "aix": + elif osname.startswith("aix"): return "%s-%s.%s" % (osname, version, release) - elif osname[:6] == "cygwin": + elif osname.startswith("cygwin"): osname = "cygwin" rel_re = re.compile (r'[\d.]+', re.ASCII) m = rel_re.match(release) if m: release = m.group() - elif osname[:6] == "darwin": + elif osname.startswith("darwin"): # # For our purposes, we'll assume that the system version from # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set diff --git a/Lib/packaging/command/build_ext.py b/Lib/packaging/command/build_ext.py --- a/Lib/packaging/command/build_ext.py +++ b/Lib/packaging/command/build_ext.py @@ -244,8 +244,7 @@ class build_ext(Command): # for extensions under Linux or Solaris with a shared Python library, # Python's library directory must be appended to library_dirs sysconfig.get_config_var('Py_ENABLE_SHARED') - if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu') - or sys.platform.startswith('sunos')) + if (sys.platform.startswith(('linux', 'gnu', 'sunos')) and sysconfig.get_config_var('Py_ENABLE_SHARED')): if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): # building third party extensions diff --git a/Lib/packaging/compiler/unixccompiler.py b/Lib/packaging/compiler/unixccompiler.py --- a/Lib/packaging/compiler/unixccompiler.py +++ b/Lib/packaging/compiler/unixccompiler.py @@ -287,11 +287,11 @@ class UnixCCompiler(CCompiler): if sys.platform[:6] == "darwin": # MacOSX's linker doesn't understand the -R flag at all return "-L" + dir - elif sys.platform[:5] == "hp-ux": + elif sys.platform == "hp-ux": if self._is_gcc(compiler): return ["-Wl,+s", "-L" + dir] return ["+s", "-L" + dir] - elif sys.platform[:7] == "irix646" or sys.platform[:6] == "osf1V5": + elif sys.platform.startswith(("irix", "osf")): return ["-rpath", dir] elif self._is_gcc(compiler): # gcc on non-GNU systems does not need -Wl, but can @@ -304,7 +304,7 @@ class UnixCCompiler(CCompiler): return "-Wl,--enable-new-dtags,-R" + dir else: return "-Wl,-R" + dir - elif sys.platform[:3] == "aix": + elif sys.platform.startswith("aix"): return "-blibpath:" + dir else: # No idea how --enable-new-dtags would be passed on to diff --git a/Lib/packaging/tests/test_config.py b/Lib/packaging/tests/test_config.py --- a/Lib/packaging/tests/test_config.py +++ b/Lib/packaging/tests/test_config.py @@ -42,7 +42,7 @@ requires_dist = MichaelPalin (> 1.1) pywin32; sys.platform == 'win32' pysqlite2; python_version < '2.5' - inotify (0.0.1); sys.platform == 'linux2' + inotify (0.0.1); sys.platform.startswith('linux') requires_external = libxml2 @@ -252,7 +252,7 @@ class ConfigTestCase(support.TempdirMana 'MichaelPalin (> 1.1)', "pywin32; sys.platform == 'win32'", "pysqlite2; python_version < '2.5'", - "inotify (0.0.1); sys.platform == 'linux2'"] + "inotify (0.0.1); sys.platform.startswith('linux')"] self.assertEqual(dist.metadata['Requires-Dist'], wanted) urls = [('Main repository', diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -631,27 +631,27 @@ def get_platform(): machine = machine.replace(' ', '_') machine = machine.replace('/', '-') - if osname[:5] == "linux": + if osname.startswith("linux"): # At least on Linux/Intel, 'machine' is the processor -- # i386, etc. # XXX what about Alpha, SPARC, etc? return "%s-%s" % (osname, machine) - elif osname[:5] == "sunos": + elif osname.startswith("sunos"): if release[0] >= "5": # SunOS 5 == Solaris 2 osname = "solaris" release = "%d.%s" % (int(release[0]) - 3, release[2:]) # fall through to standard osname-release-machine representation - elif osname[:4] == "irix": # could be "irix64"! + elif osname.startswith("irix"): # could be "irix64"! return "%s-%s" % (osname, release) - elif osname[:3] == "aix": + elif osname.startswith("aix"): return "%s-%s.%s" % (osname, version, release) - elif osname[:6] == "cygwin": + elif osname.startswith("cygwin"): osname = "cygwin" rel_re = re.compile(r'[\d.]+') m = rel_re.match(release) if m: release = m.group() - elif osname[:6] == "darwin": + elif osname.startswith("darwin"): # # For our purposes, we'll assume that the system version from # distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set diff --git a/Lib/test/fork_wait.py b/Lib/test/fork_wait.py --- a/Lib/test/fork_wait.py +++ b/Lib/test/fork_wait.py @@ -55,7 +55,7 @@ class ForkWait(unittest.TestCase): prefork_lives = self.alive.copy() - if sys.platform in ['unixware7']: + if sys.platform == 'unixware': cpid = os.fork1() else: cpid = os.fork() diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -1391,8 +1391,8 @@ def printlist(x, width=70, indent=4): # Tests that are expected to be skipped everywhere except on one platform # are also handled separately. -_expectations = ( - ('win32', +_expectations = { + 'win32': """ test__locale test_crypt @@ -1420,15 +1420,15 @@ _expectations = ( test_threadsignals test_wait3 test_wait4 - """), - ('linux', + """, + 'linux': """ test_curses test_largefile test_kqueue test_ossaudiodev - """), - ('unixware', + """, + 'unixware': """ test_epoll test_largefile @@ -1438,8 +1438,8 @@ _expectations = ( test_pyexpat test_sax test_sundry - """), - ('openunix', + """, + 'openunix': """ test_epoll test_largefile @@ -1449,8 +1449,8 @@ _expectations = ( test_pyexpat test_sax test_sundry - """), - ('sco_sv', + """, + 'sco_sv': """ test_asynchat test_fork1 @@ -1469,8 +1469,8 @@ _expectations = ( test_threaded_import test_threadedtempfile test_threading - """), - ('darwin', + """, + 'darwin': """ test__locale test_curses @@ -1482,8 +1482,8 @@ _expectations = ( test_minidom test_ossaudiodev test_poll - """), - ('sunos', + """, + 'sunos': """ test_curses test_dbm @@ -1494,8 +1494,8 @@ _expectations = ( test_openpty test_zipfile test_zlib - """), - ('hp-ux', + """, + 'hp-ux': """ test_curses test_epoll @@ -1510,8 +1510,8 @@ _expectations = ( test_sax test_zipfile test_zlib - """), - ('cygwin', + """, + 'cygwin': """ test_curses test_dbm @@ -1522,8 +1522,8 @@ _expectations = ( test_locale test_ossaudiodev test_socketserver - """), - ('os2emx', + """, + 'os2emx': """ test_audioop test_curses @@ -1536,8 +1536,8 @@ _expectations = ( test_pty test_resource test_signal - """), - ('freebsd', + """, + 'freebsd': """ test_epoll test_dbm_gnu @@ -1553,8 +1553,8 @@ _expectations = ( test_timeout test_urllibnet test_multiprocessing - """), - ('aix', + """, + 'aix': """ test_bz2 test_epoll @@ -1568,8 +1568,8 @@ _expectations = ( test_ttk_textonly test_zipimport test_zlib - """), - ('openbsd', + """, + 'openbsd': """ test_ctypes test_epoll @@ -1583,8 +1583,8 @@ _expectations = ( test_ttk_guionly test_ttk_textonly test_multiprocessing - """), - ('netbsd', + """, + 'netbsd': """ test_ctypes test_curses @@ -1598,8 +1598,8 @@ _expectations = ( test_ttk_guionly test_ttk_textonly test_multiprocessing - """), -) + """, +} class _ExpectedSkips: def __init__(self): @@ -1607,13 +1607,8 @@ class _ExpectedSkips: from test import test_timeout self.valid = False - expected = None - for item in _expectations: - if sys.platform.startswith(item[0]): - expected = item[1] - break - if expected is not None: - self.expected = set(expected.split()) + if sys.platform in _expectations: + self.expected = set(_expectations[sys.platform].split()) # These are broken tests, for now skipped on every platform. # XXX Fix these! @@ -1643,7 +1638,7 @@ class _ExpectedSkips: "test_sqlite", "test_msilib"} self.expected |= WIN_ONLY - if sys.platform != 'sunos5': + if sys.platform != 'sunos': self.expected.add('test_nis') if support.python_is_optimized(): diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -311,7 +311,7 @@ def requires_linux_version(*min_version) def decorator(func): @functools.wraps(func) def wrapper(*args, **kw): - if sys.platform.startswith('linux'): + if sys.platform == 'linux': version_txt = platform.release().split('-', 1)[0] try: version = tuple(map(int, version_txt.split('.'))) diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -623,7 +623,7 @@ class BaseTestAPI(unittest.TestCase): client = TestClient(server.address) self.loop_waiting_for_flag(client) - @unittest.skipIf(sys.platform.startswith("sunos"), + @unittest.skipIf(sys.platform == "sunos", "OOB support is broken on Solaris") def test_handle_expt(self): # Make sure handle_expt is called on OOB data received. diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -23,9 +23,8 @@ def get_lockdata(): else: start_len = "qq" - if (any(sys.platform.startswith(prefix) - for prefix in ('netbsd', 'freebsd', 'openbsd', 'bsdos')) - or sys.platform in ('Darwin1.2', 'darwin')): + if sys.platform in ('netbsd', 'freebsd', 'openbsd', 'bsdos', + 'Darwin1.2', 'darwin'): if struct.calcsize('l') == 8: off_t = 'l' pid_t = 'i' @@ -34,9 +33,9 @@ def get_lockdata(): pid_t = 'l' lockdata = struct.pack(off_t + off_t + pid_t + 'hh', 0, 0, 0, fcntl.F_WRLCK, 0) - elif sys.platform in ['aix3', 'aix4', 'hp-uxB', 'unixware7']: + elif sys.platform in ('aix', 'hp-ux', 'unixware'): lockdata = struct.pack('hhlllii', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0) - elif sys.platform in ['os2emx']: + elif sys.platform == 'os2emx': lockdata = None else: lockdata = struct.pack('hh'+start_len+'hh', fcntl.F_WRLCK, 0, 0, 0, 0, 0) diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py --- a/Lib/test/test_locale.py +++ b/Lib/test/test_locale.py @@ -357,7 +357,7 @@ class TestEnUSCollation(BaseLocalizedTes if enc not in ('utf-8', 'iso8859-1', 'cp1252'): raise unittest.SkipTest('encoding not suitable') if enc != 'iso8859-1' and (sys.platform == 'darwin' or - sys.platform.startswith('freebsd')): + sys.platform == 'freebsd'): raise unittest.SkipTest('wcscoll/wcsxfrm have known bugs') BaseLocalizedTest.setUp(self) diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -527,7 +527,7 @@ class HandlerTest(BaseTest): def test_builtin_handlers(self): # We can't actually *use* too many handlers in the tests, # but we can try instantiating them with various options - if sys.platform.startswith('linux') or sys.platform == 'darwin': + if sys.platform in ('linux', 'darwin'): for existing in (True, False): fd, fn = tempfile.mkstemp() os.close(fd) diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -2197,7 +2197,7 @@ testcases_other = [OtherTest, TestInvali # def test_main(run=None): - if sys.platform.startswith("linux"): + if sys.platform == "linux": try: lock = multiprocessing.RLock() except OSError: diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -1338,9 +1338,9 @@ if threading is not None: class TestSendfile(unittest.TestCase): DATA = b"12345abcde" * 16 * 1024 # 160 KB - SUPPORT_HEADERS_TRAILERS = not sys.platform.startswith("linux") and \ - not sys.platform.startswith("solaris") and \ - not sys.platform.startswith("sunos") + SUPPORT_HEADERS_TRAILERS = not sys.platform.startswith(("linux", + "solaris", + "sunos")) @classmethod def setUpClass(cls): diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -215,7 +215,7 @@ class PosixTester(unittest.TestCase): except OSError as inst: # issue10812, ZFS doesn't appear to support posix_fallocate, # so skip Solaris-based since they are likely to have ZFS. - if inst.errno != errno.EINVAL or not sys.platform.startswith("sunos"): + if inst.errno != errno.EINVAL or sys.platform != "sunos": raise finally: os.close(fd) diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -135,7 +135,7 @@ class InterProcessSignalTests(unittest.T " didn't arrive after another second.") # Issue 3864, unknown if this affects earlier versions of freebsd also - @unittest.skipIf(sys.platform=='freebsd6', + @unittest.skipIf(sys.platform == 'freebsd' and platform.major() == 6, 'inter process signals not reliable (do not mix well with threading) ' 'on freebsd6') def test_main(self): @@ -471,7 +471,8 @@ class ItimerTest(unittest.TestCase): self.assertEqual(self.hndl_called, True) # Issue 3864, unknown if this affects earlier versions of freebsd also - @unittest.skipIf(sys.platform in ('freebsd6', 'netbsd5'), + @unittest.skipIf((sys.platform == 'freebsd' and platform.major() == 6) + or (sys.platform == 'netbsd' and platform.major() == 5), 'itimer not reliable (does not mix well with threading) on some BSDs.') def test_itimer_virtual(self): self.itimer = signal.ITIMER_VIRTUAL @@ -494,7 +495,7 @@ class ItimerTest(unittest.TestCase): self.assertEqual(self.hndl_called, True) # Issue 3864, unknown if this affects earlier versions of freebsd also - @unittest.skipIf(sys.platform=='freebsd6', + @unittest.skipIf(sys.platform == 'freebsd' and platform.major() == 6, 'itimer not reliable (does not mix well with threading) on freebsd6') def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF @@ -571,7 +572,7 @@ class PendingSignalsTests(unittest.TestC signal.signal(signum, handler) - if sys.platform == 'freebsd6': + if sys.platform == 'freebsd' and platform.major() == 6: # Issue #12392 and #12469: send a signal to the main thread # doesn't work before the creation of the first thread on # FreeBSD 6 @@ -836,7 +837,7 @@ class PendingSignalsTests(unittest.TestC """ assert_python_ok('-c', code) - @unittest.skipIf(sys.platform == 'freebsd6', + @unittest.skipIf(sys.platform == 'freebsd' and platform.major() == 6, "issue #12392: send a signal to the main thread doesn't work " "before the creation of the first thread on FreeBSD 6") @unittest.skipUnless(hasattr(signal, 'pthread_kill'), diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -442,10 +442,7 @@ class GeneralModuleTests(unittest.TestCa # Find one service that exists, then check all the related interfaces. # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. - if (sys.platform.startswith('linux') or - sys.platform.startswith('freebsd') or - sys.platform.startswith('netbsd') or - sys.platform == 'darwin'): + if sys.platform in ('linux', 'freebsd', 'netbsd', 'darwin'): # avoid the 'echo' service on this platform, as there is an # assumption breaking non-standard port/protocol entry services = ('daytime', 'qotd', 'domain') @@ -2074,7 +2071,7 @@ def test_main(): ]) if hasattr(socket, "socketpair"): tests.append(BasicSocketPairTest) - if sys.platform.startswith('linux'): + if sys.platform == 'linux': tests.append(TestLinuxAbstractNamespace) if isTipcAvailable(): tests.append(TIPCTest) diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -703,7 +703,7 @@ class GNUReadTest(LongnameTest): # Return True if the platform knows the st_blocks stat attribute and # uses st_blocks units of 512 bytes, and if the filesystem is able to # store holes in files. - if sys.platform.startswith("linux"): + if sys.platform == "linux": # Linux evidentially has 512 byte st_blocks units. name = os.path.join(TEMPDIR, "sparse-test") with open(name, "wb") as fobj: diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -20,7 +20,7 @@ has_spawnl = hasattr(os, 'spawnl') # TEST_FILES may need to be tweaked for systems depending on the maximum # number of files that can be opened at one time (see ulimit -n) -if sys.platform.startswith('openbsd'): +if sys.platform == 'openbsd': TEST_FILES = 48 else: TEST_FILES = 100 diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -422,8 +422,10 @@ class ThreadJoinOnShutdown(BaseTestCase) # #12316 and #11870), and fork() from a worker thread is known to trigger # problems with some operating systems (issue #3863): skip problematic tests # on platforms known to behave badly. - platforms_to_skip = ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5', - 'os2emx') + platforms_to_skip = lambda: ( + (sys.platform == 'freebsd' and platform.major() <= 6) + or (sys.platform == 'netbsd' and platform.major() == 5) + or sys.platform == 'os2emx') def _run_and_join(self, script): script = """if 1: @@ -455,7 +457,7 @@ class ThreadJoinOnShutdown(BaseTestCase) self._run_and_join(script) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") - @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") + @unittest.skipIf(platforms_to_skip(), "due to known OS bug") def test_2_join_in_forked_process(self): # Like the test above, but from a forked interpreter script = """if 1: @@ -472,7 +474,7 @@ class ThreadJoinOnShutdown(BaseTestCase) self._run_and_join(script) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") - @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") + @unittest.skipIf(platforms_to_skip(), "due to known OS bug") def test_3_join_in_forked_from_thread(self): # Like the test above, but fork() was called from a worker thread # In the forked process, the main Thread object must be marked as stopped. @@ -502,7 +504,7 @@ class ThreadJoinOnShutdown(BaseTestCase) self.assertEqual(data, expected_output) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") - @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") + @unittest.skipIf(platforms_to_skip(), "due to known OS bug") def test_4_joining_across_fork_in_worker_thread(self): # There used to be a possible deadlock when forking from a child # thread. See http://bugs.python.org/issue6643. @@ -575,7 +577,7 @@ class ThreadJoinOnShutdown(BaseTestCase) self.assertScriptHasOutput(script, "end of main\n") @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") - @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") + @unittest.skipIf(platforms_to_skip(), "due to known OS bug") def test_5_clear_waiter_locks_to_avoid_crash(self): # Check that a spawned thread that forks doesn't segfault on certain # platforms, namely OS X. This used to happen if there was a waiter diff --git a/Lib/unittest/test/test_break.py b/Lib/unittest/test/test_break.py --- a/Lib/unittest/test/test_break.py +++ b/Lib/unittest/test/test_break.py @@ -10,8 +10,8 @@ import unittest @unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") @unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") -@unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " - "if threads have been used") +@unittest.skipIf(sys.platform == 'freebsd' and platform.major() == 6, + "Test kills regrtest on freebsd6 if threads have been used") class TestBreak(unittest.TestCase): def setUp(self): diff --git a/configure.in b/configure.in --- a/configure.in +++ b/configure.in @@ -288,6 +288,7 @@ AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX) # Set name for machine-dependent library files AC_SUBST(MACHDEP) AC_MSG_CHECKING(MACHDEP) + if test -z "$MACHDEP" then ac_sys_system=`uname -s` @@ -297,18 +298,12 @@ then else ac_sys_release=`uname -r` fi - ac_md_system=`echo $ac_sys_system | + MACHDEP=`echo $ac_sys_system | tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'` - ac_md_release=`echo $ac_sys_release | - tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'` - MACHDEP="$ac_md_system$ac_md_release" - - case $MACHDEP in - cygwin*) MACHDEP="cygwin";; - darwin*) MACHDEP="darwin";; - irix646) MACHDEP="irix6";; - '') MACHDEP="unknown";; - esac + + if [ -z "$MACHDEP" ]; then + MACHDEP="unknown" + fi fi # Some systems cannot stand _XOPEN_SOURCE being defined at all; they diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -363,7 +363,7 @@ class PyBuildExt(build_ext): def get_platform(self): # Get value of sys.platform - for platform in ['cygwin', 'darwin', 'osf1']: + for platform in ['cygwin', 'darwin', 'osf']: if sys.platform.startswith(platform): return platform return sys.platform @@ -462,7 +462,7 @@ class PyBuildExt(build_ext): srcdir = sysconfig.get_config_var('srcdir') # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) - if platform in ['osf1', 'unixware7', 'openunix8']: + if platform in ('osf', 'unixware', 'openunix'): lib_dirs += ['/usr/ccs/lib'] if platform == 'darwin': @@ -1341,17 +1341,17 @@ class PyBuildExt(build_ext): macros = dict() libraries = [] - elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'): + elif platform == 'freebsd': # FreeBSD's P1003.1b semaphore support is very experimental # and has many known problems. (as of June 2008) macros = dict() libraries = [] - elif platform.startswith('openbsd'): + elif platform == 'openbsd': macros = dict() libraries = [] - elif platform.startswith('netbsd'): + elif platform == 'netbsd': macros = dict() libraries = [] @@ -1381,8 +1381,7 @@ class PyBuildExt(build_ext): # End multiprocessing # Platform-specific libraries - if any(platform.startswith(prefix) - for prefix in ("linux", "freebsd", "gnukfreebsd")): + if platform in ("linux", "freebsd", "gnukfreebsd"): exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) else: missing.append('ossaudiodev') @@ -1555,7 +1554,7 @@ class PyBuildExt(build_ext): include_dirs.append(dir) # Check for various platform-specific directories - if platform == 'sunos5': + if platform == 'sunos': include_dirs.append('/usr/openwin/include') added_lib_dirs.append('/usr/openwin/lib') elif os.path.exists('/usr/X11R6/include'): @@ -1718,7 +1717,7 @@ class PyBuildExt(build_ext): # XXX Is this still needed? ## extra_link_args.extend(['-read_only_relocs', 'warning']) - elif sys.platform == 'sunos5': + elif sys.platform == 'sunos': # XXX This shouldn't be necessary; it appears that some # of the assembler code is non-PIC (i.e. it has relocations # when it shouldn't. The proper fix would be to rewrite @@ -1729,7 +1728,7 @@ class PyBuildExt(build_ext): # finding some -z option for the Sun compiler. extra_link_args.append('-mimpure-text') - elif sys.platform.startswith('hp-ux'): + elif sys.platform == 'hp-ux': extra_link_args.append('-fPIC') ext = Extension('_ctypes',