[SECURITY] Replace 14 bare except blocks in pt_hub.py - closes #53#91
Merged
sjackson0109 merged 4 commits intoMay 21, 2026
Merged
Conversation
GUI tab creation bare excepts (lines 4303-4638): except Exception: Process communicate timeout (line 5548): except (TimeoutError, OSError): Stdout read failure (line 5597): except (OSError, AttributeError): Widget/color utilities (lines 5680-5906): except Exception: Bare except: swallows SystemExit and KeyboardInterrupt. All 14 replaced. pt_trader.py had 0 bare except: (only broad except Exception: which is acceptable given its error handling patterns).
5f94349 to
e37c21d
Compare
Collaborator
Author
Manual Testing Guide — PR #91: Replace Bare Except Blocks in pt_hub.pyPrerequisitesgit fetch fork && git checkout feat/53-bare-except-audit
cd app1. Confirm no bare excepts remain in pt_hub.pypython -c "
import ast, sys
with open('pt_hub.py') as f:
tree = ast.parse(f.read())
bare = [n.lineno for n in ast.walk(tree)
if isinstance(n, ast.ExceptHandler) and n.type is None]
if bare:
print('FAIL: bare excepts at lines:', bare)
sys.exit(1)
print(f'PASS: 0 bare excepts (was 14)')
"2. Run existing tests to confirm no regressionspython -m pytest test_comprehensive.py -v --timeout=30 -k "not gui"Expected: All non-GUI tests pass. 3. Smoke test — start the hub (headless check)python -c "import pt_hub; print('import ok')"Expected: Imports without errors. Rollbackgit checkout main -- app/pt_hub.py |
Black check failed in CI — pt_hub.py had formatting issues. Auto-formatted with Black.
sjackson0109
approved these changes
May 21, 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.
Summary
Replaces all 14 bare
except:blocks inpt_hub.py. Bareexcept:incorrectly swallowsSystemExitandKeyboardInterrupt.except Exception:except (TimeoutError, OSError):proc.communicate(timeout=1)except (OSError, AttributeError):proc.stdout.read()except Exception:pt_trader.pyhad 0 bareexcept:(only broadexcept Exception:which was acceptable).Changes
app/pt_hub.py— 14 substitutions, zero functional changesTest plan
flake8 --select=E9,F63,F7,F82- zero hard errors after changegrep "except:" pt_hub.py- zero resultsCloses #53