summaryrefslogtreecommitdiff
path: root/Cython/Compiler/Main.py
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2018-09-29 09:22:31 +0200
committerStefan Behnel <stefan_ml@behnel.de>2018-09-29 09:26:49 +0200
commit7f638bcbd507f3d128d3221a398d193201c0ddad (patch)
tree40bb804fd2d9fa8f3f9eadc8c7f45a4e00b4c0ed /Cython/Compiler/Main.py
parentba9d273aa7526b179dc4f5cb6b65ceedc5b41210 (diff)
downloadcython-cy3str.tar.gz
Remove the new 'str_is_str' directive again and replace it by a new "language_level=3str" that resembles "language_level=3" but keeps unprefixed string literals and the 'str' builtin type unchanged.cy3str
See #2565.
Diffstat (limited to 'Cython/Compiler/Main.py')
-rw-r--r--Cython/Compiler/Main.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py
index 1dfc4baf1..0f1ff4d33 100644
--- a/Cython/Compiler/Main.py
+++ b/Cython/Compiler/Main.py
@@ -94,23 +94,24 @@ class Context(object):
if language_level is not None:
self.set_language_level(language_level)
- if self.compiler_directives.get('str_is_str') is not None:
- self.set_str_is_str(self.compiler_directives['str_is_str'])
self.gdb_debug_outputwriter = None
- def set_str_is_str(self, str_is_str):
- from .Future import unicode_literals
- if str_is_str:
+ def set_language_level(self, level):
+ from .Future import print_function, unicode_literals, absolute_import, division
+ future_directives = []
+ if level == '3str':
+ future_directives = [print_function, absolute_import, division]
self.future_directives.discard(unicode_literals)
+ level = 3
else:
- self.future_directives.add(unicode_literals)
-
- def set_language_level(self, level):
+ level = int(level)
+ if level >= 3:
+ future_directives = [print_function, unicode_literals, absolute_import, division]
self.language_level = level
+ if future_directives:
+ self.future_directives.update(future_directives)
if level >= 3:
- from .Future import print_function, unicode_literals, absolute_import, division
- self.future_directives.update([print_function, unicode_literals, absolute_import, division])
self.modules['builtins'] = self.modules['__builtin__']
def intern_ustring(self, value, encoding=None):