You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
# cython: language_level=2 does not work as expected #2791
There seems to be a problem with handling # cython: language_level=2 when language_level=3str is set globally (for example, using the compiler_directives flag of cythonize()).
For some features like division, the Python 3 semantics are used anyway.
Example:
# cython: language_level=2
def test():
ver = 3
L = [ver for ver in [2]]
print(f"effective language_level for list comprehension: {ver}")
cdef object a = 3
ver = int((a / 2) * 2)
print(f"effective language_level for division: {ver}")
gives as output
>>> test()
effective language_level for list comprehension: 2
effective language_level for division: 3
Strangely enough, the opposite (# cython: language_level=3str when language_level=2 is set globally) works correctly.
Activity
jdemeyer commentedon Jan 9, 2019
The problems seems to be that
set_language_levelonly addsfuture_directivesbut it never removes any.jdemeyer commentedon Jan 9, 2019
PR coming...