Violation
try:
from urllib.parse import urlparse
parsed = urlparse(url)
return parsed.port or self.DEFAULT_PORT
except:
return self.DEFAULT_PORT
Location
sdks/python/pmxt/server_manager.py:73
Why It Matters
A bare except: clause in Python catches all exceptions including SystemExit, KeyboardInterrupt, and GeneratorExit. This means a Ctrl-C issued while _get_port_from_url is on the call stack will be swallowed and the program will not exit. It should use except Exception: at minimum, and ideally the narrower except (ValueError, AttributeError): which are the only exceptions urlparse can realistically raise.
Suggested Fix
except (ValueError, AttributeError):
return self.DEFAULT_PORT
Found by automated code hygiene audit
Violation
Location
sdks/python/pmxt/server_manager.py:73Why It Matters
A bare
except:clause in Python catches all exceptions includingSystemExit,KeyboardInterrupt, andGeneratorExit. This means a Ctrl-C issued while_get_port_from_urlis on the call stack will be swallowed and the program will not exit. It should useexcept Exception:at minimum, and ideally the narrowerexcept (ValueError, AttributeError):which are the only exceptionsurlparsecan realistically raise.Suggested Fix
Found by automated code hygiene audit