View | Details | Raw Unified | Return to bug 257770
Collapse All | Expand All

(-)b/textproc/py-sphinx/Makefile (+1 lines)
Lines 2-7 Link Here
2
2
3
PORTNAME=	sphinx
3
PORTNAME=	sphinx
4
PORTVERSION=	3.5.2
4
PORTVERSION=	3.5.2
5
PORTREVISION=	1
5
PORTEPOCH=	1
6
PORTEPOCH=	1
6
CATEGORIES=	textproc python
7
CATEGORIES=	textproc python
7
MASTER_SITES=	CHEESESHOP
8
MASTER_SITES=	CHEESESHOP
(-)b/textproc/py-sphinx/files/patch-sphinx_util_typing.py (-1 / +58 lines)
Added Link Here
0
- 
1
From 8b2031c747e7c7e6b845ee2e3db47de617d33cc6 Mon Sep 17 00:00:00 2001
2
From: Takeshi KOMIYA <i.tkomiya@gmail.com>
3
Date: Fri, 30 Jul 2021 01:27:38 +0900
4
Subject: [PATCH] Fix #9512: sphinx-build: crashed with the HEAD of Python 3.10
5
6
Recently, `types.Union` was renamed to `types.UnionType` on the HEAD
7
of 3.10 (refs: python/cpython#27342). After this change, sphinx-build
8
has been crashed because of ImportError.
9
--- CHANGES.orig	2021-03-06 11:59:38 UTC
10
+++ CHANGES
11
@@ -419,6 +419,8 @@ Bugs fixed
12
 * #6914: figure numbers are unexpectedly assigned to uncaptioned items
13
 * #8320: make "inline" line numbers un-selectable
14
 
15
+* #9512: sphinx-build: crashed with the HEAD of Python 3.10
16
+
17
 Testing
18
 --------
19
 
20
 CHANGES               |  2 ++
21
 sphinx/util/typing.py | 12 ++++++------
22
 2 files changed, 8 insertions(+), 6 deletions(-)
23
24
--- sphinx/util/typing.py.orig	2021-03-06 11:58:24 UTC
25
+++ sphinx/util/typing.py
26
@@ -30,10 +30,10 @@ else:
27
             ref = _ForwardRef(self.arg)
28
             return ref._eval_type(globalns, localns)
29
 
30
-if sys.version_info > (3, 10):
31
-    from types import Union as types_Union
32
-else:
33
-    types_Union = None
34
+try:
35
+    from types import UnionType  # type: ignore  # python 3.10 or above
36
+except ImportError:
37
+    UnionType = None
38
 
39
 if False:
40
     # For type annotation
41
@@ -107,7 +107,7 @@ def restify(cls: Optional["Type"]) -> str:
42
         return ':class:`struct.Struct`'
43
     elif inspect.isNewType(cls):
44
         return ':class:`%s`' % cls.__name__
45
-    elif types_Union and isinstance(cls, types_Union):
46
+    elif UnionType and isinstance(cls, UnionType):
47
         if len(cls.__args__) > 1 and None in cls.__args__:
48
             args = ' | '.join(restify(a) for a in cls.__args__ if a)
49
             return 'Optional[%s]' % args
50
@@ -349,7 +349,7 @@ def _stringify_py37(annotation: Any) -> str:
51
     elif hasattr(annotation, '__origin__'):
52
         # instantiated generic provided by a user
53
         qualname = stringify(annotation.__origin__)
54
-    elif types_Union and isinstance(annotation, types_Union):  # types.Union (for py3.10+)
55
+    elif UnionType and isinstance(annotation, UnionType):  # types.Union (for py3.10+)
56
         qualname = 'types.Union'
57
     else:
58
         # we weren't able to extract the base type, appending arguments would

Return to bug 257770