Re: __future__ and compile: unrecognised flags

Discussion in 'Python' started by Steve Holden, Dec 13, 2008.

  1. Steve Holden

    Steve Holden Guest

    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.

    One question is whether the 2to3 translator will remove such an import.
    If it does then one could argue this is just another of the many
    expected incompatibilities between 2.x and 3.x. If it doesn't, it should
    probably be made to.

    regards
    Steve
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC http://www.holdenweb.com/
    Steve Holden, Dec 13, 2008
    #1
    1. Advertising

  2. Re: __future__ and compile: unrecognised flags

    On Dec 13, 6:03 am, Steve Holden <> 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().
    Rhamphoryncus, Dec 14, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. red floyd
    Replies:
    0
    Views:
    394
    red floyd
    Aug 4, 2005
  2. Poor Yorick

    __future__ and unrecognised flags

    Poor Yorick, Dec 12, 2008, in forum: Python
    Replies:
    0
    Views:
    243
    Poor Yorick
    Dec 12, 2008
  3. Poor Yorick
    Replies:
    0
    Views:
    254
    Poor Yorick
    Dec 13, 2008
  4. Steve Holden
    Replies:
    0
    Views:
    753
    Steve Holden
    Feb 8, 2009
  5. dhyams
    Replies:
    7
    Views:
    104
    Neil Cerutti
    Jun 12, 2013
Loading...

Share This Page