Skip to content

Commit 6db6a61

Browse files
authored
Do not use bare except:
Do not use bare `except:`, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer `except Exception:`. If you're sure what you're doing, be explicit and write `except BaseException:`.
1 parent 79a3963 commit 6db6a61

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

core.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,18 @@
1111

1212

1313
def clear_screen():
14-
if system() == "Linux":
15-
os.system("clear")
16-
if system() == "Windows":
17-
os.system("cls")
14+
os.system("cls" if system() == "Windows" else "clear")
1815

1916

2017
def validate_input(ip, val_range):
18+
val_range = val_range or []
2119
try:
2220
ip = int(ip)
2321
if ip in val_range:
2422
return ip
25-
else:
26-
return None
27-
except:
28-
return None
23+
except Exception:
24+
pass
25+
return None
2926

3027

3128
class HackingTool(object):
@@ -46,8 +43,7 @@ class HackingTool(object):
4643

4744
def __init__(self, options = None, installable: bool = True,
4845
runnable: bool = True):
49-
if options is None:
50-
options = []
46+
options = options or []
5147
if isinstance(options, list):
5248
self.OPTIONS = []
5349
if installable:
@@ -176,7 +172,7 @@ def show_options(self, parent = None):
176172
except (TypeError, ValueError):
177173
print("Please enter a valid option")
178174
input("\n\nPress ENTER to continue:")
179-
except Exception as e:
175+
except Exception:
180176
print_exc()
181177
input("\n\nPress ENTER to continue:")
182178
return self.show_options(parent = parent)

0 commit comments

Comments
 (0)