Issue 6712: sys._getframe is not available on all Python implementations (original) (raw)

Created on 2009-08-16 10:44 by johannes.janssen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (9)
msg91629 - (view) Author: Johannes Janssen (johannes.janssen) Date: 2009-08-16 10:44
As I learned on the mailing list the function sys._getframe() is not available on all Python implementations (e.g. jython). This information should be added to the documentation.
msg91641 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2009-08-16 18:55
The leading underscore is meant to convey that it is not guaranteed to exist. But in spite of this, we do plan long-term to make it explicit what all interpreters are expected to (not) support.
msg91647 - (view) Author: Tobias Ivarsson (thobe) * Date: 2009-08-16 22:01
While it is true that not all Python implementations support sys._getframe() in some or all execution modes, Jython does support it, even IronPython supports it with the proper startup parameters these days. More importantly sys._getframe() [or something equivalent] *is* available as a public API in the inspect module of Python, as inspect.currentframe(). I don't know why the inspect module is not brought up in the discussions about sys._getframe(), but it is a public API. Would this mean that introspecting callframes is something all interpreters are expected to support? Brett: what is your opinion? Perhaps I should move this discussion to the mailing list?
msg91648 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2009-08-16 22:11
Yeah I'd take this to the list. Perhaps this is destined to be a public API.
msg91649 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-08-16 22:24
It's actually quite annoying that inspect takes a private API (that has warnings in the documentation about its use) and makes it public. It's just a direct alias. That in itself is not a good reason to say the _getframe should be public. Python frames are not available by *default* in Python, because of the performance cost of using them.
msg91651 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2009-08-16 23:16
It sounds like inspect needs to have its docs updated such that it makes it explicit inspect.currentframe() requires sys._getframe() to exist to return anything of use (the code returns None in other cases). So the public API can exist, but it needs to say what it depends on is optional.
msg91652 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-08-16 23:23
I meant in IronPython of course. D'oh. Anyway, I made the change to inspect to keep it compatible with IronPython so I can make the documentation change. A mention in the sys._getframe docs that it is not guaranteed to exist across implementations would be useful. I'll add that unless there are major objections.
msg91653 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2009-08-16 23:34
On Sun, Aug 16, 2009 at 16:23, Michael Foord<report@bugs.python.org> wrote: > > Michael Foord <michael@voidspace.org.uk> added the comment: > > I meant in IronPython of course. D'oh. Anyway, I made the change to > inspect to keep it compatible with IronPython so I can make the > documentation change. > > A mention in the sys._getframe docs that it is not guaranteed to exist > across implementations would be useful. I'll add that unless there are > major objections. You won't get objections as that's what the code does. I say just do it and if people actually object we can back out the commit.
msg92572 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-09-13 16:46
Committed revision 74781.
History
Date User Action Args
2022-04-11 14:56:51 admin set github: 50961
2009-09-13 16:46:42 michael.foord set status: open -> closedresolution: acceptedmessages: +
2009-08-16 23:34:02 brett.cannon set messages: +
2009-08-16 23:23:06 michael.foord set messages: +
2009-08-16 23:16:48 brett.cannon set messages: +
2009-08-16 22:24:23 michael.foord set nosy: + michael.foordmessages: +
2009-08-16 22:11:05 gregory.p.smith set nosy: + gregory.p.smithmessages: +
2009-08-16 22:01:29 thobe set nosy: + thobemessages: +
2009-08-16 18:55:01 brett.cannon set nosy: + brett.cannonmessages: +
2009-08-16 11:12:55 cvrebert set nosy: + cvrebert
2009-08-16 10:44:19 johannes.janssen create