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

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