[pypy-dev] html_fibo.py’s problem.

Kenji Yano kenji.yano at gmail.com
Mon Aug 1 07:25:26 CEST 2011


Hi

I found the cause of html_fibo.py at the EuroPython Hands-on.
This case, HtmlTag destructor isn’t call when the object didn’t use.
Is this garbage collection’s problem?
(pypy-trunk(1.6.0-dev) same too.)

===
def html_fibo(f):
    f.write('<ul>\n')
    try:
        for n in fibo():
            tag = HtmlTag(f, 4, 'li')
            yield n
            tag = None       # doesn’t call destructor here.
    finally:
        tag = None           # here, too.
        f.write('</ul>\n')

def write_file():
    f = open('fibo.txt', 'w')   # f.close does’nt call, too.
    for n in html_fibo(f):
        f.write('%d' % n)
        if n > 100:
            break

runing code and patch are the following link.(not pypy source code patch.)
https://gist.github.com/1117550

and is this problem in bugs.pypy.org? I can’nt found it.

Cheers.
Kenji


More information about the pypy-dev mailing list