summaryrefslogtreecommitdiff
path: root/dev-python/mypy/files/mypy-0.782-py39-fixes.patch
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/mypy/files/mypy-0.782-py39-fixes.patch')
-rw-r--r--dev-python/mypy/files/mypy-0.782-py39-fixes.patch138
1 files changed, 138 insertions, 0 deletions
diff --git a/dev-python/mypy/files/mypy-0.782-py39-fixes.patch b/dev-python/mypy/files/mypy-0.782-py39-fixes.patch
new file mode 100644
index 000000000000..16c12daecae5
--- /dev/null
+++ b/dev-python/mypy/files/mypy-0.782-py39-fixes.patch
@@ -0,0 +1,138 @@
+From 13ae58ffe8bedb7da9f4c657297f0d61e681d671 Mon Sep 17 00:00:00 2001
+From: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
+Date: Sun, 30 Aug 2020 18:11:57 -0700
+Subject: [PATCH] mypy: get CI green for py39 (#9376)
+
+Due to Python 3.9's new parser, this has a different (and better) error
+message on Python 3.9.
+
+This is effectively a test of typed_ast / ast, so I don't think it
+matters too much. I'm happy to alternatively just get rid of the test
+altogether, or if people feel strongly, come up with a way to run the
+test when run with older Pythons.
+
+Co-authored-by: hauntsaninja <>
+---
+ .travis.yml | 3 ---
+ mypy/test/testcheck.py | 2 ++
+ test-data/unit/check-kwargs.test | 7 -------
+ test-data/unit/check-python39.test | 9 +++++++++
+ 4 files changed, 11 insertions(+), 10 deletions(-)
+ create mode 100644 test-data/unit/check-python39.test
+
+diff --git a/mypy/test/testcheck.py b/mypy/test/testcheck.py
+index 49a85861b6..39a35c7280 100644
+--- a/mypy/test/testcheck.py
++++ b/mypy/test/testcheck.py
+@@ -94,6 +94,8 @@
+ # Tests that use Python 3.8-only AST features (like expression-scoped ignores):
+ if sys.version_info >= (3, 8):
+ typecheck_files.append('check-python38.test')
++if sys.version_info >= (3, 9):
++ typecheck_files.append('check-python39.test')
+
+ # Special tests for platforms with case-insensitive filesystems.
+ if sys.platform in ('darwin', 'win32'):
+diff --git a/test-data/unit/check-kwargs.test b/test-data/unit/check-kwargs.test
+index 1dd450caae..a587be3e06 100644
+--- a/test-data/unit/check-kwargs.test
++++ b/test-data/unit/check-kwargs.test
+@@ -53,13 +53,6 @@ f(b=[], a=A())
+ class A: pass
+ [builtins fixtures/list.pyi]
+
+-[case testGivingSameKeywordArgumentTwice]
+-import typing
+-def f(a: 'A', b: 'B') -> None: pass
+-f(a=A(), b=B(), a=A()) # E: keyword argument repeated
+-class A: pass
+-class B: pass
+-
+ [case testGivingArgumentAsPositionalAndKeywordArg]
+ import typing
+ def f(a: 'A', b: 'B' = None) -> None: pass
+diff --git a/test-data/unit/check-python39.test b/test-data/unit/check-python39.test
+new file mode 100644
+index 0000000000..0e9ec683ae
+--- /dev/null
++++ b/test-data/unit/check-python39.test
+@@ -0,0 +1,9 @@
++[case testGivingSameKeywordArgumentTwice]
++# This test was originally in check-kwargs.test
++# Python 3.9's new parser started producing a different error message here. Since this isn't the
++# most important test, to deal with this we'll only run this test with Python 3.9 and later.
++import typing
++def f(a: 'A', b: 'B') -> None: pass
++f(a=A(), b=B(), a=A()) # E: "f" gets multiple values for keyword argument "a"
++class A: pass
++class B: pass
+From da4430119255ac9205c96d54deb2e2ebed0ce8ce Mon Sep 17 00:00:00 2001
+From: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
+Date: Fri, 31 Jul 2020 09:58:15 -0700
+Subject: [PATCH] mypyc: ignore deprecation (#9107)
+
+PyUnicode_AsUnicodeAndSize has been deprecated since 3.3
+
+Python 3.9 has compiler warnings for this deprecated function, and we
+compile with Werror, causing Python 3.9 builds to fail.
+
+I've just copied over the relevant deprecation ignoring code from the
+original getargs.c (including the TODO, but I can remove that)
+
+Co-authored-by: hauntsaninja <>
+---
+ mypyc/lib-rt/getargs.c | 27 +++++++++++++++++++++++++++
+ 1 file changed, 27 insertions(+)
+
+diff --git a/mypyc/lib-rt/getargs.c b/mypyc/lib-rt/getargs.c
+index 32b387c8ab..e6b1a0c937 100644
+--- a/mypyc/lib-rt/getargs.c
++++ b/mypyc/lib-rt/getargs.c
+@@ -18,6 +18,29 @@
+ * and is responsible for decrefing them.
+ */
+
++// These macro definitions are copied from pyport.h in Python 3.9 and later
++// https://bugs.python.org/issue19569
++#if defined(__clang__)
++#define _Py_COMP_DIAG_PUSH _Pragma("clang diagnostic push")
++#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \
++ _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
++#define _Py_COMP_DIAG_POP _Pragma("clang diagnostic pop")
++#elif defined(__GNUC__) \
++ && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
++#define _Py_COMP_DIAG_PUSH _Pragma("GCC diagnostic push")
++#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \
++ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
++#define _Py_COMP_DIAG_POP _Pragma("GCC diagnostic pop")
++#elif defined(_MSC_VER)
++#define _Py_COMP_DIAG_PUSH __pragma(warning(push))
++#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS __pragma(warning(disable: 4996))
++#define _Py_COMP_DIAG_POP __pragma(warning(pop))
++#else
++#define _Py_COMP_DIAG_PUSH
++#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS
++#define _Py_COMP_DIAG_POP
++#endif
++
+ #include "Python.h"
+ #include "pythonsupport.h"
+
+@@ -756,6 +779,9 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
+ case 'u': /* raw unicode buffer (Py_UNICODE *) */
+ case 'Z': /* raw unicode buffer or None */
+ {
++ // TODO: Raise DeprecationWarning
++_Py_COMP_DIAG_PUSH
++_Py_COMP_DIAG_IGNORE_DEPR_DECLS
+ Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **);
+
+ if (*format == '#') {
+@@ -795,6 +821,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
+ arg, msgbuf, bufsize);
+ }
+ break;
++_Py_COMP_DIAG_POP
+ }
+
+ case 'e': {/* encoded string */