Commit 6e0e4e11 authored by Stefan Behnel's avatar Stefan Behnel

enable true division for language_level=3

parent 0bcc3c34
...@@ -20,6 +20,9 @@ Features added ...@@ -20,6 +20,9 @@ Features added
Bugs fixed Bugs fixed
---------- ----------
* Language level 3 did not enable true division (a.k.a. float division) for
integer operands.
* Runtime reported file paths of source files (e.g for profiling and tracing) * Runtime reported file paths of source files (e.g for profiling and tracing)
are now relative to the build root directory instead of the main source file. are now relative to the build root directory instead of the main source file.
......
...@@ -89,8 +89,8 @@ class Context(object): ...@@ -89,8 +89,8 @@ class Context(object):
def set_language_level(self, level): def set_language_level(self, level):
self.language_level = level self.language_level = level
if level >= 3: if level >= 3:
from .Future import print_function, unicode_literals, absolute_import from .Future import print_function, unicode_literals, absolute_import, division
self.future_directives.update([print_function, unicode_literals, absolute_import]) self.future_directives.update([print_function, unicode_literals, absolute_import, division])
self.modules['builtins'] = self.modules['__builtin__'] self.modules['builtins'] = self.modules['__builtin__']
# pipeline creation functions can now be found in Pipeline.py # pipeline creation functions can now be found in Pipeline.py
......
...@@ -27,6 +27,39 @@ def locals_function(a, b=2): ...@@ -27,6 +27,39 @@ def locals_function(a, b=2):
return locals() return locals()
### true division
def truediv(x):
"""
>>> truediv(4)
2.0
>>> truediv(3)
1.5
"""
return x / 2
def truediv_int(int x):
"""
>>> truediv_int(4)
2.0
>>> truediv_int(3)
1.5
"""
return x / 2
@cython.cdivision(True)
def cdiv_int(int x):
"""
>>> cdiv_int(4)
2
>>> cdiv_int(3)
1
"""
return x / 2
### module level except-as tests ### module level except-as tests
exc = [None] exc = [None]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment