forked from pool/python-wxPython
6e6d043c2c
- add ba0d8cfcec3d3b0112d1c54991853e6003f2fbf6.patch to resolve python 3.11 build failure - add 0001-pypubsub-Replace-deprecated-inspect.getargspec.patch to fix another python 3.11 build failure OBS-URL: https://build.opensuse.org/request/show/1061720 OBS-URL: https://build.opensuse.org/package/show/X11:wxWidgets/python-wxPython?expand=0&rev=39
62 lines
2.3 KiB
Diff
62 lines
2.3 KiB
Diff
From 9986a0d5c24b5d45ddf571d60351f68765a8a9be Mon Sep 17 00:00:00 2001
|
|
From: Scott Talbert <swt@techie.net>
|
|
Date: Mon, 8 Aug 2022 22:35:58 -0400
|
|
Subject: [PATCH] pypubsub: Replace deprecated inspect.getargspec
|
|
|
|
inspect.getargspec was removed in Python 3.11. This is a backport of:
|
|
https://github.com/schollii/pypubsub/commit/089c7a73f85c76a3aa22e4b10c71db1bf65a8637
|
|
---
|
|
wx/lib/pubsub/core/callables.py | 23 +++++++++++++++--------
|
|
1 file changed, 15 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/wx/lib/pubsub/core/callables.py b/wx/lib/pubsub/core/callables.py
|
|
index 65eb1ebe..7e798c54 100644
|
|
--- a/wx/lib/pubsub/core/callables.py
|
|
+++ b/wx/lib/pubsub/core/callables.py
|
|
@@ -12,7 +12,7 @@ CallArgsInfo regarding its autoTopicArgName data member.
|
|
|
|
"""
|
|
|
|
-from inspect import getargspec, ismethod, isfunction
|
|
+from inspect import ismethod, isfunction, signature, Parameter
|
|
|
|
from .. import py2and3
|
|
|
|
@@ -133,19 +133,26 @@ class CallArgsInfo:
|
|
self.autoTopicArgName = None."""
|
|
|
|
#args, firstArgIdx, defaultVals, acceptsAllKwargs
|
|
- (allParams, varParamName, varOptParamName, defaultVals) = getargspec(func)
|
|
- if defaultVals is None:
|
|
- defaultVals = []
|
|
- else:
|
|
- defaultVals = list(defaultVals)
|
|
+ allParams = []
|
|
+ defaultVals = []
|
|
+ varParamName = None
|
|
+ varOptParamName = None
|
|
+ for argName, param in signature(func).parameters.items():
|
|
+ if param.default != Parameter.empty:
|
|
+ defaultVals.append(param.default)
|
|
+ if param.kind == Parameter.VAR_POSITIONAL:
|
|
+ varParamName = argName
|
|
+ elif param.kind == Parameter.VAR_KEYWORD:
|
|
+ varOptParamName = argName
|
|
+ else:
|
|
+ allParams.append(argName)
|
|
|
|
self.acceptsAllKwargs = (varOptParamName is not None)
|
|
self.acceptsAllUnnamedArgs = (varParamName is not None)
|
|
-
|
|
self.allParams = allParams
|
|
- del self.allParams[0:firstArgIdx] # does nothing if firstArgIdx == 0
|
|
|
|
self.numRequired = len(self.allParams) - len(defaultVals)
|
|
+ assert len(self.allParams) >= len(defaultVals)
|
|
assert self.numRequired >= 0
|
|
|
|
# if listener wants topic, remove that arg from args/defaultVals
|
|
--
|
|
2.39.0
|
|
|