bpo-42504: Ensure that get_config_var('MACOSX_DEPLOYMENT_TARGET') is … · python/cpython@49926cf (original) (raw)
6 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -54,8 +54,8 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0): | ||
54 | 54 | global _cfg_target, _cfg_target_split |
55 | 55 | if _cfg_target is None: |
56 | 56 | from distutils import sysconfig |
57 | -_cfg_target = str(sysconfig.get_config_var( | |
58 | -'MACOSX_DEPLOYMENT_TARGET') or '') | |
57 | +_cfg_target = sysconfig.get_config_var( | |
58 | +'MACOSX_DEPLOYMENT_TARGET') or '' | |
59 | 59 | if _cfg_target: |
60 | 60 | _cfg_target_split = [int(x) for x in _cfg_target.split('.')] |
61 | 61 | if _cfg_target: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -456,7 +456,7 @@ def test_deployment_target_higher_ok(self): | ||
456 | 456 | deptarget = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') |
457 | 457 | if deptarget: |
458 | 458 | # increment the minor version number (i.e. 10.6 -> 10.7) |
459 | -deptarget = [int(x) for x in str(deptarget).split('.')] | |
459 | +deptarget = [int(x) for x in deptarget.split('.')] | |
460 | 460 | deptarget[-1] += 1 |
461 | 461 | deptarget = '.'.join(str(i) for i in deptarget) |
462 | 462 | self._try_compile_deployment_target('<', deptarget) |
@@ -489,7 +489,7 @@ def _try_compile_deployment_target(self, operator, target): | ||
489 | 489 | |
490 | 490 | # get the deployment target that the interpreter was built with |
491 | 491 | target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') |
492 | -target = tuple(map(int, str(target).split('.')[0:2])) | |
492 | +target = tuple(map(int, target.split('.')[0:2])) | |
493 | 493 | # format the target value as defined in the Apple |
494 | 494 | # Availability Macros. We can't use the macro names since |
495 | 495 | # at least one value we test with will not exist yet. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -18,6 +18,11 @@ | ||
18 | 18 | 'parse_config_h', |
19 | 19 | ] |
20 | 20 | |
21 | +# Keys for get_config_var() that are never converted to Python integers. | |
22 | +_ALWAYS_STR = { | |
23 | +'MACOSX_DEPLOYMENT_TARGET', | |
24 | +} | |
25 | + | |
21 | 26 | _INSTALL_SCHEMES = { |
22 | 27 | 'posix_prefix': { |
23 | 28 | 'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}', |
@@ -252,6 +257,9 @@ def _parse_makefile(filename, vars=None): | ||
252 | 257 | notdone[n] = v |
253 | 258 | else: |
254 | 259 | try: |
260 | +if n in _ALWAYS_STR: | |
261 | +raise ValueError | |
262 | + | |
255 | 263 | v = int(v) |
256 | 264 | except ValueError: |
257 | 265 | # insert literal `$' |
@@ -310,6 +318,8 @@ def _parse_makefile(filename, vars=None): | ||
310 | 318 | notdone[name] = value |
311 | 319 | else: |
312 | 320 | try: |
321 | +if name in _ALWAYS_STR: | |
322 | +raise ValueError | |
313 | 323 | value = int(value) |
314 | 324 | except ValueError: |
315 | 325 | done[name] = value.strip() |
@@ -472,6 +482,8 @@ def parse_config_h(fp, vars=None): | ||
472 | 482 | if m: |
473 | 483 | n, v = m.group(1, 2) |
474 | 484 | try: |
485 | +if n in _ALWAYS_STR: | |
486 | +raise ValueError | |
475 | 487 | v = int(v) |
476 | 488 | except ValueError: |
477 | 489 | pass |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1071,7 +1071,7 @@ def test_getgroups(self): | ||
1071 | 1071 | if sys.platform == 'darwin': |
1072 | 1072 | import sysconfig |
1073 | 1073 | dt = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') or '10.0' |
1074 | -if tuple(int(n) for n in str(dt).split('.')[0:2]) < (10, 6): | |
1074 | +if tuple(int(n) for n in dt.split('.')[0:2]) < (10, 6): | |
1075 | 1075 | raise unittest.SkipTest("getgroups(2) is broken prior to 10.6") |
1076 | 1076 | |
1077 | 1077 | # 'id -G' and 'os.getgroups()' should return the same |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
1 | +Ensure that the value of | |
2 | +sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') is always a string, | |
3 | +even in when the value is parsable as an integer. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1072,7 +1072,7 @@ def detect_readline_curses(self): | ||
1072 | 1072 | os_release = int(os.uname()[2].split('.')[0]) |
1073 | 1073 | dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') |
1074 | 1074 | if (dep_target and |
1075 | - (tuple(int(n) for n in str(dep_target).split('.')[0:2]) | |
1075 | + (tuple(int(n) for n in dep_target.split('.')[0:2]) | |
1076 | 1076 | < (10, 5) ) ): |
1077 | 1077 | os_release = 8 |
1078 | 1078 | if os_release < 9: |