Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
common_deps: python3-distro-info python3-launchpadlib
gtk_deps: gir1.2-gtk-3.0 gir1.2-wnck-3.0 gnome-icon-theme procps python3-gi
kde_deps: procps pyqt6-dev-tools python3-pyqt6
unit_deps: locales python3-systemd python3-zstandard
unit_deps: locales python3-systemd
integration_deps: >
bash binutils gcc gdb kmod libc6-dev libglib2.0-dev libxml2-utils
polkitd python3-systemd valgrind xterm
Expand All @@ -40,7 +40,7 @@ jobs:
strategy:
fail-fast: false
container:
image: ubuntu:resolute
image: ubuntu:stonking
steps:
- uses: actions/checkout@v6
- name: Install dependencies
Expand All @@ -49,7 +49,7 @@ jobs:
&& apt-get install --no-install-recommends --yes
black isort mypy pycodestyle pydocstyle pylint python3-typeshed
python3-dbus python3-distutils-extra python3-rpm python3-yaml
python3-systemd python3-zstandard
python3-systemd
$base_deps $common_deps $gtk_deps $kde_deps
- name: Run linter tests
run: tests/run-linters
Expand All @@ -66,13 +66,12 @@ jobs:
fail-fast: false
matrix:
container:
- debian:stable-slim
- debian:testing-slim
- ubuntu:noble
- ubuntu:resolute
- ubuntu:stonking
architecture:
- ubuntu-latest
- ubuntu-24.04-arm
- ubuntu-26.04-arm
container:
image: ${{ matrix.container }}
options: --cap-add=SYS_PTRACE --security-opt seccomp=unconfined
Expand Down Expand Up @@ -106,7 +105,7 @@ jobs:
path: ./coverage*.xml

unit-and-integration-installed:
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
strategy:
fail-fast: false
steps:
Expand Down Expand Up @@ -150,8 +149,8 @@ jobs:
fail-fast: false
matrix:
container:
- ubuntu:noble
- ubuntu:resolute
- ubuntu:stonking
container:
image: ${{ matrix.container }}
steps:
Expand Down Expand Up @@ -181,11 +180,11 @@ jobs:
fail-fast: false
matrix:
container:
- ubuntu:noble
- ubuntu:resolute
- ubuntu:stonking
architecture:
- ubuntu-latest
- ubuntu-24.04-arm
- ubuntu-26.04-arm
container:
image: ${{ matrix.container }}
steps:
Expand Down Expand Up @@ -218,7 +217,7 @@ jobs:
path: ./coverage.xml

system-installed:
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
strategy:
fail-fast: false
steps:
Expand Down Expand Up @@ -266,11 +265,11 @@ jobs:
fail-fast: false
matrix:
container:
- ubuntu:noble
- ubuntu:resolute
- ubuntu:stonking
architecture:
- ubuntu-latest
- ubuntu-24.04-arm
- ubuntu-26.04-arm
container:
image: ${{ matrix.container }}
steps:
Expand Down Expand Up @@ -302,7 +301,7 @@ jobs:
path: ./coverage.xml

system-internet-installed:
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
strategy:
fail-fast: false
steps:
Expand Down
2 changes: 1 addition & 1 deletion apport/crashdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
if typing.TYPE_CHECKING: # pragma: no cover
# pylint: disable-next=import-outside-toplevel,unused-import
import sqlite3
self.duplicate_db: "sqlite3.Connection | None" = None

Check failure on line 53 in apport/crashdb.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (UP037)

apport/crashdb.py:53:28: UP037 Remove quotes from type annotation help: Remove quotes
self.format_version: int | None = None

def get_bugpattern_baseurl(self) -> str | None:
Expand Down Expand Up @@ -182,7 +182,7 @@

try:
report_package_version = report["Package"].split()[1]
except (KeyError, IndexError):
except KeyError, IndexError:
report_package_version = None

# check the existing IDs whether there is one that is unfixed or not
Expand Down Expand Up @@ -391,7 +391,7 @@
if cur_file:
cur_file.close()
# hard to change, pylint: disable-next=consider-using-with
cur_file = open(os.path.join(basedir, cur_hash), "w", encoding="utf-8")

Check failure on line 394 in apport/crashdb.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (SIM115)

apport/crashdb.py:394:28: SIM115 Use a context manager for opening files

