Closed warsaw closed 23 years ago
My only comment on the docs (both docstring and LaTeX) is that it should say "ValueError is raised" rather than "a ValueError is raised" (drop the "a"). Otherwise looks good; I've not run it through the formatting.
The docstring and docs should say that the default depth is zero. They should also mention that this is for internal use only. Can you implement this in Jython too?
I disagree with Ping. The function needs to be clearly marked as non-public-API -- it's an interface that should be used only to implement a few blessed higher-level library modules.
It differs from getrefcount(), which is harmless, and exc_info(), which is intended to be used in preference to exc_type etc. (in order to be thread-safe).
BTW, I'm accepting the patch -- I don't know why it hasn't been checked in yet. (The doc changes suggested should still be made.)
This patch adds a function to the sys module which will return a frame object. By default, it returns the frame object of the current stack frame, but an optional integer argument can be supplied to retrieve any frame higher up the stack. If the integer is greater than the depth of the stack, a ValueError is raised.
Good point. Patch updated. Thanks.
Oops, fixed one small typo.
Checking in now. sysmodule.c 2.79 libsys.tex 1.43
It's a small point, but i'd much prefer the function to be called sys.getframe() rather than sys._getframe(). There aren't any other functions in sys that begin with an underscore, and it's understood that routines in sys manipulate the Python interpreter system anyway (such as getrefcount or exc_info). This routine isn't private within sys; it's exported by sys, so it should be called sys.getframe().
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = 'https://github.com/warsaw' closed_at =
created_at =
labels = ['interpreter-core']
title = 'sys._getframe() for getting the current stack frame'
updated_at =
user = 'https://github.com/warsaw'
```
bugs.python.org fields:
```python
activity =
actor = 'barry'
assignee = 'barry'
closed = True
closed_date = None
closer = None
components = ['Interpreter Core']
creation =
creator = 'barry'
dependencies = []
files = ['2901']
hgrepos = []
issue_num = 402106
keywords = ['patch']
message_count = 9.0
messages = ['34707', '34708', '34709', '34710', '34711', '34712', '34713', '34714', '34715']
nosy_count = 4.0
nosy_names = ['gvanrossum', 'fdrake', 'ping', 'barry']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue402106'
versions = []
```