[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.227,2.228

Tim Peters tim.one@home.com
Fri, 24 Aug 2001 18:26:13 -0400

> ! 	/* XXX Warn if (supplied_flags & PyCF_MASK_OBSOLETE) != 0? */

[Michael Hudson]
> I think not.
> If, as I *think*, all code objects compiled in 2.2 have
>    ob.co_flags & __future__.nested_scopes.compiler_flag
> non-zero, then, eg., idle will compile all code typed interactively
> (after the first line, anyway) with
> __future__.nested_scopes.compiler_flag in the supplied_flags argument
> to compile().  This could be wormed around, obviously, but I don't see
> the point.

Your belief was true of 2.2a1 but not of 2.2a2.  For 2.2a1, Guido simply
turned on nested_scopes by default (and so every code object had CO_NESTED
set).  For 2.2a2, Jeremy returned from paternity leave and took away the
*possibility* of turning nested scopes off.  As a result, the *only*
reference to CO_NESTED now in the C part of Python is in the #define of
PyCF_MASK_OBSOLETE, and Python itself never sets CO_NESTED.  That's part of
what I meant when I said (in a different recent thread) that any piece of
code using these flags is eventually going to get surprised:  these
implementation details are as internal and transient as they get.

This isn't critical now, but I can't help but notice that we've got 8 bit
positions assigned in the co_flags int.  One is meaningless in 2.2a2
(CO_NESTED), and two more will eventually become meaningless
running out of "real" co_flags bits, but so long as we're stuck *also* using
co_flags to communicate-- from caller to dynamically-compiled callee --which
still-optional future-features are in effect, we burn another bit position
every time we dream up a future-feature with semantic content.

So, but later rather than sooner, I expect we're going to have to recycle
these temporary future-feature co_flags bits.  When that happens, it may be
prudent to *warn* about obsolete flag values for a release cycle (before
recycling them), for the benefit of insane people who can't restrain
themselves from playing with undocumented bits <wink>.