blob: 4cba7ed8026924554f7f875f92613f0cdb2005dd [file] [log] [blame]
Ka-Ping Yee3bda4f02001-03-15 10:45:44 +00001"""Record of phased-in incompatible language changes.
Tim Petersffc215a2001-02-26 21:14:49 +00002
3Each line is of the form:
4
Tim Petersfd85a4e2001-03-02 03:11:53 +00005 FeatureName = "_Feature(" OptionalRelease "," MandatoryRelease ")"
Tim Petersffc215a2001-02-26 21:14:49 +00006
7where, normally, OptionalRelease < MandatoryRelease, and both are 5-tuples
8of 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
17OptionalRelease records the first release in which
18
19 from __future__ import FeatureName
20
21was accepted.
22
Tim Peters85ba6732001-02-28 08:26:44 +000023In the case of MandatoryReleases that have not yet occurred,
24MandatoryRelease predicts the release in which the feature will become part
Tim Petersffc215a2001-02-26 21:14:49 +000025of the language.
26
Tim Peters85ba6732001-02-28 08:26:44 +000027Else MandatoryRelease records when the feature became part of the language;
Tim Petersffc215a2001-02-26 21:14:49 +000028in releases at or after that, modules no longer need
29
30 from __future__ import FeatureName
31
32to use the feature in question, but may continue to use such imports.
33
Tim Peters85ba6732001-02-28 08:26:44 +000034MandatoryRelease may also be None, meaning that a planned feature got
Tim Petersffc215a2001-02-26 21:14:49 +000035dropped.
36
Tim Petersd74bc432001-03-02 02:53:08 +000037Instances of class _Feature have two corresponding methods,
38.getOptionalRelease() and .getMandatoryRelease().
39
40No feature line is ever to be deleted from this file.
Tim Petersffc215a2001-02-26 21:14:49 +000041"""
42
Tim Petersd74bc432001-03-02 02:53:08 +000043class _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
Tim Petersc4889c42001-07-12 22:36:02 +000069nested_scopes = _Feature((2, 1, 0, "beta", 1), (2, 2, 0, "alpha", 0))
Guido van Rossumb09f7ed2001-07-15 21:08:29 +000070generators = _Feature((2, 2, 0, "alpha", 1), (2, 3, 0, "final", 0))
Guido van Rossum4668b002001-08-08 05:00:18 +000071division = _Feature((2, 2, 0, "alpha", 2), (3, 0, 0, "alpha", 0))