Package: aptsources
Version: python-apt
Severity: normal
Tags: patch
X-Debbugs-Cc: macda...@gmail.com

Dear Maintainer,


   * What led up to the situation?

adding a commented line to /usr/lib/os-release

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

ran `add-apt-repository` command

   * What was the outcome of this action?

an error:

```
Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 11, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties,
shortcut_handler
  File "/usr/lib/python3/dist-
packages/softwareproperties/SoftwareProperties.py", line 57, in <module>
    from . import shortcuts
  File "/usr/lib/python3/dist-packages/softwareproperties/shortcuts.py", line
23, in <module>
    _DEF_CODENAME = aptsources.distro.get_distro().codename
  File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 580, in
get_distro
    os_release = _OSRelease()
  File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 526, in
__init__
    self.parse()
  File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 551, in
parse
    self.parse_entry(*line.split('=', 1))
TypeError: _OSRelease.parse_entry() missing 1 required positional argument:
'value'
```

   * What outcome did you expect instead?

the program should continue without stopping


patch:

diff --git a/aptsources/distro.py b/aptsources/distro.py
index df9bc2f5..f38907fb 100644
--- a/aptsources/distro.py
+++ b/aptsources/distro.py
@@ -545,6 +545,8 @@ class _OSRelease:
             line = line.strip()
             if not line:
                 continue
+            if line[0] == "#":
+                continue
             self.parse_entry(*line.split('=', 1))
         f.close()



-- System Information:
Debian Release: bookworm/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (100, 
'bullseye-fasttrack'), (100, 'bullseye-backports-staging')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.19.0-1-amd64 (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff --git a/aptsources/distro.py b/aptsources/distro.py
index df9bc2f5..f38907fb 100644
--- a/aptsources/distro.py
+++ b/aptsources/distro.py
@@ -545,6 +545,8 @@ class _OSRelease:
             line = line.strip()
             if not line:
                 continue
+            if line[0] == "#":
+                continue
             self.parse_entry(*line.split('=', 1))
         f.close()
 
diff --git a/aptsources/distro.py b/aptsources/distro.py
index df9bc2f5..f38907fb 100644
--- a/aptsources/distro.py
+++ b/aptsources/distro.py
@@ -545,6 +545,8 @@ class _OSRelease:
             line = line.strip()
             if not line:
                 continue
+            if line[0] == "#":
+                continue
             self.parse_entry(*line.split('=', 1))
         f.close()
 

Reply via email to