__future__ and compile: unrecognised flags

Rhamphoryncus rhamph at gmail.com
Sun Dec 14 09:46:01 CET 2008


On Dec 13, 6:03 am, Steve Holden <st... at holdenweb.com> wrote:
> Poor Yorick wrote:
> > I have a future statement in a script which is intended to work in 2.6 and 3.
> > Shouldn't compile flags in __future__ objects essentially be noops for versions
> > that already support the feature? doctest is complaining about unrecognised
> > flags.  This illustrates the problem:
>
> >     Python 3.0 (r30:67507, Dec  3 2008, 20:14:27) [MSC v.1500 32 bit (Intel)] on win
> >     32
> >     Type "help", "copyright", "credits" or "license" for more information.
> >     >>> from __future__ import unicode_literals
> >     >>> src = 'a = "hello"'
> >     >>> c1 = compile(src,'<string>','exec',unicode_literals.compiler_flag)
> >     Traceback (most recent call last):
> >       File "<stdin>", line 1, in <module>
> >     ValueError: compile(): unrecognised flags
>
> This could arguably be classed as a bug given that the 2.6 documentation
> for __future__ says "No feature description will ever be deleted from
> __future__." However I suspect that the feature has been removed because
> all string literals are Unicode in 3.0 and up, and 3.0 is allowed to
> break compatibility.

I don't think the rule about __future__ applies to compile().



More information about the Python-list mailing list