This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ag6502
Recipients ag6502
Date 2008-03-02.13:55:44
SpamBayes Score 3.054658e-05
Marked as misclassified No
Message-id <1204466149.08.0.371697565628.issue2216@psf.upfronthosting.co.za>
In-reply-to
Content
I'm not a user of idle, but when asked about a strange behaviour of the
logging module I digged a bit and found what I think is indeed a problem
in the module itself.
The problem is visible if the module is used from idle (or any other IDE
that keeps the same python instance running for multiple execution of
user code); if you call basicConfig(filename="foo.txt"), do some logging
and call shutdown() the handler is closed (correctly closing the file)
but remains attached to the root logger, and gets called again at next
run (giving an error for invalid I/O on a closed file).
This can also be reproduced in a single run with

import logging
logging.basicConfig(filename="logtest.txt")
logging.warning("This is a test")
logging.shutdown()
logging.basicConfig(filename="logtest2.txt")
logging.warning("This is a test (2)")
logging.shutdown()

I think that it is not correct to close the handler but leave it in
place, so I tried patching the module so that every handler keeps a list
of all loggers it is attached to, and removes itself from loggers at
close() time. This way the above code runs correctly (creating two
files) and the logging module still passes the test suite.
I must however admit that logging logic is a bit beyond my grasp
(including a close() call commented out, some uses of lock/release I
don't understand) so may be the attached patch is not correct even if
passes the test.
History
Date User Action Args
2008-03-02 13:55:49ag6502setspambayes_score: 3.05466e-05 -> 3.054658e-05
recipients: + ag6502
2008-03-02 13:55:49ag6502setspambayes_score: 3.05466e-05 -> 3.05466e-05
messageid: <1204466149.08.0.371697565628.issue2216@psf.upfronthosting.co.za>
2008-03-02 13:55:47ag6502linkissue2216 messages
2008-03-02 13:55:46ag6502create