Skip to content

Commit 4170f58

Browse files
committed
2 parents fec6e4f + 2727c77 commit 4170f58

File tree

16,571 files changed

+2555110
-782070
lines changed

Some content is hidden

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

16,571 files changed

+2555110
-782070
lines changed

Diff for: addons/source-python/Python3/__future__.py

+28-21
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
to use the feature in question, but may continue to use such imports.
3434
3535
MandatoryRelease may also be None, meaning that a planned feature got
36-
dropped.
36+
dropped or that the release version is undetermined.
3737
3838
Instances of class _Feature have two corresponding methods,
3939
.getOptionalRelease() and .getMandatoryRelease().
@@ -42,7 +42,7 @@
4242
argument to the builtin function compile() to enable the feature in
4343
dynamically compiled code. This flag is stored in the .compiler_flag
4444
attribute on _Future instances. These values must match the appropriate
45-
#defines of CO_xxx flags in Include/compile.h.
45+
#defines of CO_xxx flags in Include/cpython/compile.h.
4646
4747
No feature line is ever to be deleted from this file.
4848
"""
@@ -57,25 +57,29 @@
5757
"unicode_literals",
5858
"barry_as_FLUFL",
5959
"generator_stop",
60+
"annotations",
6061
]
6162

6263
__all__ = ["all_feature_names"] + all_feature_names
6364

64-
# The CO_xxx symbols are defined here under the same names used by
65-
# compile.h, so that an editor search will find them here. However,
66-
# they're not exported in __all__, because they don't really belong to
65+
# The CO_xxx symbols are defined here under the same names defined in
66+
# code.h and used by compile.h, so that an editor search will find them here.
67+
# However, they're not exported in __all__, because they don't really belong to
6768
# this module.
68-
CO_NESTED = 0x0010 # nested_scopes
69-
CO_GENERATOR_ALLOWED = 0 # generators (obsolete, was 0x1000)
70-
CO_FUTURE_DIVISION = 0x2000 # division
71-
CO_FUTURE_ABSOLUTE_IMPORT = 0x4000 # perform absolute imports by default
72-
CO_FUTURE_WITH_STATEMENT = 0x8000 # with statement
73-
CO_FUTURE_PRINT_FUNCTION = 0x10000 # print function
74-
CO_FUTURE_UNICODE_LITERALS = 0x20000 # unicode string literals
75-
CO_FUTURE_BARRY_AS_BDFL = 0x40000
76-
CO_FUTURE_GENERATOR_STOP = 0x80000 # StopIteration becomes RuntimeError in generators
69+
CO_NESTED = 0x0010 # nested_scopes
70+
CO_GENERATOR_ALLOWED = 0 # generators (obsolete, was 0x1000)
71+
CO_FUTURE_DIVISION = 0x20000 # division
72+
CO_FUTURE_ABSOLUTE_IMPORT = 0x40000 # perform absolute imports by default
73+
CO_FUTURE_WITH_STATEMENT = 0x80000 # with statement
74+
CO_FUTURE_PRINT_FUNCTION = 0x100000 # print function
75+
CO_FUTURE_UNICODE_LITERALS = 0x200000 # unicode string literals
76+
CO_FUTURE_BARRY_AS_BDFL = 0x400000
77+
CO_FUTURE_GENERATOR_STOP = 0x800000 # StopIteration becomes RuntimeError in generators
78+
CO_FUTURE_ANNOTATIONS = 0x1000000 # annotations become strings at runtime
79+
7780

7881
class _Feature:
82+
7983
def __init__(self, optionalRelease, mandatoryRelease, compiler_flag):
8084
self.optional = optionalRelease
8185
self.mandatory = mandatoryRelease
@@ -86,23 +90,22 @@ def getOptionalRelease(self):
8690
8791
This is a 5-tuple, of the same form as sys.version_info.
8892
"""
89-
9093
return self.optional
9194

