Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyximport of .py files should use language_level=3 in Python 3 #1288

Closed
robertwb opened this issue Sep 15, 2011 · 4 comments
Closed

pyximport of .py files should use language_level=3 in Python 3 #1288

robertwb opened this issue Sep 15, 2011 · 4 comments

Comments

@robertwb
Copy link
Contributor

When running under Python 3, any .py file that pyximport is triggered for can be expected to be in Python 3 syntax. Currently, pyximporting simply fails because of syntax errors because it does not configure the language level at all. Therefore, pyximport's import hook should automatically switch to -3 mode under Python 3 when compiling a .py file.

Note that the same is not true for .pyx files, which may or may not in Py3 syntax. So there should additionally be a way to configure the language level explicitly when installing the pyximport import hooks.

Migrated from http://trac.cython.org/ticket/733

@robertwb robertwb added this to the wishlist milestone Aug 16, 2016
@scoder scoder modified the milestones: wishlist, 3.0 Sep 22, 2018
@scoder scoder modified the milestones: 3.0, 0.17 Jan 12, 2019
@scoder
Copy link
Contributor

scoder commented Jan 12, 2019

This was already implemented in Cython 0.17 (8133605).

@scoder scoder closed this as completed Jan 12, 2019
@hermidalc
Copy link

Unless I'm doing something wrong, as of 0.29.7 this is still not implemented at least when using pyximport. If you do not specify the language_level manually it gives you the FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! even though it should know it's using Python 3.x.

@scoder
Copy link
Contributor

scoder commented May 6, 2019

@hermidalc are you sure you are referring to .py files? The automatic setting does not apply to .pyx files.

if language_level is None:
language_level = sys.version_info[0]

@hermidalc
Copy link

@hermidalc are you sure you are referring to .py files? The automatic setting does not apply to .pyx files.

if language_level is None:
language_level = sys.version_info[0]

Ok, sorry didn't know that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants