From 6cc31af657a0aaf5a8ba0564b35124f1ca542287 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 5 Sep 2022 10:39:52 -0700 Subject: gh-92986: Fix ast.unparse when ImportFrom.level is None (GH-92992) This doesn't happen naturally, but is allowed by the ASDL and compiler. We don't want to change ASDL for backward compatibility reasons (GH-57645, GH-92987) (cherry picked from commit 200c9a8da0e2b892c476807e986009c01327e781) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> --- Lib/ast.py | 2 +- Lib/test/test_unparse.py | 6 ++++++ .../next/Library/2022-05-19-22-34-42.gh-issue-92986.e6uKxj.rst | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2022-05-19-22-34-42.gh-issue-92986.e6uKxj.rst diff --git a/Lib/ast.py b/Lib/ast.py index f4d2f6e..d63cb2f 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -849,7 +849,7 @@ class _Unparser(NodeVisitor): def visit_ImportFrom(self, node): self.fill("from ") - self.write("." * node.level) + self.write("." * (node.level or 0)) if node.module: self.write(node.module) self.write(" import ") diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py index 33e1149..6e38c5e 100644 --- a/Lib/test/test_unparse.py +++ b/Lib/test/test_unparse.py @@ -341,6 +341,12 @@ class UnparseTestCase(ASTTestCase): def test_invalid_yield_from(self): self.check_invalid(ast.YieldFrom(value=None)) + def test_import_from_level_none(self): + tree = ast.ImportFrom(module='mod', names=[ast.alias(name='x')]) + self.assertEqual(ast.unparse(tree), "from mod import x") + tree = ast.ImportFrom(module='mod', names=[ast.alias(name='x')], level=None) + self.assertEqual(ast.unparse(tree), "from mod import x") + def test_docstrings(self): docstrings = ( 'this ends with double quote"', diff --git a/Misc/NEWS.d/next/Library/2022-05-19-22-34-42.gh-issue-92986.e6uKxj.rst b/Misc/NEWS.d/next/Library/2022-05-19-22-34-42.gh-issue-92986.e6uKxj.rst new file mode 100644 index 0000000..691c0dd --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-05-19-22-34-42.gh-issue-92986.e6uKxj.rst @@ -0,0 +1 @@ +Fix :func:`ast.unparse` when ``ImportFrom.level`` is None -- cgit v0.12 From 75c3a4ccaff2ed581be67c5f48c3ca8a9fed23b7 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 5 Sep 2022 11:56:21 -0700 Subject: Add upstream openssl 1.1.1q patch for trivial build error on macOS (GH-96594) (cherry picked from commit 991b3712a11a705efc6e45d22643bb2ccfb3eca5) Co-authored-by: Ned Deily --- Mac/BuildScript/build-installer.py | 1 + Mac/BuildScript/openssl1.1.1q-pr-18719.patch | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 Mac/BuildScript/openssl1.1.1q-pr-18719.patch diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py index 668667c..67a6e4b 100755 --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -249,6 +249,7 @@ def library_recipes(): name="OpenSSL 1.1.1q", url="https://www.openssl.org/source/openssl-1.1.1q.tar.gz", checksum='d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca', + patches=['openssl1.1.1q-pr-18719.patch'], buildrecipe=build_universal_openssl, configure=None, install=None, diff --git a/Mac/BuildScript/openssl1.1.1q-pr-18719.patch b/Mac/BuildScript/openssl1.1.1q-pr-18719.patch new file mode 100644 index 0000000..6b4b188 --- /dev/null +++ b/Mac/BuildScript/openssl1.1.1q-pr-18719.patch @@ -0,0 +1,17 @@ +https://github.com/openssl/openssl/commit/60f011f584d80447e86cae1d1bd3ae24bc13235b +This fixes a regression in 1.1.1q: + +test/v3ext.c:201:24: error: implicitly declaring library function 'memcmp' with type 'int (const void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration] + if (!TEST_true(memcmp(ip1->data, ip2->data, ip1->length) <= 0)) + +diff -Naur openssl-1.1.1q/test/v3ext.c openssl-1.1.1q-patched/test/v3ext.c +--- openssl-1.1.1q/test/v3ext.c 2022-07-05 09:08:33.000000000 +0000 ++++ openssl-1.1.1q-patched/test/v3ext.c 2022-09-05 16:54:45.740859256 +0000 +@@ -8,6 +8,7 @@ + */ + + #include ++#include + #include + #include + #include -- cgit v0.12