9295
def getMandatoryRelease(self):
9396
"""Return release in which this feature will become mandatory.
9497
9598
This is a 5-tuple, of the same form as sys.version_info, or, if
96-
the feature was dropped, is None.
99+
the feature was dropped, or the release date is undetermined, is None.
97100
"""
98-
99101
return self.mandatory
100102

101103
def __repr__(self):
102104
return "_Feature" + repr((self.optional,
103105
self.mandatory,
104106
self.compiler_flag))
105107

108+
106109
nested_scopes = _Feature((2, 1, 0, "beta", 1),
107110
(2, 2, 0, "alpha", 0),
108111
CO_NESTED)
@@ -132,9 +135,13 @@ def __repr__(self):
132135
CO_FUTURE_UNICODE_LITERALS)
133136

134137
barry_as_FLUFL = _Feature((3, 1, 0, "alpha", 2),
135-
(3, 9, 0, "alpha", 0),
136-
CO_FUTURE_BARRY_AS_BDFL)
138+
(4, 0, 0, "alpha", 0),
139+
CO_FUTURE_BARRY_AS_BDFL)
137140

138141
generator_stop = _Feature((3, 5, 0, "beta", 1),
139-
(3, 7, 0, "alpha", 0),
140-
CO_FUTURE_GENERATOR_STOP)
142+
(3, 7, 0, "alpha", 0),
143+
CO_FUTURE_GENERATOR_STOP)
144+
145+
annotations = _Feature((3, 7, 0, "beta", 1),
146+
None,
147+
CO_FUTURE_ANNOTATIONS)

Diff for: addons/source-python/Python3/__hello__.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
initialized = True
2+
3+
class TestFrozenUtf8_1:
4+
"""\u00b6"""
5+
6+
class TestFrozenUtf8_2:
7+
"""\u03c0"""
8+
9+
class TestFrozenUtf8_4:
10+
"""\U0001f600"""
11+
12+
def main():
13+
print("Hello world!")
14+
15+
if __name__ == '__main__':
16+
main()

Diff for: addons/source-python/Python3/__phello__.foo.py

-1
This file was deleted.

Diff for: addons/source-python/Python3/__phello__/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
initialized = True
2+
3+
def main():
4+
print("Hello world!")
5+
6+
if __name__ == '__main__':
7+
main()

Diff for: addons/source-python/Python3/__phello__/ham/__init__.py

Whitespace-only changes.

Diff for: addons/source-python/Python3/__phello__/ham/eggs.py

Whitespace-only changes.

Diff for: addons/source-python/Python3/__phello__/spam.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
initialized = True
2+
3+
def main():
4+
print("Hello world!")
5+
6+
if __name__ == '__main__':
7+
main()

