[Python-Dev] Changing the Division Operator -- PEP 238, rev 1.12

Michael Hudson mwh@python.net
10 Aug 2001 10:08:50 -0400


Guido van Rossum <guido@python.org> writes:

> > It's a matter of interface, really.  It's certainly not at all
> > technically hard.  Maybe:
> > 
> >    compile(text, filename, symbol[, flags[, dont_inherit]])
> 
> Occam sez: let's add the dont_inherit argument when we have found a
> real use for it.

Fair enough.

> My bigger worry about this interface is that the flags accepted should
> be carefully checked to be from the small set related to future
> statements.  It would be harmful if the user could set flags like
> CO_OPTIMIZED, CO_GENERATOR, or CO_VARARGS this way!

Wrong set of flags!

There are two complementary sets of flags here:

(1) The PyCF_* ones, defined in Include/pythonrun.h
(2) The CO_* ones defined in Include/compile.h

The proposed fourth argument to compile() should be a combination of
the former set.

I only use the latter to tell whether a __future__ statement was used
in the text compiled (which is a bit horrible, but no better way
springs to mind).

There might be value in checking the flags passed to compile() anyway,
but I can't see it being dangerous.

Cheers,
M.

-- 
  You owe The Oracle a TV with an 'intelligence' control - I've 
  tried 'brightness' but that didn't work.
                                      -- Internet Oracularity #1192-01