42
42
argument to the builtin function compile() to enable the feature in
43
43
dynamically compiled code. This flag is stored in the .compiler_flag
44
44
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.
46
46
47
47
No feature line is ever to be deleted from this file.
48
48
"""
57
57
"unicode_literals" ,
58
58
"barry_as_FLUFL" ,
59
59
"generator_stop" ,
60
+ "annotations" ,
60
61
]
61
62
62
63
__all__ = ["all_feature_names" ] + all_feature_names
63
64
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
67
68
# 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
+
77
80
78
81
class _Feature :
82
+
79
83
def __init__ (self , optionalRelease , mandatoryRelease , compiler_flag ):
80
84
self .optional = optionalRelease
81
85
self .mandatory = mandatoryRelease
@@ -86,7 +90,6 @@ def getOptionalRelease(self):
86
90
87
91
This is a 5-tuple, of the same form as sys.version_info.
88
92
"""
89
-
90
93
return self .optional
91
94
92
95
def getMandatoryRelease (self ):
@@ -95,14 +98,14 @@ def getMandatoryRelease(self):
95
98
This is a 5-tuple, of the same form as sys.version_info, or, if
96
99
the feature was dropped, is None.
97
100
"""
98
-
99
101
return self .mandatory
100
102
101
103
def __repr__ (self ):
102
104
return "_Feature" + repr ((self .optional ,
103
105
self .mandatory ,
104
106
self .compiler_flag ))
105
107
108
+
106
109
nested_scopes = _Feature ((2 , 1 , 0 , "beta" , 1 ),
107
110
(2 , 2 , 0 , "alpha" , 0 ),
108
111
CO_NESTED )
@@ -132,9 +135,13 @@ def __repr__(self):
132
135
CO_FUTURE_UNICODE_LITERALS )
133
136
134
137
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 )
137
140
138
141
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