Patchwork [stable] doc: inspect.getargspec has been removed in Python 3.11

login
register
mail settings
Submitter Mads Kiilerich
Date Feb. 5, 2022, 1:23 p.m.
Message ID <e3c50cc1facafbd13120.1644067413@xps>
Download mbox | patch
Permalink /patch/50467/
State New
Headers show

Comments

Mads Kiilerich - Feb. 5, 2022, 1:23 p.m.
# HG changeset patch
# User Mads Kiilerich <mads@kiilerich.com>
# Date 1644066813 -3600
#      Sat Feb 05 14:13:33 2022 +0100
# Branch stable
# Node ID e3c50cc1facafbd13120b7693155add1af9f94ed
# Parent  01fde63b4eded708802bfd0d0d4cb4ecc5ff6e1c
doc: inspect.getargspec has been removed in Python 3.11

Fix problem left over from 646002338365.

Reported for Fedora on https://bugzilla.redhat.com/show_bug.cgi?id=2022252#c2 .
Yuya Nishihara - Feb. 6, 2022, 10:40 a.m.
On Sat, 05 Feb 2022 14:23:33 +0100, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <mads@kiilerich.com>
> # Date 1644066813 -3600
> #      Sat Feb 05 14:13:33 2022 +0100
> # Branch stable
> # Node ID e3c50cc1facafbd13120b7693155add1af9f94ed
> # Parent  01fde63b4eded708802bfd0d0d4cb4ecc5ff6e1c
> doc: inspect.getargspec has been removed in Python 3.11
> 
> Fix problem left over from 646002338365.
> 
> Reported for Fedora on https://bugzilla.redhat.com/show_bug.cgi?id=2022252#c2 .
> 
> diff --git a/doc/hgmanpage.py b/doc/hgmanpage.py
> --- a/doc/hgmanpage.py
> +++ b/doc/hgmanpage.py
> @@ -177,7 +177,11 @@ class Translator(nodes.NodeVisitor):
>          nodes.NodeVisitor.__init__(self, document)
>          self.settings = settings = document.settings
>          lcode = settings.language_code
> -        arglen = len(inspect.getargspec(languages.get_language)[0])
> +        try:
> +            getfullargspec = inspect.getfullargspec
> +        except:  # Python 2
           ^^^^^^
check-code complains about naked except clause.

I think it's okay to drop support for old docutils. cdda48c93676 says this
hack is for Docutils < 0.8.

Patch

diff --git a/doc/hgmanpage.py b/doc/hgmanpage.py
--- a/doc/hgmanpage.py
+++ b/doc/hgmanpage.py
@@ -177,7 +177,11 @@  class Translator(nodes.NodeVisitor):
         nodes.NodeVisitor.__init__(self, document)
         self.settings = settings = document.settings
         lcode = settings.language_code
-        arglen = len(inspect.getargspec(languages.get_language)[0])
+        try:
+            getfullargspec = inspect.getfullargspec
+        except:  # Python 2
+            getfullargspec = inspect.getargspec
+        arglen = len(getfullargspec(languages.get_language)[0])
         if arglen == 2:
             self.language = languages.get_language(
                 lcode, self.document.reporter