From 951b7cf45a331d01c439f5c29dfda66d55a9b316 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 12 Jun 2026 07:28:08 +0000 Subject: [PATCH] fix: close log file handlers before unlink on Windows (v2.6.2) Windows holds file locks on open log handlers; os.unlink() fails with PermissionError. Close and remove handlers in finally blocks. https://claude.ai/code/session_01XT6iUWaQgahXDB9TWX9Bq7 --- data_masking.py | 2 +- masking/constants.py | 2 +- tests/test_masking_logger.py | 6 ++++++ unmasking/cli.py | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/data_masking.py b/data_masking.py index fcf6498..90dbf83 100644 --- a/data_masking.py +++ b/data_masking.py @@ -30,7 +30,7 @@ # Re-exports from masking package for backward compatibility # ============================================================================ -__version__ = "2.6.1" +__version__ = "2.6.2" from masking.constants import ( __version__, __author__, __contact__, __phone__, __license__, __year__, diff --git a/masking/constants.py b/masking/constants.py index 343176a..3f73131 100644 --- a/masking/constants.py +++ b/masking/constants.py @@ -26,7 +26,7 @@ # ============================================================================ # МЕТАДАНІ # ============================================================================ -__version__ = "2.6.1" +__version__ = "2.6.2" __author__ = "Vladyslav V. Prodan" __contact__ = "github.com/click0" __phone__ = "+38(099)6053340" diff --git a/tests/test_masking_logger.py b/tests/test_masking_logger.py index 0802a74..cde6957 100644 --- a/tests/test_masking_logger.py +++ b/tests/test_masking_logger.py @@ -132,6 +132,9 @@ def test_file_logging(self): content = f.read() assert "file test message" in content finally: + for handler in ml.logger.handlers[:]: + handler.close() + ml.logger.removeHandler(handler) os.unlink(log_path) def test_stats_tracking(self): @@ -159,4 +162,7 @@ def test_setup_with_file(self): logger = setup_logging(level="INFO", log_file=log_path) assert logger is not None finally: + for handler in logger.logger.handlers[:]: + handler.close() + logger.logger.removeHandler(handler) os.unlink(log_path) diff --git a/unmasking/cli.py b/unmasking/cli.py index 4d21c9a..538e833 100644 --- a/unmasking/cli.py +++ b/unmasking/cli.py @@ -58,7 +58,7 @@ # ============================================================================ # МЕТАДАНІ # ============================================================================ -__version__ = "2.6.1" +__version__ = "2.6.2" def main():