Python 3.11: replace getargspec() with getfullargspec()
Adding two upstream fixes for Python 3.11 compatibility replacing the deprecated inspect.getargspec method.
This commit is contained in:
parent
58679981b3
commit
a45c9c811c
124
0001-replace-getargspec-with-getfullargspec.patch
Normal file
124
0001-replace-getargspec-with-getfullargspec.patch
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
From 5322413dec1ff008e0181210ddf829a6899d115d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Maurizio Lombardi <mlombard@redhat.com>
|
||||||
|
Date: Wed, 29 Jun 2022 14:38:42 +0200
|
||||||
|
Subject: [PATCH 1/2] replace getargspec() with getfullargspec()
|
||||||
|
|
||||||
|
inspect.getargspec() doesn't work anymore with Python3.11
|
||||||
|
|
||||||
|
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
|
||||||
|
---
|
||||||
|
configshell/node.py | 6 +++---
|
||||||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/configshell/node.py b/configshell/node.py
|
||||||
|
index 6af8642..811a730 100644
|
||||||
|
--- a/configshell/node.py
|
||||||
|
+++ b/configshell/node.py
|
||||||
|
@@ -1417,10 +1417,10 @@ class ConfigNode(object):
|
||||||
|
@type kparams: dict
|
||||||
|
@raise ExecutionError: When the check fails.
|
||||||
|
'''
|
||||||
|
- spec = inspect.getargspec(method)
|
||||||
|
+ spec = inspect.getfullargspec(method)
|
||||||
|
args = spec.args[1:]
|
||||||
|
pp = spec.varargs
|
||||||
|
- kw = spec.keywords
|
||||||
|
+ kw = spec.varkw
|
||||||
|
|
||||||
|
if spec.defaults is None:
|
||||||
|
nb_opt_params = 0
|
||||||
|
@@ -1460,7 +1460,7 @@ class ConfigNode(object):
|
||||||
|
"Missing required parameters %s"
|
||||||
|
% ", ".join("'%s'" % missing for missing in missing_params))
|
||||||
|
|
||||||
|
- if spec.keywords is None:
|
||||||
|
+ if kw is None:
|
||||||
|
if len(unexpected_keywords) == 1:
|
||||||
|
raise ExecutionError(
|
||||||
|
"Unexpected keyword parameter '%s'."
|
||||||
|
--
|
||||||
|
2.37.1
|
||||||
|
|
||||||
|
|
||||||
|
From 8703e265828184c34fffa1ba539602dd23ae564c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
Date: Tue, 19 Jul 2022 10:03:48 +0200
|
||||||
|
Subject: [PATCH 2/2] Replace more occurrences of getargspec() with
|
||||||
|
getfullargspec()
|
||||||
|
|
||||||
|
Follow up for f3ac914861bd605e3d634aeeb5e706abdbd39259, getargspec
|
||||||
|
was used at two more places.
|
||||||
|
|
||||||
|
Signed-off-by: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
---
|
||||||
|
configshell/node.py | 32 ++++++++++++++++----------------
|
||||||
|
1 file changed, 16 insertions(+), 16 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/configshell/node.py b/configshell/node.py
|
||||||
|
index 811a730..4f0ec9e 100644
|
||||||
|
--- a/configshell/node.py
|
||||||
|
+++ b/configshell/node.py
|
||||||
|
@@ -1575,12 +1575,12 @@ class ConfigNode(object):
|
||||||
|
@type command: str
|
||||||
|
'''
|
||||||
|
method = self.get_command_method(command)
|
||||||
|
- parameters, args, kwargs, default = inspect.getargspec(method)
|
||||||
|
- parameters = parameters[1:]
|
||||||
|
- if default is None:
|
||||||
|
+ spec = inspect.getfullargspec(method)
|
||||||
|
+ parameters = spec.args[1:]
|
||||||
|
+ if spec.defaults is None:
|
||||||
|
num_defaults = 0
|
||||||
|
else:
|
||||||
|
- num_defaults = len(default)
|
||||||
|
+ num_defaults = len(spec.defaults)
|
||||||
|
|
||||||
|
if num_defaults != 0:
|
||||||
|
required_parameters = parameters[:-num_defaults]
|
||||||
|
@@ -1605,16 +1605,16 @@ class ConfigNode(object):
|
||||||
|
syntax += optional_parameters_str
|
||||||
|
|
||||||
|
comments = []
|
||||||
|
- if args is not None:
|
||||||
|
- syntax += "[%s...] " % args
|
||||||
|
- if kwargs is not None:
|
||||||
|
- syntax += "[%s=value...] " % (kwargs)
|
||||||
|
+ if spec.varargs is not None:
|
||||||
|
+ syntax += "[%s...] " % spec.varargs
|
||||||
|
+ if spec.varkw is not None:
|
||||||
|
+ syntax += "[%s=value...] " % (spec.varkw)
|
||||||
|
|
||||||
|
default_values = ''
|
||||||
|
if num_defaults > 0:
|
||||||
|
for index, param in enumerate(optional_parameters):
|
||||||
|
- if default[index] is not None:
|
||||||
|
- default_values += "%s=%s " % (param, str(default[index]))
|
||||||
|
+ if spec.defaults[index] is not None:
|
||||||
|
+ default_values += "%s=%s " % (param, str(spec.defaults[index]))
|
||||||
|
|
||||||
|
return syntax, comments, default_values
|
||||||
|
|
||||||
|
@@ -1630,14 +1630,14 @@ class ConfigNode(object):
|
||||||
|
@rtype: ([str...], bool, bool)
|
||||||
|
'''
|
||||||
|
method = self.get_command_method(command)
|
||||||
|
- parameters, args, kwargs, default = inspect.getargspec(method)
|
||||||
|
- parameters = parameters[1:]
|
||||||
|
- if args is not None:
|
||||||
|
- free_pparams = args
|
||||||
|
+ spec = inspect.getfullargspec(method)
|
||||||
|
+ parameters = spec.args[1:]
|
||||||
|
+ if spec.varargs is not None:
|
||||||
|
+ free_pparams = spec.varargs
|
||||||
|
else:
|
||||||
|
free_pparams = False
|
||||||
|
- if kwargs is not None:
|
||||||
|
- free_kparams = kwargs
|
||||||
|
+ if spec.varkw is not None:
|
||||||
|
+ free_kparams = spec.varkw
|
||||||
|
else:
|
||||||
|
free_kparams = False
|
||||||
|
self.shell.log.debug("Signature is %s, %s, %s."
|
||||||
|
--
|
||||||
|
2.37.1
|
||||||
|
|
@ -6,9 +6,10 @@ License: ASL 2.0
|
|||||||
Summary: A framework to implement simple but nice CLIs
|
Summary: A framework to implement simple but nice CLIs
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Version: 1.1.29
|
Version: 1.1.29
|
||||||
Release: 8%{?dist}
|
Release: 9%{?dist}
|
||||||
URL: https://github.com/open-iscsi/configshell-fb
|
URL: https://github.com/open-iscsi/configshell-fb
|
||||||
Source: %{url}/archive/v%{version}/%{oname}-%{version}.tar.gz
|
Source: %{url}/archive/v%{version}/%{oname}-%{version}.tar.gz
|
||||||
|
Patch0: 0001-replace-getargspec-with-getfullargspec.patch
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
BuildRequires: python3-devel python3-setuptools
|
BuildRequires: python3-devel python3-setuptools
|
||||||
@ -28,6 +29,7 @@ Requires: python3-pyparsing python3-urwid
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n %{oname}-%{version}
|
%setup -q -n %{oname}-%{version}
|
||||||
|
%patch0 -p1
|
||||||
|
|
||||||
sed -r -i "s/'pyparsing.*'/'pyparsing'/" setup.py
|
sed -r -i "s/'pyparsing.*'/'pyparsing'/" setup.py
|
||||||
|
|
||||||
@ -42,6 +44,9 @@ sed -r -i "s/'pyparsing.*'/'pyparsing'/" setup.py
|
|||||||
%doc COPYING README.md
|
%doc COPYING README.md
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Aug 03 2022 Vojtech Trefny <vtrefny@redhat.com> - 1:1.1.29-9
|
||||||
|
- Python 3.11: replace getargspec() with getfullargspec()
|
||||||
|
|
||||||
* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1:1.1.29-8
|
* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1:1.1.29-8
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user