| 1 | n/a | """Record of phased-in incompatible language changes. |
|---|
| 2 | n/a | |
|---|
| 3 | n/a | Each line is of the form: |
|---|
| 4 | n/a | |
|---|
| 5 | n/a | FeatureName = "_Feature(" OptionalRelease "," MandatoryRelease "," |
|---|
| 6 | n/a | CompilerFlag ")" |
|---|
| 7 | n/a | |
|---|
| 8 | n/a | where, normally, OptionalRelease < MandatoryRelease, and both are 5-tuples |
|---|
| 9 | n/a | of the same form as sys.version_info: |
|---|
| 10 | n/a | |
|---|
| 11 | n/a | (PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int |
|---|
| 12 | n/a | PY_MINOR_VERSION, # the 1; an int |
|---|
| 13 | n/a | PY_MICRO_VERSION, # the 0; an int |
|---|
| 14 | n/a | PY_RELEASE_LEVEL, # "alpha", "beta", "candidate" or "final"; string |
|---|
| 15 | n/a | PY_RELEASE_SERIAL # the 3; an int |
|---|
| 16 | n/a | ) |
|---|
| 17 | n/a | |
|---|
| 18 | n/a | OptionalRelease records the first release in which |
|---|
| 19 | n/a | |
|---|
| 20 | n/a | from __future__ import FeatureName |
|---|
| 21 | n/a | |
|---|
| 22 | n/a | was accepted. |
|---|
| 23 | n/a | |
|---|
| 24 | n/a | In the case of MandatoryReleases that have not yet occurred, |
|---|
| 25 | n/a | MandatoryRelease predicts the release in which the feature will become part |
|---|
| 26 | n/a | of the language. |
|---|
| 27 | n/a | |
|---|
| 28 | n/a | Else MandatoryRelease records when the feature became part of the language; |
|---|
| 29 | n/a | in releases at or after that, modules no longer need |
|---|
| 30 | n/a | |
|---|
| 31 | n/a | from __future__ import FeatureName |
|---|
| 32 | n/a | |
|---|
| 33 | n/a | to use the feature in question, but may continue to use such imports. |
|---|
| 34 | n/a | |
|---|
| 35 | n/a | MandatoryRelease may also be None, meaning that a planned feature got |
|---|
| 36 | n/a | dropped. |
|---|
| 37 | n/a | |
|---|
| 38 | n/a | Instances of class _Feature have two corresponding methods, |
|---|
| 39 | n/a | .getOptionalRelease() and .getMandatoryRelease(). |
|---|
| 40 | n/a | |
|---|
| 41 | n/a | CompilerFlag is the (bitfield) flag that should be passed in the fourth |
|---|
| 42 | n/a | argument to the builtin function compile() to enable the feature in |
|---|
| 43 | n/a | dynamically compiled code. This flag is stored in the .compiler_flag |
|---|
| 44 | n/a | attribute on _Future instances. These values must match the appropriate |
|---|
| 45 | n/a | #defines of CO_xxx flags in Include/compile.h. |
|---|
| 46 | n/a | |
|---|
| 47 | n/a | No feature line is ever to be deleted from this file. |
|---|
| 48 | n/a | """ |
|---|
| 49 | n/a | |
|---|
| 50 | n/a | all_feature_names = [ |
|---|
| 51 | n/a | "nested_scopes", |
|---|
| 52 | n/a | "generators", |
|---|
| 53 | n/a | "division", |
|---|
| 54 | n/a | "absolute_import", |
|---|
| 55 | n/a | "with_statement", |
|---|
| 56 | n/a | "print_function", |
|---|
| 57 | n/a | "unicode_literals", |
|---|
| 58 | n/a | "barry_as_FLUFL", |
|---|
| 59 | n/a | "generator_stop", |
|---|
| 60 | n/a | ] |
|---|
| 61 | n/a | |
|---|
| 62 | n/a | __all__ = ["all_feature_names"] + all_feature_names |
|---|
| 63 | n/a | |
|---|
| 64 | n/a | # The CO_xxx symbols are defined here under the same names used by |
|---|
| 65 | n/a | # compile.h, so that an editor search will find them here. However, |
|---|
| 66 | n/a | # they're not exported in __all__, because they don't really belong to |
|---|
| 67 | n/a | # this module. |
|---|
| 68 | n/a | CO_NESTED = 0x0010 # nested_scopes |
|---|
| 69 | n/a | CO_GENERATOR_ALLOWED = 0 # generators (obsolete, was 0x1000) |
|---|
| 70 | n/a | CO_FUTURE_DIVISION = 0x2000 # division |
|---|
| 71 | n/a | CO_FUTURE_ABSOLUTE_IMPORT = 0x4000 # perform absolute imports by default |
|---|
| 72 | n/a | CO_FUTURE_WITH_STATEMENT = 0x8000 # with statement |
|---|
| 73 | n/a | CO_FUTURE_PRINT_FUNCTION = 0x10000 # print function |
|---|
| 74 | n/a | CO_FUTURE_UNICODE_LITERALS = 0x20000 # unicode string literals |
|---|
| 75 | n/a | CO_FUTURE_BARRY_AS_BDFL = 0x40000 |
|---|
| 76 | n/a | CO_FUTURE_GENERATOR_STOP = 0x80000 # StopIteration becomes RuntimeError in generators |
|---|
| 77 | n/a | |
|---|
| 78 | n/a | class _Feature: |
|---|
| 79 | n/a | def __init__(self, optionalRelease, mandatoryRelease, compiler_flag): |
|---|
| 80 | n/a | self.optional = optionalRelease |
|---|
| 81 | n/a | self.mandatory = mandatoryRelease |
|---|
| 82 | n/a | self.compiler_flag = compiler_flag |
|---|
| 83 | n/a | |
|---|
| 84 | n/a | def getOptionalRelease(self): |
|---|
| 85 | n/a | """Return first release in which this feature was recognized. |
|---|
| 86 | n/a | |
|---|
| 87 | n/a | This is a 5-tuple, of the same form as sys.version_info. |
|---|
| 88 | n/a | """ |
|---|
| 89 | n/a | |
|---|
| 90 | n/a | return self.optional |
|---|
| 91 | n/a | |
|---|
| 92 | n/a | def getMandatoryRelease(self): |
|---|
| 93 | n/a | """Return release in which this feature will become mandatory. |
|---|
| 94 | n/a | |
|---|
| 95 | n/a | This is a 5-tuple, of the same form as sys.version_info, or, if |
|---|
| 96 | n/a | the feature was dropped, is None. |
|---|
| 97 | n/a | """ |
|---|
| 98 | n/a | |
|---|
| 99 | n/a | return self.mandatory |
|---|
| 100 | n/a | |
|---|
| 101 | n/a | def __repr__(self): |
|---|
| 102 | n/a | return "_Feature" + repr((self.optional, |
|---|
| 103 | n/a | self.mandatory, |
|---|
| 104 | n/a | self.compiler_flag)) |
|---|
| 105 | n/a | |
|---|
| 106 | n/a | nested_scopes = _Feature((2, 1, 0, "beta", 1), |
|---|
| 107 | n/a | (2, 2, 0, "alpha", 0), |
|---|
| 108 | n/a | CO_NESTED) |
|---|
| 109 | n/a | |
|---|
| 110 | n/a | generators = _Feature((2, 2, 0, "alpha", 1), |
|---|
| 111 | n/a | (2, 3, 0, "final", 0), |
|---|
| 112 | n/a | CO_GENERATOR_ALLOWED) |
|---|
| 113 | n/a | |
|---|
| 114 | n/a | division = _Feature((2, 2, 0, "alpha", 2), |
|---|
| 115 | n/a | (3, 0, 0, "alpha", 0), |
|---|
| 116 | n/a | CO_FUTURE_DIVISION) |
|---|
| 117 | n/a | |
|---|
| 118 | n/a | absolute_import = _Feature((2, 5, 0, "alpha", 1), |
|---|
| 119 | n/a | (3, 0, 0, "alpha", 0), |
|---|
| 120 | n/a | CO_FUTURE_ABSOLUTE_IMPORT) |
|---|
| 121 | n/a | |
|---|
| 122 | n/a | with_statement = _Feature((2, 5, 0, "alpha", 1), |
|---|
| 123 | n/a | (2, 6, 0, "alpha", 0), |
|---|
| 124 | n/a | CO_FUTURE_WITH_STATEMENT) |
|---|
| 125 | n/a | |
|---|
| 126 | n/a | print_function = _Feature((2, 6, 0, "alpha", 2), |
|---|
| 127 | n/a | (3, 0, 0, "alpha", 0), |
|---|
| 128 | n/a | CO_FUTURE_PRINT_FUNCTION) |
|---|
| 129 | n/a | |
|---|
| 130 | n/a | unicode_literals = _Feature((2, 6, 0, "alpha", 2), |
|---|
| 131 | n/a | (3, 0, 0, "alpha", 0), |
|---|
| 132 | n/a | CO_FUTURE_UNICODE_LITERALS) |
|---|
| 133 | n/a | |
|---|
| 134 | n/a | barry_as_FLUFL = _Feature((3, 1, 0, "alpha", 2), |
|---|
| 135 | n/a | (3, 9, 0, "alpha", 0), |
|---|
| 136 | n/a | CO_FUTURE_BARRY_AS_BDFL) |
|---|
| 137 | n/a | |
|---|
| 138 | n/a | generator_stop = _Feature((3, 5, 0, "beta", 1), |
|---|
| 139 | n/a | (3, 7, 0, "alpha", 0), |
|---|
| 140 | n/a | CO_FUTURE_GENERATOR_STOP) |
|---|