fix: replace bare except and mutable default arguments#183
Open
KeloYuan wants to merge 1 commit into
Open
Conversation
- 3 bare except: -> except Exception: in localgzipsearch.py, intelx.py, localsearch.py - 4 mutable default [] -> None in function signatures
There was a problem hiding this comment.
Pull request overview
This PR aims to harden error handling by replacing bare except: clauses with except Exception:, and to avoid Python mutable-default pitfalls by switching list defaults in several intelx search APIs.
Changes:
- Replaced bare
except:withexcept Exception:in local search utilities and the IntelX client. - Updated IntelX search method signatures to default
bucketstoNoneinstead of[].
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
h8mail/utils/localsearch.py |
Replaces a bare except: during local file decoding with except Exception:. |
h8mail/utils/localgzipsearch.py |
Replaces a bare except: during gzip file decoding with except Exception:. |
h8mail/utils/intelx.py |
Replaces a bare except: in FILE_TREE_VIEW and changes buckets defaults from [] to None across multiple search methods. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
146
to
+150
| ) | ||
| c.good_news( | ||
| f"Found occurrence [{file_to_parse}] Line {cnt}: {decoded}" | ||
| ) | ||
| except: | ||
| except Exception: |
Comment on lines
114
to
+118
| ) | ||
| c.good_news( | ||
| f"Found occurrence [{file_to_parse}] Line {cnt}: {decoded}" | ||
| ) | ||
| except: | ||
| except Exception: |
| return False | ||
|
|
||
| def INTEL_SEARCH(self, term, maxresults=100, buckets=[], timeout=5, datefrom="", dateto="", sort=4, media=0, terminate=[]): | ||
| def INTEL_SEARCH(self, term, maxresults=100, buckets=None, timeout=5, datefrom="", dateto="", sort=4, media=0, terminate=[]): |
| return r.status_code | ||
|
|
||
| def PHONEBOOK_SEARCH(self, term, maxresults=100, buckets=[], timeout=5, datefrom="", dateto="", sort=4, media=0, terminate=[], target=0): | ||
| def PHONEBOOK_SEARCH(self, term, maxresults=100, buckets=None, timeout=5, datefrom="", dateto="", sort=4, media=0, terminate=[], target=0): |
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
except:→except Exception:inlocalgzipsearch.py,intelx.py,localsearch.py[]→Nonein function signatures to prevent shared state bugsWhy
Bare
except:catchesSystemExitandKeyboardInterrupt. Mutable default arguments are shared across all calls and can cause subtle bugs.