-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Milestone
Description
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.