Skip to content

[Feature Request]: Implement sys._getframemodulename #976

@jonathandung

Description

@jonathandung

Describe the feature

Though the function in question, introduced in Python 3.12, is documented not to be available on all implementations of Python, I believe it to be relatively straightforward to implement when GraalPy already supports frames.

Expected behavior

There would be a function named _getframemodulename, available in the sys module, that would return the name of the module from which it was called by default, or the module of the caller n frames up if the sole argument depth is passed, or None if the module name cannot be determined.

Additional context

As demonstrated in the Python 3.14.6 coloured REPL:

Python 3.14.6 (tags/v3.14.6:c63aec6, Jun 10 2026, 10:26:10) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from sys import _getframemodulename
>>> for i in range(7): print(i, _getframemodulename(i))
... 
0 __main__
1 _pyrepl.console
2 _pyrepl.console
3 code
4 _pyrepl.simple_interact
5 _pyrepl.main
6 None

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions