__future__ and unrecognised flags
tjreedy at udel.edu
Sat Dec 13 01:16:47 CET 2008
Poor Yorick wrote:
> I have a future statement in a script I intend to work on 2.6 and 3. Shouldn't __future__ statements basically be noops for versions that already support the feature? doctest is complaining about compiler flags. This illustrates the problem:
> Python 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MSC v.1500 32 bit (Intel)] on win
> 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
According to this "The optional arguments flags and dont_inherit control
which future statements (see PEP 236) affect the compilation of source.
If neither is present (or both are zero) the code is compiled with those
future statements that are in effect in the code that is calling
compile. " you do not need to duplicate the future option in the compile
I tried doing the same without the flag and it works. That said, this
seems like a bug to me, so if no one explains otherwise, report it at
I tried with 5th param True and got same error.
More information about the Python-list