From 23b5cdf21e0a4a96acedc46e56778cb1003aad79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 19 May 2020 17:34:35 +0200 Subject: [PATCH] Backport another patch from upstream for Python 3.9 support --- 46372726.patch | 41 +++++++++++++++++++++++++++++++++++++++++ python-sphinx.spec | 4 ++++ 2 files changed, 45 insertions(+) create mode 100644 46372726.patch diff --git a/46372726.patch b/46372726.patch new file mode 100644 index 0000000..ec60f7b --- /dev/null +++ b/46372726.patch @@ -0,0 +1,41 @@ +From f236cd03e4853fd8b07a307e334c5110a78c1335 Mon Sep 17 00:00:00 2001 +From: Eric Wieser +Date: Mon, 27 Apr 2020 14:44:37 +0100 +Subject: [PATCH] Do not emit type arguments twice + +Fixes gh-7567 +--- + sphinx/util/inspect.py | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py +index 20af75628..4977af07f 100644 +--- a/sphinx/util/inspect.py ++++ b/sphinx/util/inspect.py +@@ -505,8 +505,13 @@ class Signature: + qualname = self.format_annotation(annotation.__origin__) # ex. Union + elif hasattr(annotation, '__qualname__'): + qualname = '%s.%s' % (module, annotation.__qualname__) ++ elif hasattr(annotation, '__origin__'): ++ # instantiated generic provided by a user ++ qualname = self.format_annotation(annotation.__origin__) + else: +- qualname = repr(annotation) ++ # we weren't able to extract the base type, appending arguments would ++ # only make them appear twice ++ return repr(annotation) + + if getattr(annotation, '__args__', None): + if qualname == 'Union': +@@ -519,7 +524,7 @@ class Signature: + args = ', '.join(self.format_annotation(a) for a in annotation.__args__[:-1]) + returns = self.format_annotation(annotation.__args__[-1]) + return '%s[[%s], %s]' % (qualname, args, returns) +- elif annotation._special: ++ elif getattr(annotation, '_special', False): + return qualname + else: + args = ', '.join(self.format_annotation(a) for a in annotation.__args__) +-- +2.26.2 + diff --git a/python-sphinx.spec b/python-sphinx.spec index 0b6c8dd..064abda 100644 --- a/python-sphinx.spec +++ b/python-sphinx.spec @@ -45,6 +45,10 @@ Patch1: sphinx-test_theming.diff # Backport: test: Add a docstring to avoid an error on py39a5+ Patch2: https://github.com/sphinx-doc/sphinx/commit/ffb1ca3a.patch +# Backport: Do not emit type arguments twice (needed for Python 3.9) +# Rebased from https://github.com/sphinx-doc/sphinx/commit/46372726 +Patch3: 46372726.patch + BuildArch: noarch BuildRequires: python3-devel