Diff for: addons/source-python/Python3/_aix_support.py

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
"""Shared AIX support functions."""
2+
3+
import sys
4+
import sysconfig
5+
6+
7+
# Taken from _osx_support _read_output function
8+
def _read_cmd_output(commandstring, capture_stderr=False):
9+
"""Output from successful command execution or None"""
10+
# Similar to os.popen(commandstring, "r").read(),
11+
# but without actually using os.popen because that
12+
# function is not usable during python bootstrap.
13+
import os
14+
import contextlib
15+
fp = open("/tmp/_aix_support.%s"%(
16+
os.getpid(),), "w+b")
17+
18+
with contextlib.closing(fp) as fp:
19+
if capture_stderr:
20+
cmd = "%s >'%s' 2>&1" % (commandstring, fp.name)
21+
else:
22+
cmd = "%s 2>/dev/null >'%s'" % (commandstring, fp.name)
23+
return fp.read() if not os.system(cmd) else None
24+
25+
26+
def _aix_tag(vrtl, bd):
27+
# type: (List[int], int) -> str
28+
# Infer the ABI bitwidth from maxsize (assuming 64 bit as the default)
29+
_sz = 32 if sys.maxsize == (2**31-1) else 64
30+
_bd = bd if bd != 0 else 9988
31+
# vrtl[version, release, technology_level]
32+
return "aix-{:1x}{:1d}{:02d}-{:04d}-{}".format(vrtl[0], vrtl[1], vrtl[2], _bd, _sz)
33+
34+
35+
# extract version, release and technology level from a VRMF string
36+
def _aix_vrtl(vrmf):
37+
# type: (str) -> List[int]
38+
v, r, tl = vrmf.split(".")[:3]
39+
return [int(v[-1]), int(r), int(tl)]
40+
41+
42+
def _aix_bos_rte():
43+
# type: () -> Tuple[str, int]
44+
"""
45+
Return a Tuple[str, int] e.g., ['7.1.4.34', 1806]
46+
The fileset bos.rte represents the current AIX run-time level. It's VRMF and
47+
builddate reflect the current ABI levels of the runtime environment.
48+
If no builddate is found give a value that will satisfy pep425 related queries
49+
"""
50+
# All AIX systems to have lslpp installed in this location
51+
# subprocess may not be available during python bootstrap
52+
try:
53+
import subprocess
54+
out = subprocess.check_output(["/usr/bin/lslpp", "-Lqc", "bos.rte"])
55+
except ImportError:
56+
out = _read_cmd_output("/usr/bin/lslpp -Lqc bos.rte")
57+
out = out.decode("utf-8")
58+
out = out.strip().split(":") # type: ignore
59+
_bd = int(out[-1]) if out[-1] != '' else 9988
60+
return (str(out[2]), _bd)
61+
62+
63+
def aix_platform():
64+
# type: () -> str
65+
"""
66+
AIX filesets are identified by four decimal values: V.R.M.F.
67+
V (version) and R (release) can be retrieved using ``uname``
68+
Since 2007, starting with AIX 5.3 TL7, the M value has been
69+
included with the fileset bos.rte and represents the Technology
70+
Level (TL) of AIX. The F (Fix) value also increases, but is not
71+
relevant for comparing releases and binary compatibility.
72+
For binary compatibility the so-called builddate is needed.
73+
Again, the builddate of an AIX release is associated with bos.rte.
74+
AIX ABI compatibility is described as guaranteed at: https://www.ibm.com/\
75+
support/knowledgecenter/en/ssw_aix_72/install/binary_compatability.html
76+
77+
For pep425 purposes the AIX platform tag becomes:
78+
"aix-{:1x}{:1d}{:02d}-{:04d}-{}".format(v, r, tl, builddate, bitsize)
79+
e.g., "aix-6107-1415-32" for AIX 6.1 TL7 bd 1415, 32-bit
80+
and, "aix-6107-1415-64" for AIX 6.1 TL7 bd 1415, 64-bit
81+
"""
82+
vrmf, bd = _aix_bos_rte()
83+
return _aix_tag(_aix_vrtl(vrmf), bd)
84+
85+
86+
# extract vrtl from the BUILD_GNU_TYPE as an int
87+
def _aix_bgt():
88+
# type: () -> List[int]
89+
gnu_type = sysconfig.get_config_var("BUILD_GNU_TYPE")
90+
if not gnu_type:
91+
raise ValueError("BUILD_GNU_TYPE is not defined")
92+
return _aix_vrtl(vrmf=gnu_type)
93+
94+
95+
def aix_buildtag():
96+
# type: () -> str
97+
"""
98+
Return the platform_tag of the system Python was built on.
99+
"""
100+
# AIX_BUILDDATE is defined by configure with:
101+
# lslpp -Lcq bos.rte | awk -F: '{ print $NF }'
102+
build_date = sysconfig.get_config_var("AIX_BUILDDATE")
103+
try:
104+
build_date = int(build_date)
105+
except (ValueError, TypeError):
106+
raise ValueError(f"AIX_BUILDDATE is not defined or invalid: "
107+
f"{build_date!r}")
108+
return _aix_tag(_aix_bgt(), build_date)

0 commit comments

Comments
 (0)