commit:     448c5a045d47fe5cac56c30e4ff4bcab4d5627b7
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 28 02:29:33 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jan 28 02:29:33 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=448c5a04

dev-python/dnspython: Backport musl test fix

Closes: https://bugs.gentoo.org/923004
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/dnspython/dnspython-2.5.0.ebuild        |  6 ++
 .../files/dnspython-2.5.0-musl-test.patch          | 67 ++++++++++++++++++++++
 2 files changed, 73 insertions(+)

diff --git a/dev-python/dnspython/dnspython-2.5.0.ebuild 
b/dev-python/dnspython/dnspython-2.5.0.ebuild
index fa76df91c401..c942143466ba 100644
--- a/dev-python/dnspython/dnspython-2.5.0.ebuild
+++ b/dev-python/dnspython/dnspython-2.5.0.ebuild
@@ -38,6 +38,12 @@ BDEPEND="
 
 distutils_enable_tests pytest
 
+PATCHES=(
+       # https://github.com/rthalley/dnspython/issues/1035
+       # 
https://github.com/rthalley/dnspython/commit/1b22985f2d67b6dd43259e3c6b853498f1cff712
+       "${FILESDIR}/${P}-musl-test.patch"
+)
+
 python_install_all() {
        distutils-r1_python_install_all
        if use examples; then

diff --git a/dev-python/dnspython/files/dnspython-2.5.0-musl-test.patch 
b/dev-python/dnspython/files/dnspython-2.5.0-musl-test.patch
new file mode 100644
index 000000000000..a5aec3378fdd
--- /dev/null
+++ b/dev-python/dnspython/files/dnspython-2.5.0-musl-test.patch
@@ -0,0 +1,67 @@
+From 1b22985f2d67b6dd43259e3c6b853498f1cff712 Mon Sep 17 00:00:00 2001
+From: Bob Halley <[email protected]>
+Date: Sat, 27 Jan 2024 12:38:03 -0800
+Subject: [PATCH] In tests, work around musl libc and docker issues.
+
+Specifically: musl libc's getaddrinfo behavior always returns
+a canonical name.
+
+Docker's resolver proxy doesn't do dangling CNAMEs correctly
+and also answers NXDOMAIN in some cases where it should say
+no error, no data.
+---
+ tests/test_async.py             | 14 +++++++++++---
+ tests/test_resolver.py          | 21 +++++++++++++++------
+ tests/test_resolver_override.py | 19 ++++++++++++-------
+ tests/util.py                   | 10 +++++++++-
+ 4 files changed, 47 insertions(+), 17 deletions(-)
+
+diff --git a/tests/test_resolver_override.py b/tests/test_resolver_override.py
+index aed7a53d..be9e53f2 100644
+--- a/tests/test_resolver_override.py
++++ b/tests/test_resolver_override.py
+@@ -69,7 +69,7 @@ def test_override(self):
+         dns.resolver.restore_system_resolver()
+         self.assertTrue(socket.getaddrinfo is 
dns.resolver._original_getaddrinfo)
+ 
+-    def equivalent_info(self, a, b):
++    def equivalent_info(self, a, b, q):
+         if len(a) != len(b):
+             return False
+         for x in a:
+@@ -78,16 +78,21 @@ def equivalent_info(self, a, b):
+                 # looking for a zero protocol.
+                 y = (x[0], x[1], 0, x[3], x[4])
+                 if y not in b:
+-                    print("NOT EQUIVALENT")
+-                    print(a)
+-                    print(b)
+-                    return False
++                    # musl libc insists on always providing a canonical name, 
so
++                    # accept that too.
++                    y = (x[0], x[1], x[2], q, x[4])
++                    if y not in b:
++                        print("NOT EQUIVALENT")
++                        print(a)
++                        print(b)
++                        return False
+         return True
+ 
+     def equivalent(self, *args, **kwargs):
++        q = args[0]
+         a = socket.getaddrinfo(*args, **kwargs)
+         b = dns.resolver._original_getaddrinfo(*args, **kwargs)
+-        return self.equivalent_info(a, b)
++        return self.equivalent_info(a, b, q)
+ 
+     @unittest.skipIf(
+         sys.platform == "win32", "avoid windows original getaddrinfo issues"
+@@ -139,7 +144,7 @@ def test_getaddrinfo_nxdomain(self):
+     def test_getaddrinfo_service(self):
+         a = socket.getaddrinfo("dns.google", "domain")
+         b = socket.getaddrinfo("dns.google", 53)
+-        self.assertTrue(self.equivalent_info(a, b))
++        self.assertTrue(self.equivalent_info(a, b, "dns.google"))
+         try:
+             socket.getaddrinfo("dns.google", "domain", 
flags=socket.AI_NUMERICSERV)
+             self.assertTrue(False)  # should not happen!

Reply via email to