From 9b24fd97b6602287e2f275642b7036a5a35364f7 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Thu, 3 Oct 2013 23:21:45 -0700 Subject: [PATCH] Fix self-assignment warnings. This is somewhat of a Gordian Knot approach, but seems to do the trick. --- Cython/Compiler/Code.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index 1f51f1f..c2f4af9 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -62,6 +62,8 @@ modifier_output_mapper = { 'inline': 'CYTHON_INLINE' }.get +is_self_assignment = re.compile(r" *(\w+) = (\1);\s*$").match + def get_utility_dir(): # make this a function and not global variables: @@ -1555,6 +1557,8 @@ class CCodeWriter(object): self.put(code) def put(self, code): + if is_self_assignment(code): + return fix_indent = False if "{" in code: dl = code.count("{") -- 2.7.4