Skip to content

Commit 40397a4

Browse files
authored
Merge pull request RustPython#3096 from RustPython/ast-3.9
__future__.annotations
2 parents cd2edbc + 4087fa1 commit 40397a4

Some content is hidden

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

53 files changed

+2867
-548
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/__future__.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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,7 +90,6 @@ 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):
@@ -95,14 +98,14 @@ def getMandatoryRelease(self):
9598
This is a 5-tuple, of the same form as sys.version_info, or, if
9699
the feature was dropped, 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+
(3, 11, 0, "alpha", 0),
147+
CO_FUTURE_ANNOTATIONS)

0 commit comments

Comments
 (0)