From 29bb8d5196f40285fdeee3db50bfc2a1362c8f05 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Tue, 22 Sep 2009 00:59:48 -0700 Subject: [PATCH] String literal warning. --- Cython/Compiler/Errors.py | 14 ++++++++++++++ Cython/Compiler/ExprNodes.py | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/Errors.py b/Cython/Compiler/Errors.py index 1e7a44a3..dc51d061 100644 --- a/Cython/Compiler/Errors.py +++ b/Cython/Compiler/Errors.py @@ -145,6 +145,20 @@ def warning(position, message, level=0): echo_file.write(line) return warn +_warn_once_seen = {} +def warn_once(position, message, level=0): + if level < LEVEL or message in _warn_once_seen: + return + warn = CompileWarning(position, message) + line = "warning: %s\n" % warn + if listing_file: + listing_file.write(line) + if echo_file: + echo_file.write(line) + _warn_once_seen[message] = True + return warn + + # These functions can be used to momentarily suppress errors. error_stack = [] diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 6d649a43..f14f1817 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -4,7 +4,7 @@ import operator -from Errors import error, warning, InternalError +from Errors import error, warning, warn_once, InternalError from Errors import hold_errors, release_errors, held_errors, report_error from Cython.Utils import UtilityCode import StringEncoding @@ -942,6 +942,7 @@ class StringNode(ConstNode): # Arrange for a Python version of the string to be pre-allocated # when coercing to a Python type. if dst_type.is_pyobject and not self.type.is_pyobject: + warn_once(self.pos, "String literals will no longer be Py3 bytes in Cython 0.12.", 1) node = self.as_py_string_node(env) else: node = self -- 2.26.2