Skip to content

Commit 0a8bce0

Browse files
authored
Merge pull request python#13 from paulmon/win-arm32-fixes
fix importlib and distutils formatting of platform tag for ARM
2 parents f01f3c6 + 1e2d615 commit 0a8bce0

File tree

111 files changed

+249
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+249
-257
lines changed

Lib/_osx_support.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _find_executable(executable, path=None):
3838
paths = path.split(os.pathsep)
3939
base, ext = os.path.splitext(executable)
4040

41-
if (sys.platform.startswith('win')) and (ext != '.exe'):
41+
if (sys.platform == 'win32') and (ext != '.exe'):
4242
executable = executable + '.exe'
4343

4444
if not os.path.isfile(executable):

Lib/_pyio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import sys
1111
# Import _thread instead of threading to reduce startup cost
1212
from _thread import allocate_lock as Lock
13-
if sys.platform in {'win32', 'win-arm', 'cygwin'}:
13+
if sys.platform in {'win32', 'cygwin'}:
1414
from msvcrt import setmode as _setmode
1515
else:
1616
_setmode = None

Lib/asyncio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
tasks.__all__ +
3636
transports.__all__)
3737

38-
if sys.platform.startswith('win'): # pragma: no cover
38+
if sys.platform == 'win32': # pragma: no cover
3939
from .windows_events import *
4040
__all__ += windows_events.__all__
4141
else:

Lib/asyncio/unix_events.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
)
3333

3434

35-
if sys.platform.startswith('win'): # pragma: no cover
35+
if sys.platform == 'win32': # pragma: no cover
3636
raise ImportError('Signals are not really supported on Windows')
3737

3838

Lib/asyncio/windows_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import sys
44

5-
if not sys.platform.startswith('win'): # pragma: no cover
5+
if sys.platform != 'win32': # pragma: no cover
66
raise ImportError('win32 only')
77

88
import _winapi

Lib/ctypes/test/test_bytes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class X(Structure):
5252
self.assertEqual(x.a, "abc")
5353
self.assertEqual(type(x.a), str)
5454

55-
@unittest.skipUnless(sys.platform.startswith("win"), 'Windows-specific test')
55+
@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
5656
def test_BSTR(self):
5757
from _ctypes import _SimpleCData
5858
class BSTR(_SimpleCData):

Lib/ctypes/test/test_find.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Test_OpenGL_libs(unittest.TestCase):
1010
@classmethod
1111
def setUpClass(cls):
1212
lib_gl = lib_glu = lib_gle = None
13-
if sys.platform.startswith("win"):
13+
if sys.platform == "win32":
1414
lib_gl = find_library("OpenGL32")
1515
lib_glu = find_library("Glu32")
1616
elif sys.platform == "darwin":

Lib/ctypes/test/test_functions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import _ctypes_test
1919
dll = CDLL(_ctypes_test.__file__)
20-
if sys.platform.startswith("win"):
20+
if sys.platform == "win32":
2121
windll = WinDLL(_ctypes_test.__file__)
2222

2323
class POINT(Structure):
@@ -341,7 +341,7 @@ class S2H(Structure):
341341
s2h = dll.ret_2h_func(inp)
342342
self.assertEqual((s2h.x, s2h.y), (99*2, 88*3))
343343

344-
@unittest.skipUnless(sys.platform.startswith("win"), 'Windows-specific test')
344+
@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
345345
def test_struct_return_2H_stdcall(self):
346346
class S2H(Structure):
347347
_fields_ = [("x", c_short),
@@ -369,7 +369,7 @@ class S8I(Structure):
369369
self.assertEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h),
370370
(9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9))
371371

