From 4a3942b0d7ecc8eba429e5daa516a15fc64950ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Sat, 5 Dec 2020 22:51:06 +0100 Subject: [PATCH 1/2] bpo-42579: Make workaround for various versions of Sphinx more robust The solution in gh#python/cpython#13236 is too strict, because it effectively requires use of Sphinx >= 2.0. It is not too difficult to make the same solution more robust so it works with all normal versions of Sphinx. --- Doc/tools/extensions/pyspecific.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 80fbd96d56fdc0..52b17ab8277fac 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -394,7 +394,12 @@ def run(self): translatable=False) node.append(para) env = self.state.document.settings.env - env.get_domain('changeset').note_changeset(node) + # new method + if hasattr(env, 'get_domain'): + env.get_domain('changeset').note_changeset(node) + # deprecated pre-Sphinx-2 method + else: + env.note_versionchange('deprecated', version[0], node, self.lineno) return [node] + messages From 97802bc18558c02adac75fedd49ebdf615a9b575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Mon, 7 Dec 2020 19:47:52 +0100 Subject: [PATCH 2/2] Turn the condition in DeprecatedRemoved.run() method around. --- Doc/tools/extensions/pyspecific.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 52b17ab8277fac..28994399e25cf9 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -394,12 +394,12 @@ def run(self): translatable=False) node.append(para) env = self.state.document.settings.env - # new method - if hasattr(env, 'get_domain'): - env.get_domain('changeset').note_changeset(node) # deprecated pre-Sphinx-2 method - else: + if hasattr(env, 'note_versionchange'): env.note_versionchange('deprecated', version[0], node, self.lineno) + # new method + else: + env.get_domain('changeset').note_changeset(node) return [node] + messages