[PATCH] tests/mercurialapi_test.py: fix failure in Python 3.11 for inspect module (issue #5826 partial fix)

99 views
Skip to first unread message

Sergey Torokhov

unread,
Aug 17, 2022, 5:50:06 PM8/17/22
to thg...@googlegroups.com
# HG changeset patch
# User Sergey Torokhov <torokh...@yandex.ru>
# Date 1660771688 -10800
# Thu Aug 18 00:28:08 2022 +0300
# Node ID 138005449f614fcc28806a1c6b637c8620190dcf
# Parent 81a6f0507e07620bf17ebdc150907dab213d098e
tests/mercurialapi_test.py: fix failure in Python 3.11 for inspect module

The AttributeError is due to 'getargspec' is removed from 'inspect'module
in Python 3.11.

In the "What’s New In Python 3.11" [1] is mentioned
"Removed from the inspect module:
- the getargspec function, deprecated since Python 3.0; use inspect.signature()
or inspect.getfullargspec() instead."

The replacing 'getargspec' with 'getfullargspec' fix issue.
The 'signature' function of 'inspect' implemented since Python 3.3
therefore 'getfullargspec' is prefered this place as it's
implemented since 'Pyhton 3.0'

#issue: https://foss.heptapod.net/mercurial/tortoisehg/thg/-/issues/5826

[1] https://docs.python.org/3.11/whatsnew/3.11.html

diff -r 81a6f0507e07 -r 138005449f61 tests/mercurialapi_test.py
--- a/tests/mercurialapi_test.py Sat Jun 25 17:53:09 2022 +0900
+++ b/tests/mercurialapi_test.py Thu Aug 18 00:28:08 2022 +0300
@@ -5,7 +5,7 @@
from tortoisehg.util import hglib, pipeui

def test_same_argspec(f, g):
- fa, ga = inspect.getargspec(f), inspect.getargspec(g)
+ fa, ga = inspect.getfullargspec(f), inspect.getfullargspec(g)
assert fa == ga, '%s != %s' % (inspect.formatargspec(*fa),
inspect.formatargspec(*ga))

stor...@gmail.com

unread,
Aug 17, 2022, 5:55:04 PM8/17/22
to TortoiseHg Developers
Sorry, it seems spaces are trimmed from text message.
I  attach the patch as file.
mercurialapi_test.patch

Yuya Nishihara

unread,
Aug 17, 2022, 8:51:48 PM8/17/22
to Sergey Torokhov, thg...@googlegroups.com
On Thu, 18 Aug 2022 00:49:53 +0300, Sergey Torokhov wrote:
> # HG changeset patch
> # User Sergey Torokhov <torokh...@yandex.ru>
> # Date 1660771688 -10800
> # Thu Aug 18 00:28:08 2022 +0300
> # Node ID 138005449f614fcc28806a1c6b637c8620190dcf
> # Parent 81a6f0507e07620bf17ebdc150907dab213d098e
> tests/mercurialapi_test.py: fix failure in Python 3.11 for inspect module

Queued for stable, thanks.
Reply all
Reply to author
Forward
0 new messages