mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
[doctest] fix a resources leak for the `doctest
` builder (#12044)
This commit is contained in:
parent
a7df31cfc6
commit
7f582a56ba
@ -311,6 +311,12 @@ class DocTestBuilder(Builder):
|
|||||||
'==================================%s\n') %
|
'==================================%s\n') %
|
||||||
(date, '=' * len(date)))
|
(date, '=' * len(date)))
|
||||||
|
|
||||||
|
def __del__(self) -> None:
|
||||||
|
# free resources upon destruction (the file handler might not be
|
||||||
|
# closed if the builder is never used)
|
||||||
|
if hasattr(self, 'outfile'):
|
||||||
|
self.outfile.close()
|
||||||
|
|
||||||
def _out(self, text: str) -> None:
|
def _out(self, text: str) -> None:
|
||||||
logger.info(text, nonl=True)
|
logger.info(text, nonl=True)
|
||||||
self.outfile.write(text)
|
self.outfile.write(text)
|
||||||
|
Loading…
Reference in New Issue
Block a user