summaryrefslogtreecommitdiff
path: root/Cython/Compiler/FlowControl.py
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2013-02-14 18:47:28 +0100
committerStefan Behnel <stefan_ml@behnel.de>2013-02-14 18:47:28 +0100
commit0b6577210a8fa40e3a3fe9fca7b9afa1c6a725fc (patch)
treeb6e460fbdbf3df42340dd41864b6a498b4ba9e74 /Cython/Compiler/FlowControl.py
parent6e4ccc8e9e471846a527babd949bf23acfa21224 (diff)
downloadcython-0b6577210a8fa40e3a3fe9fca7b9afa1c6a725fc.tar.gz
prevent unused '_' variables from appearing in C code
Diffstat (limited to 'Cython/Compiler/FlowControl.py')
-rw-r--r--Cython/Compiler/FlowControl.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/Cython/Compiler/FlowControl.py b/Cython/Compiler/FlowControl.py
index 22f226997..8ef14b140 100644
--- a/Cython/Compiler/FlowControl.py
+++ b/Cython/Compiler/FlowControl.py
@@ -615,17 +615,19 @@ def check_definitions(flow, compiler_directives):
# Unused entries
for entry in flow.entries:
- if (not entry.cf_references and not entry.is_pyclass_attr
- and not entry.in_closure
- and entry.name != '_'):
- if entry.is_arg:
- if warn_unused_arg:
- messages.warning(entry.pos, "Unused argument '%s'" %
- entry.name)
- else:
- if warn_unused:
- messages.warning(entry.pos, "Unused entry '%s'" %
- entry.name)
+ if (not entry.cf_references
+ and not entry.is_pyclass_attr
+ and not entry.in_closure):
+ if entry.name != '_':
+ # '_' is often used for unused variables, e.g. in loops
+ if entry.is_arg:
+ if warn_unused_arg:
+ messages.warning(entry.pos, "Unused argument '%s'" %
+ entry.name)
+ else:
+ if warn_unused:
+ messages.warning(entry.pos, "Unused entry '%s'" %
+ entry.name)
entry.cf_used = False
messages.report()