Tim Peters | ffc215a | 2001-02-26 21:14:49 +0000 | [diff] [blame] | 1 | """__future__: Record of phased-in incompatible language changes. |
| 2 | |
| 3 | Each line is of the form: |
| 4 | |
Tim Peters | fd85a4e | 2001-03-02 03:11:53 +0000 | [diff] [blame] | 5 | FeatureName = "_Feature(" OptionalRelease "," MandatoryRelease ")" |
Tim Peters | ffc215a | 2001-02-26 21:14:49 +0000 | [diff] [blame] | 6 | |
| 7 | where, normally, OptionalRelease < MandatoryRelease, and both are 5-tuples |
| 8 | of the same form as sys.version_info: |
| 9 | |
| 10 | (PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int |
| 11 | PY_MINOR_VERSION, # the 1; an int |
| 12 | PY_MICRO_VERSION, # the 0; an int |
| 13 | PY_RELEASE_LEVEL, # "alpha", "beta", "candidate" or "final"; string |
| 14 | PY_RELEASE_SERIAL # the 3; an int |
| 15 | ) |
| 16 | |
| 17 | OptionalRelease records the first release in which |
| 18 | |
| 19 | from __future__ import FeatureName |
| 20 | |
| 21 | was accepted. |
| 22 | |
Tim Peters | 85ba673 | 2001-02-28 08:26:44 +0000 | [diff] [blame] | 23 | In the case of MandatoryReleases that have not yet occurred, |
| 24 | MandatoryRelease predicts the release in which the feature will become part |
Tim Peters | ffc215a | 2001-02-26 21:14:49 +0000 | [diff] [blame] | 25 | of the language. |
| 26 | |
Tim Peters | 85ba673 | 2001-02-28 08:26:44 +0000 | [diff] [blame] | 27 | Else MandatoryRelease records when the feature became part of the language; |
Tim Peters | ffc215a | 2001-02-26 21:14:49 +0000 | [diff] [blame] | 28 | in releases at or after that, modules no longer need |
| 29 | |
| 30 | from __future__ import FeatureName |
| 31 | |
| 32 | to use the feature in question, but may continue to use such imports. |
| 33 | |
Tim Peters | 85ba673 | 2001-02-28 08:26:44 +0000 | [diff] [blame] | 34 | MandatoryRelease may also be None, meaning that a planned feature got |
Tim Peters | ffc215a | 2001-02-26 21:14:49 +0000 | [diff] [blame] | 35 | dropped. |
| 36 | |
Tim Peters | d74bc43 | 2001-03-02 02:53:08 +0000 | [diff] [blame] | 37 | Instances of class _Feature have two corresponding methods, |
| 38 | .getOptionalRelease() and .getMandatoryRelease(). |
| 39 | |
| 40 | No feature line is ever to be deleted from this file. |
Tim Peters | ffc215a | 2001-02-26 21:14:49 +0000 | [diff] [blame] | 41 | """ |
| 42 | |
Tim Peters | d74bc43 | 2001-03-02 02:53:08 +0000 | [diff] [blame] | 43 | class _Feature: |
| 44 | def __init__(self, optionalRelease, mandatoryRelease): |
| 45 | self.optional = optionalRelease |
| 46 | self.mandatory = mandatoryRelease |
| 47 | |
| 48 | def getOptionalRelease(self): |
| 49 | """Return first release in which this feature was recognized. |
| 50 | |
| 51 | This is a 5-tuple, of the same form as sys.version_info. |
| 52 | """ |
| 53 | |
| 54 | return self.optional |
| 55 | |
| 56 | def getMandatoryRelease(self): |
| 57 | """Return release in which this feature will become mandatory. |
| 58 | |
| 59 | This is a 5-tuple, of the same form as sys.version_info, or, if |
| 60 | the feature was dropped, is None. |
| 61 | """ |
| 62 | |
| 63 | return self.mandatory |
| 64 | |
| 65 | def __repr__(self): |
| 66 | return "Feature(" + `self.getOptionalRelease()` + ", " + \ |
| 67 | `self.getMandatoryRelease()` + ")" |
| 68 | |
| 69 | nested_scopes = _Feature((2, 1, 0, "beta", 1), (2, 2, 0, "final", 0)) |