assert cur_file is not None
cur_file.write(f"{crash_id} {sig}\n")
Expand Down Expand Up @@ -908,7 +908,7 @@
settings: dict[str, Any] = {}
with open(conf, encoding="utf-8") as f:
# legacy, pylint: disable=exec-used
exec(compile(f.read(), conf, "exec"), settings)

Check failure on line 911 in apport/crashdb.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (S102)

apport/crashdb.py:911:9: S102 Use of `exec` detected

# Load third parties crashdb.conf
confd_dir = f"{conf}.d"
Expand All @@ -919,8 +919,8 @@
try:
with open(cfpath, encoding="utf-8") as f:
# legacy, pylint: disable=exec-used
exec(compile(f.read(), cfpath, "exec"), settings["databases"])

Check failure on line 922 in apport/crashdb.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (S102)

apport/crashdb.py:922:25: S102 Use of `exec` detected
except Exception as error: # pylint: disable=broad-except

Check failure on line 923 in apport/crashdb.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (BLE001)

apport/crashdb.py:923:24: BLE001 Do not catch blind exception: `Exception`
# ignore broken files
sys.stderr.write(f"Invalid file {cfpath}: {error}\n")

Expand Down
2 changes: 1 addition & 1 deletion apport/crashdb_impl/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@
# Frame the report in the format the BTS understands
try:
buggy_package, buggy_version = report["Package"].split(" ")
except (KeyError, ValueError):
except KeyError, ValueError:
return False

with tempfile.NamedTemporaryFile() as temp:
temp.file.write(f"Package: {buggy_package}\n".encode("UTF-8"))

Check failure on line 78 in apport/crashdb_impl/debian.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (UP012)

apport/crashdb_impl/debian.py:78:29: UP012 Unnecessary UTF-8 `encoding` argument to `encode` help: Remove unnecessary `encoding` argument
temp.file.write(f"Version: {buggy_version}\n\n\n".encode("UTF-8"))

Check failure on line 79 in apport/crashdb_impl/debian.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (UP012)

apport/crashdb_impl/debian.py:79:29: UP012 Unnecessary UTF-8 `encoding` argument to `encode` help: Remove unnecessary `encoding` argument
temp.file.write(("=============================\n\n").encode("UTF-8"))

Check failure on line 80 in apport/crashdb_impl/debian.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (UP012)

apport/crashdb_impl/debian.py:80:29: UP012 Unnecessary call to `encode` as UTF-8 help: Rewrite as bytes literal

# Let's remove the CoreDump first

Expand Down
4 changes: 2 additions & 2 deletions apport/crashdb_impl/launchpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def filter_filename(attachments):
for attachment in attachments:
try:
f = attachment.data.open()
except (HTTPError, FailedToDecompressContent):
except HTTPError, FailedToDecompressContent:
apport.logging.error("Broken attachment on bug, ignoring")
continue
name = f.filename
Expand Down Expand Up @@ -356,7 +356,7 @@ def download(self, crash_id):
# ignore attachments with invalid keys
try:
report[key] = ""
except (AssertionError, TypeError, ValueError):
except AssertionError, TypeError, ValueError:
continue
if ext == ".txt":
report[key] = attachment.read()
Expand Down
14 changes: 7 additions & 7 deletions apport/fileutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def find_snap(snap):
response = c.getresponse()
if response.status == 200:
return json.loads(response.read())["result"]
except (http.client.HTTPException, json.JSONDecodeError, OSError):
except http.client.HTTPException, json.JSONDecodeError, OSError:
return None
return None

Expand Down Expand Up @@ -283,15 +283,15 @@ def get_sys_gid_max() -> int:
"""Return maximum system group ID (SYS_GID_MAX from /etc/login.defs)."""
try:
return int(get_login_defs()["SYS_GID_MAX"])
except (KeyError, ValueError):
except KeyError, ValueError:
return 999


def get_sys_uid_max() -> int:
"""Return maximum system user ID (SYS_UID_MAX from /etc/login.defs)."""
try:
return int(get_login_defs()["SYS_UID_MAX"])
except (KeyError, ValueError):
except KeyError, ValueError:
return 999


Expand Down Expand Up @@ -398,7 +398,7 @@ def get_recent_crashes(report: IO[bytes]) -> int:
if cur_time - report_time > 24 * 3600:
return 0
return count
except (ValueError, KeyError):
except ValueError, KeyError:
return 0


