Lisandro Dalcin wrote:
This look nicer. However, there is still something that does not work.
Try to compile the following:
cdef object foo1
cdef object foo2 = []
and then you will see that the declaration of the (unused) 'foo1' is
not ever emited in the module declaration part. Some optimization
should be playing games. Or perhaps 'foo1' should be completely
ignored and never declared/initialized/cleaned-up?
I believe this is an unrelated and long-standing bug?
Anyway, the following patch should fix it (unless we want the opposite
behaviour).
Will you commit it together with your testcase? (I.e. try to print
"foo1" from a doctest, which is only in a string and so will trigger
this case, and it should be "None"...)
--
Dag Sverre
diff -r 2dbb7b8520a5 Cython/Compiler/Symtab.py
--- a/Cython/Compiler/Symtab.py Wed Oct 15 21:48:31 2008 +0200
+++ b/Cython/Compiler/Symtab.py Wed Oct 15 22:04:53 2008 +0200
@@ -935,6 +935,11 @@ class ModuleScope(Scope):
else:
entry.is_cglobal = 1
self.var_entries.append(entry)
+ if entry.type.is_pyobject:
+ # A Python variable declared in the module scope is always
+ # implicitly set to None, and can be used by the client of
+ # the module.
+ entry.used = True
return entry
def declare_global(self, name, pos):
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev