[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor
STINNER Victor added the comment: I proposed GH-31198 to fix the compiler warnings in the doc. -- ___ Python tracker ___ ___ Python

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor
Change by STINNER Victor : -- keywords: +patch pull_requests: +29369 stage: -> patch review pull_request: https://github.com/python/cpython/pull/31198 ___ Python tracker ___ _

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor
STINNER Victor added the comment: > Is there anyway to get the PyObject* associated with a PyFrameObject*? Ah. I see. If you pass a PyFrameObject* frame to PyObject_GetAttrString(), you get a compiler warning. You should cast it explicitly: PyObject_GetAttrString((PyObject*)frame, "f_locals

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread STINNER Victor
STINNER Victor added the comment: Example of C code that I added to _testcapi: --- static PyObject * get_caller_locals(PyObject *self, PyObject *Py_UNUSED(args)) { PyFrameObject *frame = PyThreadState_GetFrame(PyThreadState_Get()); if (frame == NULL) { Py_RETURN_NONE; }

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-07 Thread Aaron Gokaslan
Aaron Gokaslan added the comment: The frame object I am referring to was: PyFrameObject *frame = PyThreadState_GetFrame(PyThreadState_Get()); This frame can not be used with PyObject_GetAttrString. Is there anyway to get the PyObject* associated with a PyFrameObject*? It seems weird that som

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-04 Thread STINNER Victor
STINNER Victor added the comment: > PyObject_GetAttrString(frame, "f_locals") doesn't work for PyFrameObject* Oh, would you mind to elaborate? Example in Python: $ ./python Python 3.11.0a5+ >>> import sys >>> f=sys._getframe() >>> f.f_locals {'__name__': '__main__', '__doc__': None, ...} -

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-02-04 Thread Aaron Gokaslan
Aaron Gokaslan added the comment: I saw the latest Python 3.11 5A release notes on the frame API changes. Do the notes mean the only officially supported way of accessing co_varnames is now through the Python interface and the inspect module? By using PyObject_GetAttrString? Also, the docum

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-01-31 Thread STINNER Victor
STINNER Victor added the comment: It would be nice to have a PyFrame_GetVariable(frame, "self") function: get the value of the "frame" variable of the specified frame object. -- ___ Python tracker _

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-01-31 Thread Aaron Gokaslan
Aaron Gokaslan added the comment: `PyCodeObject_GetVariableName()` and `PyCodeObject_GetVariableKind()` work? - Some public-gettters such as these functions would be ideal. OOI, how do you cope with non-local self? - We only care about checking self to prevent an infinite recursion in our

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-01-31 Thread Aaron Gokaslan
Aaron Gokaslan added the comment: We didn't want to read colocalsplus directly because we were worried about the stability of that approach and the code complexity / readability. Also, I wasn't aware that colocalsplus would work or if that was lazily populated as well. The functions used i

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-01-27 Thread Gregory P. Smith
Change by Gregory P. Smith : -- keywords: +3.11regression nosy: +gregory.p.smith priority: normal -> high ___ Python tracker ___ ___

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-01-27 Thread Eric Snow
Eric Snow added the comment: In addition to what Mark said, note that co_varnames get's populated lazily by the Python-level getter for code.co_varnames. So could you call the Python function before entering the hot path? Regardless, a dedicated C-API for this like Mark suggested would be t

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-01-27 Thread Mark Shannon
Mark Shannon added the comment: Yes, we should expose the tuple of variable names, both in Python and in the C-API. Would something like `PyCodeObject_GetVariableName()` and `PyCodeObject_GetVariableKind()` work? In the meantime, since you were reading `co_varnames` directly, why not read

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-01-27 Thread Henry Schreiner
Henry Schreiner added the comment: It would be great to get this looked at before things start getting too locked in for 3.11! -- ___ Python tracker ___ _

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2022-01-06 Thread Mark Shannon
Change by Mark Shannon : -- nosy: +eric.snow ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyt

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2021-12-27 Thread Dong-hee Na
Change by Dong-hee Na : -- nosy: +vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2021-12-24 Thread Terry J. Reedy
Terry J. Reedy added the comment: Pablo, Mark: I am guessing that at least one of you know about this. -- nosy: +Mark.Shannon, pablogsal, terry.reedy ___ Python tracker ___ __

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2021-12-23 Thread Henry Schreiner
Change by Henry Schreiner : -- nosy: +Henry Schreiner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:/

[issue46166] Get "self" args or non-null co_varnames from frame object with C-API

2021-12-23 Thread Aaron Gokaslan
New submission from Aaron Gokaslan : Hello, I am a maintainer with the PyBind11 project. We have been following the 3.11 development branch and have noticed an issue we are encountering with changes to the C-API. Particularly, we have an edge case in our overloading dispatch mechanism that