Blame SOURCES/0019-Silence-a-deprecation-warning-in-plugins-copr.py.patch

9f4a6f
From a07db6dcd669eecb27b7ddbf1b85cd842bdcc35b Mon Sep 17 00:00:00 2001
9f4a6f
From: Otto Urpelainen <oturpe@iki.fi>
9f4a6f
Date: Wed, 6 Oct 2021 22:08:54 +0300
9f4a6f
Subject: [PATCH] Silence a deprecation warning in plugins/copr.py
9f4a6f
9f4a6f
In version 1.6.0, the 'distro' package deprecated linux_distribution().
9f4a6f
This causes a deprecation warning to printed to stdout
9f4a6f
every time the user calls the copr plugin.
9f4a6f
9f4a6f
In order to avoid the printout
9f4a6f
and to protect against possible removal in the future,
9f4a6f
the function is reimplemented
9f4a6f
using still supported functions from 'distro'.
9f4a6f
9f4a6f
= changelog =
9f4a6f
msg: [copr] Avoid using deprecated function distro.linux_distribution()
9f4a6f
type: bugfix
9f4a6f
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2011550
9f4a6f
---
9f4a6f
 plugins/copr.py | 6 +++++-
9f4a6f
 1 file changed, 5 insertions(+), 1 deletion(-)
9f4a6f
9f4a6f
diff --git a/plugins/copr.py b/plugins/copr.py
9f4a6f
index c216408..9f597dd 100644
9f4a6f
--- a/plugins/copr.py
9f4a6f
+++ b/plugins/copr.py
9f4a6f
@@ -38,7 +38,11 @@ import rpm
9f4a6f
 # If that fails, attempt to import the deprecated implementation
9f4a6f
 # from the platform module.
9f4a6f
 try:
9f4a6f
-    from distro import linux_distribution, os_release_attr
9f4a6f
+    from distro import name, version, codename, os_release_attr
9f4a6f
+
9f4a6f
+    # Re-implement distro.linux_distribution() to avoid a deprecation warning
9f4a6f
+    def linux_distribution():
9f4a6f
+        return (name(), version(), codename())
9f4a6f
 except ImportError:
9f4a6f
     def os_release_attr(_):
9f4a6f
         return ""
9f4a6f
-- 
9f4a6f
2.36.1
9f4a6f