Skip to content

Change directive default to language_level=3 #2565

Closed

Description

@scoder

This is a breaking change that needs preparation. It changes the default semantics of the Cython language from Python 2 to Python 3.

Specifically, it will enable the __future__ imports division, print_function, absolute_import, and preferably also generator_stop (which became active in Python 3.7).

Excluding unicode_literals from the default setup seems like a good idea, as long as users want to continue supporting Python 2.x (and if they don't then it makes no difference for Py 3.x anyway). In this case, it is worth considering if f-strings should also be supported for Py2 str, although it might not be worth implementing this given the nearing end of life of Py2.

Users will be able to opt out of this by explicitly setting language_level=2. We should emit a warning in a prior release when no language level is specified.

Activity

  1. added this to the 3.0 milestone on Aug 18, 2018
  2. jdemeyer commented on Aug 21, 2018

    @jdemeyer
    Contributor

    As I mentioned on the mailing list, I would very much like to exclude from __future__ import unicode_literals (which is often considered a bad idea).

  3. scoder commented on Sep 16, 2018

    @scoder
    ContributorAuthor

    I agree that unicode_literals is a special case that is worth excluding. I updated the ticket description.

  4. fish2000 commented on Nov 29, 2018

    @fish2000

    Before this goes into effect, can someone address #2661 – in which setting language_level=3 breaks cimport statements that work fine under level 2?

  5. added
    Python3 Semantics[outdated] Python Semantics that differ specifically from Python 2.x
    and removed
    Python SemanticsGeneral Python (3) language semantics
    on Jan 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Python3 Semantics[outdated] Python Semantics that differ specifically from Python 2.x

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions