Skip to content

fix: replace bare except and mutable default arguments#183

Open
KeloYuan wants to merge 1 commit into
khast3x:masterfrom
KeloYuan:fix/bare-except-improvements
Open

fix: replace bare except and mutable default arguments#183
KeloYuan wants to merge 1 commit into
khast3x:masterfrom
KeloYuan:fix/bare-except-improvements

Conversation

@KeloYuan

@KeloYuan KeloYuan commented May 8, 2026

Copy link
Copy Markdown

Summary

  • 3 bare except:except Exception: in localgzipsearch.py, intelx.py, localsearch.py
  • 4 mutable default []None in function signatures to prevent shared state bugs

Why

Bare except: catches SystemExit and KeyboardInterrupt. Mutable default arguments are shared across all calls and can cause subtle bugs.

- 3 bare except: -> except Exception: in localgzipsearch.py, intelx.py, localsearch.py
- 4 mutable default [] -> None in function signatures
Copilot AI review requested due to automatic review settings May 8, 2026 13:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: with except Exception: in local search utilities and the IntelX client.
  • Updated IntelX search method signatures to default buckets to None instead 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:
Comment thread h8mail/utils/intelx.py
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=[]):
Comment thread h8mail/utils/intelx.py
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):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants