[Python-checkins] CVS: python/dist/src/Lib __future__.py,1.8,1.9

Tim Peters tim_one@users.sourceforge.net
Fri, 17 Aug 2001 12:49:04 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv11086

Modified Files:
	__future__.py 
Log Message:
A self-contained piece of Michael Hudson's patch
    #449043 supporting __future__ in simulated shells
in support of PEP 264.

Much has changed from the patch version:
+ Repaired bad hex constant for nested_scopes.
+ Defined symbolic CO_xxx names so global search will find these uses.
+ Made the exported list of feature names explicit, instead of abusing
  __all__ for this purpose (and redefined __all__ accordingly).
+ Added gross .compiler_flag verification to test___future__.py, and
  reworked it a little to make use of the newly exported explicit list
  of feature names.


Index: __future__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/__future__.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** __future__.py	2001/08/08 05:00:17	1.8
--- __future__.py	2001/08/17 19:49:02	1.9
***************
*** 3,7 ****
  Each line is of the form:
  
!     FeatureName = "_Feature(" OptionalRelease "," MandatoryRelease ")"
  
  where, normally, OptionalRelease < MandatoryRelease, and both are 5-tuples
--- 3,8 ----
  Each line is of the form:
  
!     FeatureName = "_Feature(" OptionalRelease "," MandatoryRelease ","
!                               CompilerFlag ")"
  
  where, normally, OptionalRelease < MandatoryRelease, and both are 5-tuples
***************
*** 38,48 ****
  .getOptionalRelease() and .getMandatoryRelease().
  
  No feature line is ever to be deleted from this file.
  """
  
  class _Feature:
!     def __init__(self, optionalRelease, mandatoryRelease):
          self.optional = optionalRelease
          self.mandatory = mandatoryRelease
  
      def getOptionalRelease(self):
--- 39,73 ----
  .getOptionalRelease() and .getMandatoryRelease().
  
+ CompilerFlag is the (bitfield) flag that should be passed in the fourth
+ argument to the builtin function compile() to enable the feature in
+ dynamically compiled code.  This flag is stored in the .compiler_flag
+ attribute on _Future instances.  These values must match the appropriate
+ #defines of CO_xxx flags in Include/compile.h.
+ 
  No feature line is ever to be deleted from this file.
  """
  
+ all_feature_names = [
+     "nested_scopes",
+     "generators",
+     "division",
+ ]
+ 
+ __all__ = ["all_feature_names"] + all_feature_names
+ 
+ 
+ # The CO_xxx symbols are defined here under the same names used by
+ # compile.h, so that an editor search will find them here.  However,
+ # they're not exported in __all__, because they don't really belong to
+ # this module.
+ CO_NESTED            = 0x0010   # nested_scopes
+ CO_GENERATOR_ALLOWED = 0x1000   # generators
+ CO_FUTURE_DIVISION   = 0x2000   # division
+ 
  class _Feature:
!     def __init__(self, optionalRelease, mandatoryRelease, compiler_flag):
          self.optional = optionalRelease
          self.mandatory = mandatoryRelease
+         self.compiler_flag = compiler_flag
  
      def getOptionalRelease(self):
***************
*** 64,71 ****
  
      def __repr__(self):
!         return "Feature(" + `self.getOptionalRelease()` + ", " + \
!                             `self.getMandatoryRelease()` + ")"
  
! nested_scopes = _Feature((2, 1, 0, "beta", 1), (2, 2, 0, "alpha", 0))
! generators = _Feature((2, 2, 0, "alpha", 1), (2, 3, 0, "final", 0))
! division = _Feature((2, 2, 0, "alpha", 2), (3, 0, 0, "alpha", 0))
--- 89,104 ----
  
      def __repr__(self):
!         return "_Feature(" + `self.getOptionalRelease()` + ", " + \
!                              `self.getMandatoryRelease()` + ")"
  
! nested_scopes = _Feature((2, 1, 0, "beta",  1),
!                          (2, 2, 0, "alpha", 0),
!                          CO_NESTED)
! 
! generators = _Feature((2, 2, 0, "alpha", 1),
!                       (2, 3, 0, "final", 0),
!                       CO_GENERATOR_ALLOWED)
! 
! division = _Feature((2, 2, 0, "alpha", 2),
!                     (3, 0, 0, "alpha", 0),
!                     CO_FUTURE_DIVISION)