Potential NameError in copy_file() exception handler #6
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Potential NameError in copy_file() exception handler
Priority: Medium
Component: fs.py
Type: Bug
Description
In the
copy_file()function, if theos.open()call for the output file fails, the variablefoutwill be uninitialized, causing aNameErrorwhen the finally block tries to close it.Location
curateipsum/fs.py:182-198Current Code
Problem
If line 187 fails,
foutis never assigned, leading toUnboundLocalErrorin the finally block (which is caught but indicates poor code structure).Proposed Solution
Impact
Medium - Code works but is fragile and harder to maintain.