372-
@unittest.skipUnless(sys.platform.startswith("win"), 'Windows-specific test')
372+
@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
373373
def test_struct_return_8H_stdcall(self):
374374
class S8I(Structure):
375375
_fields_ = [("a", c_int),

Lib/ctypes/test/test_pointers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def test_pointers_bool(self):
192192
self.assertEqual(bool(CFUNCTYPE(None)(42)), True)
193193

194194
# COM methods are boolean True:
195-
if sys.platform.startswith("win"):
195+
if sys.platform == "win32":
196196
mth = WINFUNCTYPE(None)(42, "name", (), None)
197197
self.assertEqual(bool(mth), True)
198198

Lib/ctypes/test/test_random_things.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def callback_func(arg):
55
42 / arg
66
raise ValueError(arg)
77

8-
@unittest.skipUnless(sys.platform.startswith("win"), 'Windows-specific test')
8+
@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
99
class call_function_TestCase(unittest.TestCase):
1010
# _ctypes.call_function is deprecated and private, but used by
1111
# Gary Bishp's readline module. If we have it, we must test it as well.

Lib/ctypes/test/test_win32.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import _ctypes_test
88

99
# Only windows 32-bit has different calling conventions.
10-
@unittest.skipUnless(sys.platform.startswith("win"), 'Windows-specific test')
10+
@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
1111
@unittest.skipUnless(sizeof(c_void_p) == sizeof(c_int),
1212
"sizeof c_void_p and c_int differ")
1313
class WindowsTestCase(unittest.TestCase):
@@ -37,7 +37,7 @@ def test_callconv_2(self):
3737
# (4 bytes missing) or wrong calling convention
3838
self.assertRaises(ValueError, IsWindow, None)
3939

40-
@unittest.skipUnless(sys.platform.startswith("win"), 'Windows-specific test')
40+
@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
4141
class FunctionCallTestCase(unittest.TestCase):
4242
@unittest.skipUnless('MSC' in sys.version, "SEH only supported by MSC")
4343
@unittest.skipIf(sys.executable.lower().endswith('_d.exe'),
@@ -56,7 +56,7 @@ def test_noargs(self):
5656
windll.user32.GetDesktopWindow()
5757

5858

59-
@unittest.skipUnless(sys.platform.startswith("win"), 'Windows-specific test')
59+
@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
6060
class TestWintypes(unittest.TestCase):
6161
def test_HWND(self):
6262
from ctypes import wintypes
@@ -80,7 +80,7 @@ def test_COMError(self):
8080
self.assertEqual(ex.text, "text")
8181
self.assertEqual(ex.details, ("details",))
8282

83-
@unittest.skipUnless(sys.platform.startswith("win"), 'Windows-specific test')
83+
@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
8484
class TestWinError(unittest.TestCase):
8585
def test_winerror(self):
8686
# see Issue 16169

Lib/distutils/archive_util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _set_uid_gid(tarinfo):
115115
warn("'compress' will be deprecated.", PendingDeprecationWarning)
116116
# the option varies depending on the platform
117117
compressed_name = archive_name + compress_ext[compress]
118-
if sys.platform.startswith('win'):
118+
if sys.platform == 'win32':
119119
cmd = [compress, archive_name, compressed_name]
120120
else:
121121
cmd = [compress, '-f', archive_name]

Lib/distutils/command/bdist_wininst.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def finalize_options(self):
110110
% self.install_script)
111111

112112
def run(self):
113-
if (not sys.platform.startswith("win") and
113+
if (sys.platform != "win32" and
114114
(self.distribution.has_ext_modules() or
115115
self.distribution.has_c_libraries())):
116116
raise DistutilsPlatformError \

Lib/distutils/command/build_ext.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ def get_libraries(self, ext):
702702
# pyconfig.h that MSVC groks. The other Windows compilers all seem
703703
# to need it mentioned explicitly, though, so that's what we do.
704704
# Append '_d' to the python import library on debug builds.
705-
if sys.platform.startswith("win"):
705+
if sys.platform == "win32":
706706
from distutils._msvccompiler import MSVCCompiler
707707
if not isinstance(self.compiler, MSVCCompiler):
708708
template = "python%d%d"

Lib/distutils/command/sdist.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def prune_file_list(self):
364364
self.filelist.exclude_pattern(None, prefix=build.build_base)
365365
self.filelist.exclude_pattern(None, prefix=base_dir)
366366

367-
if sys.platform.startswith('win'):
367+
if sys.platform == 'win32':
368368
seps = r'/|\\'
369369
else:
370370
seps = '/'

Lib/distutils/msvc9compiler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
winreg.HKEY_LOCAL_MACHINE,
3737
winreg.HKEY_CLASSES_ROOT)
3838

39-
NATIVE_WIN64 = (sys.platform.startswith('win') and sys.maxsize > 2**32)
39+
NATIVE_WIN64 = (sys.platform == 'win32' and sys.maxsize > 2**32)
4040
if NATIVE_WIN64:
4141
# Visual C++ is a 32-bit application, so we need to look in
4242
# the corresponding registry branch, if we're running a

Lib/distutils/spawn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def find_executable(executable, path=None):
178178
paths = path.split(os.pathsep)
179179
base, ext = os.path.splitext(executable)
180180

181-
if (sys.platform.startswith('win')) and (ext != '.exe'):
181+
if (sys.platform == 'win32') and (ext != '.exe'):
182182
executable = executable + '.exe'
183183

184184
if not os.path.isfile(executable):

Lib/distutils/tests/test_bdist_msi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from distutils.tests import support
77

88

9-
SKIP_MESSAGE = (None if sys.platform.startswith("win") and not platform.win32_is_iot() else
9+
SKIP_MESSAGE = (None if sys.platform == 'win32' and not platform.win32_is_iot() else
1010
"These tests require Windows x86 or x64. Windows IoT Core and nanoserver are not supported")
1111

1212
@unittest.skipUnless(SKIP_MESSAGE is None, SKIP_MESSAGE)

Lib/distutils/tests/test_build_clib.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def test_finalize_options(self):
102102
cmd.distribution.libraries = 'WONTWORK'
103103
self.assertRaises(DistutilsSetupError, cmd.finalize_options)
104104

105-
@unittest.skipIf(sys.platform.startswith('win'), "can't test on Windows")
105+
@unittest.skipIf(sys.platform == 'win32', "can't test on Windows")
106106
def test_run(self):
107107
pkg_dir, dist = self.create_dist()
108108
cmd = build_clib(dist)

Lib/distutils/tests/test_config_cmd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_dump_file(self):
3737
dump_file(this_file, 'I am the header')
3838
self.assertEqual(len(self._logs), numlines+1)
3939

40-
@unittest.skipIf(sys.platform.startswith('win'), "can't test on Windows")
40+
@unittest.skipIf(sys.platform == 'win32', "can't test on Windows")
4141
def test_search_cpp(self):
4242
cmd = missing_compiler_executable(['preprocessor'])
4343
if cmd is not None:

Lib/distutils/tests/test_dist.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def test_custom_pydistutils(self):
461461
self.assertIn(user_filename, files)
462462

463463
# win32-style
464-
if sys.platform.startswith('win'):
464+
if sys.platform == 'win32':
465465
# home drive should be found
466466
os.environ['HOME'] = temp_dir
467467
files = dist.find_config_files()

Lib/distutils/tests/test_msvc9compiler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
</dependency>
9292
</assembly>"""
9393

94-
if sys.platform.startswith("win") and not platform.win32_is_iot():
94+
if sys.platform=="win32" and not platform.win32_is_iot():
9595
from distutils.msvccompiler import get_build_version
9696
if get_build_version()>=8.0:
9797
SKIP_MESSAGE = None

Lib/distutils/tests/test_msvccompiler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from test.support import run_unittest
1010

1111

12-
SKIP_MESSAGE = (None if sys.platform.startswith("win") and not platform.win32_is_iot() else
12+
SKIP_MESSAGE = (None if sys.platform == "win32" and not platform.win32_is_iot() else
1313
"These tests require Windows x86 or x64. Windows IoT Core and nanoserver are not supported")
1414

1515
@unittest.skipUnless(SKIP_MESSAGE is None, SKIP_MESSAGE)

Lib/distutils/tests/test_spawn.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_spawn(self):
3030

3131
# creating something executable
3232
# through the shell that returns 1
33-
if not sys.platform.startswith('win'):
33+
if sys.platform != 'win32':
3434
exe = os.path.join(tmpdir, 'foo.sh')
3535
self.write_file(exe, '#!%s\nexit 1' % unix_shell)
3636
else:
@@ -41,7 +41,7 @@ def test_spawn(self):
4141
self.assertRaises(DistutilsExecError, spawn, [exe])
4242

4343
# now something that works
44-
if not sys.platform.startswith('win'):
44+
if sys.platform != 'win32':
4545
exe = os.path.join(tmpdir, 'foo.sh')
4646
self.write_file(exe, '#!%s\nexit 0' % unix_shell)
4747
else:

Lib/distutils/tests/test_unixccompiler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def tearDown(self):
2020
sys.platform = self._backup_platform
2121
sysconfig.get_config_var = self._backup_get_config_var
2222

23-
@unittest.skipIf(sys.platform.startswith('win'), "can't test on Windows")
23+
@unittest.skipIf(sys.platform == 'win32', "can't test on Windows")
2424
def test_runtime_libdir_option(self):
2525
# Issue#5900
2626
#

Lib/distutils/util.py

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def get_platform ():
3838
if os.name == 'nt':
3939
if 'amd64' in sys.version.lower():
4040
return 'win-amd64'
41+
if 'arm' in sys.version.lower():
42+
return 'win-arm'
4143
return sys.platform
4244

4345
# Set for cross builds explicitly

Lib/encodings/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def search_function(encoding):
155155
# Register the search_function in the Python codec registry
156156
codecs.register(search_function)
157157

158-
if sys.platform.startswith('win'):
158+
if sys.platform == 'win32':
159159
def _alias_mbcs(encoding):
160160
try:
161161
import _winapi

Lib/idlelib/iomenu.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
pass
2626

2727
locale_decode = 'ascii'
28-
if sys.platform.startswith('win'):
28+
if sys.platform == 'win32':
2929
# On Windows, we could use "mbcs". However, to give the user
3030
# a portable encoding name, we need to find the code page
3131
try:

Lib/idlelib/pyshell.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Valid arguments for the ...Awareness call below are defined in the following.
1313
# https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx
14-
if sys.platform.startswith('win'):
14+
if sys.platform == 'win32':
1515
import ctypes
1616
PROCESS_SYSTEM_DPI_AWARE = 1
1717
try:

Lib/idlelib/zoomheight.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def zoom_height(top):
2525
return
2626
width, height, x, y = map(int, m.groups())
2727
newheight = top.winfo_screenheight()
28-
if sys.platform.startswith('win'):
28+
if sys.platform == 'win32':
2929
newy = 0
3030
newheight = newheight - 72
3131

Lib/locale.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
547547
pass
548548
else:
549549
# make sure the code/encoding values are valid
550-
if sys.platform.startswith("win") and code and code[:2] == "0x":
550+
if sys.platform == "win32" and code and code[:2] == "0x":
551551
# map windows language identifier to language name
552552
code = windows_locale.get(int(code, 0))
553553
# ...add other platform-specific processing here, if

Lib/multiprocessing/connection.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import _winapi
3131
from _winapi import WAIT_OBJECT_0, WAIT_ABANDONED_0, WAIT_TIMEOUT, INFINITE
3232
except ImportError:
33-
if sys.platform.startswith('win'):
33+
if sys.platform == 'win32':
3434
raise
3535
_winapi = None
3636

@@ -51,7 +51,7 @@
5151
default_family = 'AF_UNIX'
5252
families += ['AF_UNIX']
5353

54-
if sys.platform.startswith('win'):
54+
if sys.platform == 'win32':
5555
default_family = 'AF_PIPE'
5656
families += ['AF_PIPE']
5757

@@ -84,10 +84,10 @@ def _validate_family(family):
8484
'''
8585
Checks if the family is valid for the current environment.
8686
'''
87-
if not sys.platform.startswith('win') and family == 'AF_PIPE':
87+
if sys.platform != 'win32' and family == 'AF_PIPE':
8888
raise ValueError('Family %s is not recognized.' % family)
8989

90-
if sys.platform.startswith('win') and family == 'AF_UNIX':
90+
if sys.platform == 'win32' and family == 'AF_UNIX':
9191
# double check
9292
if not hasattr(socket, family):
9393
raise ValueError('Family %s is not recognized.' % family)
@@ -501,7 +501,7 @@ def Client(address, family=None, authkey=None):
501501
return c
502502

503503

504-
if not sys.platform.startswith('win'):
504+
if sys.platform != 'win32':
505505

506506
def Pipe(duplex=True):
507507
'''
@@ -623,7 +623,7 @@ def SocketClient(address):
623623
# Definitions for connections based on named pipes
624624
#
625625

626-
if sys.platform.startswith('win'):
626+
if sys.platform == 'win32':
627627

628628
class PipeListener(object):
629629
'''
@@ -789,7 +789,7 @@ def XmlClient(*args, **kwds):
789789
# Wait
790790
#
791791

792-
if sys.platform.startswith('win'):
792+
if sys.platform == 'win32':
793793

794794
def _exhaustive_wait(handles, timeout):
795795
# Return ALL handles which are currently signalled. (Only
@@ -930,7 +930,7 @@ def wait(object_list, timeout=None):
930930
# Make connection and socket objects sharable if possible
931931
#
932932

933-
if sys.platform.startswith('win'):
933+
if sys.platform == 'win32':
934934
def reduce_connection(conn):
935935
handle = conn.fileno()
936936
with socket.fromfd(handle, socket.AF_INET, socket.SOCK_STREAM) as s:

0 commit comments

Comments
 (0)