termios disappears during object deletion

Brien Barton brien_barton at hotmail.com
Fri Sep 3 18:58:34 EDT 1999


Can anyone explain this behavior??  For some reason, the termios and TERMIOS
modules get wiped out when python is running the __del__ method during
program termination.  I've tried this with Python 1.5.1 on Linux and with
Python 1.5.2 on SGI IRIX.  If you explicitly delete the object, you don't
have this problem.

~> cat test.py
import math, termios, TERMIOS

print 'math=', math
print 'termios=', termios
print 'TERMIOS=', TERMIOS

class Test:
    def __del__(self):
        print 'deleting Test object ...'
        print 'math=', math
        print 'termios=', termios
        print 'TERMIOS=', TERMIOS

t = Test()


~> python test.py
math= <module 'math' from
'/usr/local/lib/python1.5/lib-dynload/mathmodule.so'>
termios= <module 'termios' from
'/usr/local/lib/python1.5/lib-dynload/termios.so
'>
TERMIOS= <module 'TERMIOS' from
'/usr/local/lib/python1.5/plat-irix646-32/TERMIO
S.pyc'>
deleting Test object ...
math= <module 'math' from
'/usr/local/lib/python1.5/lib-dynload/mathmodule.so'>
termios= None
TERMIOS= None
~>

-- Brien







More information about the Python-list mailing list