Initialize file descriptors to None before opening to prevent UnboundLocalError in the finally block if file opening fails. Changes: - Initialize fin = None and fout = None at function start - Check if descriptors are not None before closing - Remove UnboundLocalError from exception handling (no longer needed) This improves code quality by eliminating the need to catch an error that indicates a logic bug. The existing tests verify correct behavior. Fixes #6
20 KiB
20 KiB