jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1314797?usp=email )
Change subject: [bugfix] do not use sys._getframemodulename with GraalPy
......................................................................
[bugfix] do not use sys._getframemodulename with GraalPy
Bug: T432968
Change-Id: Ib6f098ff1791a4cc41f96333d54eede48740b3c5
---
M pywikibot/backports.py
M pywikibot/tools/_deprecate.py
2 files changed, 6 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/backports.py b/pywikibot/backports.py
index 7f54057..d226155 100644
--- a/pywikibot/backports.py
+++ b/pywikibot/backports.py
@@ -324,12 +324,10 @@
def _get_module_name(depth: int = 1, default: str = '__main__') -> str:
"""Return the module name of a caller frame."""
d = depth + 1
- if PYTHON_VERSION >= (3, 12):
- return (
- sys._getframemodulename(d) # type: ignore[attr-defined]
- or default
- )
+ if hasattr(sys, '_getframemodulename'):
+ return sys._getframemodulename(d) or default
+ # Python < 3.12 or GraalPy
return sys._getframe(d).f_globals.get('__name__', default)
if PYTHON_VERSION >= (3, 10):
diff --git a/pywikibot/tools/_deprecate.py b/pywikibot/tools/_deprecate.py
index 4105dc5..e9a0c71 100644
--- a/pywikibot/tools/_deprecate.py
+++ b/pywikibot/tools/_deprecate.py
@@ -736,10 +736,9 @@
source_module = target_module
elif source_module and source_module[-1] != '.':
source_module += '.'
- elif PYTHON_VERSION >= (3, 12):
- source_module = sys._getframemodulename( # type: ignore[attr-defined]
- 1) + '.'
- else:
+ elif hasattr(sys, '_getframemodulename'):
+ source_module = sys._getframemodulename(1) + '.'
+ else: # Python < 3.12 or GraalPy
source_module = sys._getframe(1).f_globals['__name__'] + '.'
if class_name:
target_module += class_name + '.'
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1314797?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ib6f098ff1791a4cc41f96333d54eede48740b3c5
Gerrit-Change-Number: 1314797
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]