Lisandro Dalcin wrote:
> On Wed, Oct 15, 2008 at 5:05 PM, Dag Sverre Seljebotn
> <[EMAIL PROTECTED]> wrote:
>> 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).
> 
> OK, I'll give a try, but perhaps tomorrow.
> 
>> 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"...)
> 
> Well, I'll try to make a good test case for all this. But the 'print
> foo1' will not work, as 'foo1' is not exported in the module dict, as
> it is cdef stuff (print foo2 in a doctest docstring will not work
> either).
> 

Ah right. Well my patch is a bad one then; it is the initialization to 
Py_None which should be removed instead.

Well, you seem to have a better grasp on this stuff than me so I'll 
leave it for you :-) You are right, it is optimization stuff going wrong 
-- "entry.used" isn't honoured by the code in ModuleNode.py initializing 
the entries to Py_None. Just search for the comments inserted in the 
.c-file at that point in ModuleNode.py and it will put you right on 
track for where to insert the if-test.

As for the tests, I suppose all of this is really difficult to test for 
(as possibly the doctests would interfer a lot with the refcount of 
Py_None and so on), so actually I'd agree with you if you didn't bother 
with them.

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to