diff options
author | Daniel Andersson <daniel.4ndersson@gmail.com> | 2019-11-13 09:03:45 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2019-11-13 09:03:45 (GMT) |
commit | d89cea15ad37e873003fc74ec2c77660ab620b00 (patch) | |
tree | dedb513561770828daac5e08a7f3e2e1a54bad84 /Lib | |
parent | 9c2844927d15b2d3e21b28d62249dead02b5b597 (diff) | |
download | cpython-d89cea15ad37e873003fc74ec2c77660ab620b00.zip cpython-d89cea15ad37e873003fc74ec2c77660ab620b00.tar.gz cpython-d89cea15ad37e873003fc74ec2c77660ab620b00.tar.bz2 |
bpo-38781: Clear buffer in MemoryHandler flush (GH-17132)
This makes it easier to use a custom buffer when subclassing
MemoryHandler (by avoiding the explicity empty list literal
assignment in the flush method). For example, collection.deque
can now be used without any modifications to MemoryHandler.flush.
The same applies to BufferingHandler.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/logging/handlers.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index c1aec98..ea14541 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -1254,7 +1254,7 @@ class BufferingHandler(logging.Handler): """ self.acquire() try: - self.buffer = [] + self.buffer.clear() finally: self.release() @@ -1321,7 +1321,7 @@ class MemoryHandler(BufferingHandler): if self.target: for record in self.buffer: self.target.handle(record) - self.buffer = [] + self.buffer.clear() finally: self.release() |