This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barry
Recipients JelleZijlstra, Mark.Shannon, barry
Date 2022-02-08.01:56:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
> Usually the calling function object should be enough.

I want to at least provide some historical context on why sys._getframe() exists.  I originally wrote that to support PEP 292 and internationalization in Mailman.  This has since been extracted into the flufl.i18n package.  Here is the use of sys._getframe() in that library:

https://gitlab.com/warsaw/flufl.i18n/-/blob/main/src/flufl/i18n/_translator.py#L65

You can see that the reason this exists is to dig out the local and globals of the context in which the _() function is invoked.  This greatly reduces the need to repeat yourself in i18n call sites.

https://flufli18n.readthedocs.io/en/stable/using.html#substitutions-and-placeholders

I'm not saying sys._getfunc() is or isn't useful, but it won't change original need for sys._getframe().
History
Date User Action Args
2022-02-08 01:56:28barrysetrecipients: + barry, Mark.Shannon, JelleZijlstra
2022-02-08 01:56:28barrysetmessageid: <[email protected]>
2022-02-08 01:56:28barrylinkissue46543 messages
2022-02-08 01:56:28barrycreate