Expand Down Expand Up @@ -515,7 +515,7 @@ def get_config(section, setting, default=None, path=None, boolean=False):
if boolean:
return config.getboolean(section, setting)
return config.get(section, setting)
except (configparser.NoOptionError, configparser.NoSectionError):
except configparser.NoOptionError, configparser.NoSectionError:
return default


Expand Down Expand Up @@ -653,7 +653,7 @@ def find_core_files_by_uid(uid: int) -> list[tuple[str, float]]:
if f.split(".")[2] == str(uid):
core_file_time = os.path.getmtime(os.path.join(core_dir, f))
uid_files.append((f, core_file_time))
except (IndexError, FileNotFoundError):
except IndexError, FileNotFoundError:
continue
return uid_files

Expand Down Expand Up @@ -717,7 +717,7 @@ def should_skip_crash(report: ProblemReport, filename: str) -> str | None:
"""
try:
crash_counter = int(report["CrashCounter"])
except (KeyError, ValueError):
except KeyError, ValueError:
crash_counter = 0
if crash_counter > 1:
return f"this executable already crashed {crash_counter} times, ignoring"
Expand Down
2 changes: 1 addition & 1 deletion apport/hookutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ def attach_mac_events(
profile = match[1:-1]
else:
profile = bytes.fromhex(match).decode("UTF-8", errors="replace")
except (IndexError, ValueError):
except IndexError, ValueError:
continue

for search_profile in profiles:
Expand Down
6 changes: 3 additions & 3 deletions apport/packaging_impl/apt_dpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def _virtual_mapping(self, configdir: str) -> dict[str, set[str]]:
with open(mapping_file, "rb") as fp:
self._virtual_mapping_obj = pickle.load(fp)
assert isinstance(self._virtual_mapping_obj, dict)
except (AssertionError, FileNotFoundError):
except AssertionError, FileNotFoundError:
self._virtual_mapping_obj = {}

return self._virtual_mapping_obj
Expand Down Expand Up @@ -378,7 +378,7 @@ def _contents_mapping(
assert isinstance(self._contents_mapping_obj, dict)
# Discard files from Apport < 2.35.0
assert isinstance(next(iter(self._contents_mapping_obj)), str)
except (AssertionError, FileNotFoundError):
except AssertionError, FileNotFoundError:
self._contents_mapping_obj = {"release": release, "arch": arch}

return self._contents_mapping_obj
Expand Down Expand Up @@ -2033,7 +2033,7 @@ def get_distro_codename(self) -> str:
try:
info = platform.freedesktop_os_release()
self._distro_codename = info["VERSION_CODENAME"]
except (KeyError, OSError):
except KeyError, OSError:
# Fall back to query lsb_release
lsb_release = subprocess.run(
["lsb_release", "-sc"],
Expand Down
10 changes: 5 additions & 5 deletions apport/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def _check_bug_pattern(report, pattern):
regexp = regexp.encode("UTF-8")
try:
re_c = re.compile(regexp)
except (re.error, TypeError, ValueError):
except re.error, TypeError, ValueError:
continue
if not re_c.search(v):
return None
Expand All @@ -297,7 +297,7 @@ def _check_bug_pattern(report, pattern):
def _check_bug_patterns(report, patterns):
try:
dom = xml.dom.minidom.parseString(patterns)
except (xml.parsers.expat.ExpatError, UnicodeEncodeError):
except xml.parsers.expat.ExpatError, UnicodeEncodeError:
return None

for pattern in dom.getElementsByTagName("pattern"):
Expand Down Expand Up @@ -1413,7 +1413,7 @@ def check_ignored(self) -> bool:

try:
dom = self._get_ignore_dom()
except (ValueError, KeyError):
except ValueError, KeyError:
apport.logging.error("Could not get ignore file:")
traceback.print_exc()
return False
Expand All @@ -1430,7 +1430,7 @@ def check_ignored(self) -> bool:
if ignore.getAttribute("program") == self["ExecutablePath"]:
if float(ignore.getAttribute("mtime")) >= cur_mtime:
return True
except (ValueError, KeyError):
except ValueError, KeyError:
pass

return False
Expand Down Expand Up @@ -1962,7 +1962,7 @@ def get_executable_timestamp(self) -> int | None:
"""Get ExecutableTimestamp if present and valid."""
try:
return int(self["ExecutableTimestamp"])
except (KeyError, ValueError):
except KeyError, ValueError:
return None

def gdb_command(
Expand Down
8 changes: 4 additions & 4 deletions apport/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def get_pid(report):
try:
pid = re.search("Pid:\t(.*)\n", report.get("ProcStatus", "")).group(1)
return int(pid)
except (IndexError, AttributeError):
except IndexError, AttributeError:
return None


Expand All @@ -77,7 +77,7 @@ def _get_env_int(key: str, default: int | None = None) -> int | None:
"""
try:
return int(os.environ[key])
except (KeyError, ValueError):
except KeyError, ValueError:
return default


