Fix: resolve undefined variable and early termination in aveElecStatPot.py - #7640
Merged
mohanchen merged 1 commit intoJul 15, 2026
Merged
Conversation
…ot.py Refactored input file handling to check for 'ElecStaticPot.cube' in subdirectories. Added error handling for missing input files.
mohanchen
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue
Fixes #7559
Description
This PR addresses two logical issues in the
aveElecStatPot.pyscript that could cause it to crash or exit prematurely when searching forElecStaticPot.cube:Premature Termination (Early
sys.exit):Previously, the script would immediately exit (
sys.exit()) if the first matchingOUT.*subdirectory scanned did not containElecStaticPot.cube. This prevented the script from checking subsequentOUT.*directories that might actually contain the target file.NameError (Undefined
input_file):If no
ElecStaticPot.cubewas present in the root directory, and noOUT.*subdirectories existed, the nested search loop was never executed. Consequently,input_filewas never defined, resulting in aNameErrorwhen the script reached thewith open(input_file, 'r')block.Changes Made
input_file,output_file, andoutput_pngtoNoneto preventNameError.OUT.*directories rather than exiting immediately on the first miss.