pytest: fix remaining code checker warnings

- curl.py: delete commented no-op code.
- certs.py, curl.py: narrow down exceptions to fix:
  Except block handles 'BaseException'
- test_20_websockets: add comment to empty except branch.

Reported by GitHub CodeQL

Closes #21924
This commit is contained in:
Viktor Szakats 2026-06-09 11:14:17 +02:00
parent feb609f28b
commit 4aa8cc3c4a
No known key found for this signature in database
3 changed files with 5 additions and 8 deletions

View file

@ -264,6 +264,8 @@ class TestWebsockets:
f = b"\x88\x00" # CLOSE frame
c.sendall(f)
except OSError:
# Client may close/reset while we intentionally flood frames.
# Send errors are expected here, ignore them.
pass
time.sleep(1)
c.close()

View file

@ -484,8 +484,7 @@ class TestCA:
else:
try:
names.append(x509.IPAddress(ipaddress.ip_address(name)))
# TODO: specify specific exceptions here
except: # noqa: E722
except ValueError:
names.append(x509.DNSName(name))
return csr.add_extension(

View file

@ -284,11 +284,10 @@ class ExecResult:
if with_stats:
self._parse_stats()
else:
# noinspection PyBroadException
try:
out = ''.join(self._stdout)
self._json_out = json.loads(out)
except: # noqa: E722
except (json.JSONDecodeError, TypeError, ValueError):
pass
def __repr__(self):
@ -300,8 +299,7 @@ class ExecResult:
for line in self._stdout:
try:
self._stats.append(json.loads(line))
# TODO: specify specific exceptions here
except: # noqa: E722
except (json.JSONDecodeError, TypeError, ValueError):
log.exception(f'not a JSON stat: {line}')
break
@ -1031,8 +1029,6 @@ class CurlClient:
cwd=self._run_dir, shell=False,
env=self._run_env)
profile = RunProfile(p.pid, started_at, self._run_dir)
#if intext is not None and False:
# p.communicate(input=intext.encode(), timeout=1)
if self._with_perf:
perf = PerfProfile(p.pid, self._run_dir)
perf.start()