Expand Down Expand Up @@ -1377,7 +1377,7 @@ def check_report_crashdb(self) -> bool:
return False
try:
self.crashdb = apport.crashdb.load_crashdb(None, spec)
except (ImportError, KeyError):
except ImportError, KeyError:
self.report["UnreportableReason"] = (
f"A package hook wants to send this report to the crash"
f' database "{self.report["CrashDB"]}"'
Expand All @@ -1388,7 +1388,7 @@ def check_report_crashdb(self) -> bool:
# DB name
try:
self.crashdb = apport.crashdb.get_crashdb(None, self.report["CrashDB"])
except (ImportError, KeyError):
except ImportError, KeyError:
self.report["UnreportableReason"] = (
f"A package hook wants to send this report to the crash"
f' database "{self.report["CrashDB"]}"'
Expand Down
4 changes: 2 additions & 2 deletions apport_python_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def apport_excepthook(
likely_packaged,
should_skip_crash,
)
except (ImportError, OSError):
except ImportError, OSError:
return

# for interactive Python sessions, sys.argv[0] == ""
Expand Down Expand Up @@ -194,7 +194,7 @@ def dbus_service_unknown_analysis(exc_obj, report):
subprocess.call(["pidof", "-sx", exe], stdout=subprocess.PIPE) == 0
)
services.append((service_file, exe, running))
except (NoSectionError, NoOptionError):
except NoSectionError, NoOptionError:
if sys.stderr:
sys.stderr.write(
f"Invalid D-BUS .service file {service_file}:"
Expand Down
2 changes: 1 addition & 1 deletion bin/apport-retrace
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def gen_source_stacktrace(report, sandbox):
try:
try:
version = report["Package"].split()[1]
except (IndexError, KeyError):
except IndexError, KeyError:
version = None
srcdir = packaging.get_source_tree(
report["SourcePackage"], workdir, version, sandbox=sandbox
Expand Down
10 changes: 5 additions & 5 deletions bin/apport-valgrind
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ try:
sys.stderr.write(_("Error: %s is not an executable. Stopping.") % options.exe)
sys.stderr.write("\n")
sys.exit(1)
except (KeyboardInterrupt, SystemExit):
except KeyboardInterrupt, SystemExit:
sys.stderr.write("\nInterrupted during initialization\n")
_exit_on_interrupt()

Expand All @@ -144,7 +144,7 @@ try:
report.add_package_info()

apport.logging.memdbg("\nCreated report")
except (KeyboardInterrupt, SystemExit):
except KeyboardInterrupt, SystemExit:
sys.stderr.write("\nInterrupted during report creation\n")
_exit_on_interrupt()

Expand All @@ -165,7 +165,7 @@ try:
options.verbose,
)

except (KeyboardInterrupt, SystemExit):
except KeyboardInterrupt, SystemExit:
sys.stderr.write("\nInterrupted while creating sandbox\n")
_exit_on_interrupt()

Expand Down Expand Up @@ -199,15 +199,15 @@ try:
argv += [exepath]

apport.logging.memdbg("before calling valgrind")
except (KeyboardInterrupt, SystemExit):
except KeyboardInterrupt, SystemExit:
sys.stderr.write("\nInterrupted while preparing to create sandbox\n")
_exit_on_interrupt()

valgrind_env = {k: v for k, v in os.environ.items() if k != "DEBUGINFOD_URLS"}

try:
subprocess.call(argv, env=valgrind_env)
except (KeyboardInterrupt, SystemExit):
except KeyboardInterrupt, SystemExit:
sys.stderr.write("\nInterrupted while running valgrind\n")
_exit_on_interrupt()

Expand Down
Loading
Loading