Change to flush and close logic to fix #1760556.
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 4bb8cf4..c7058d8 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -728,7 +728,8 @@
"""
Flushes the stream.
"""
- self.stream.flush()
+ if self.stream:
+ self.stream.flush()
def emit(self, record):
"""
@@ -778,9 +779,11 @@
"""
Closes the stream.
"""
- self.flush()
- self.stream.close()
- StreamHandler.close(self)
+ if self.stream:
+ self.flush()
+ self.stream.close()
+ StreamHandler.close(self)
+ self.stream = None
def _open(self):
"""