[Python-Dev] What is the purpose of the _PyThreadState_Current symbol in Python 3?

Gabriele phoenix1987 at gmail.com
Sat Sep 29 12:14:22 EDT 2018


Ah ok, this might be related to Victor's observation based on the
latest sources. I haven't tested 3.7 yet, but if _PyRuntime is
available from dynsym then this is already enough.

Thanks,
Gabriele
On Sat, 29 Sep 2018 at 11:00, Nathaniel Smith <njs at pobox.com> wrote:
>
> On Fri, Sep 28, 2018 at 3:29 PM, Gabriele <phoenix1987 at gmail.com> wrote:
> > On Fri, 28 Sep 2018 at 23:12, Nathaniel Smith <njs at pobox.com> wrote:
> >> What information do you wish the interpreter provided, that would make your program simpler and more reliable?
> >
> > An exported global variable that points to the head of the
> > PyInterpreterState linked list (i.e. the return value of
> > PyInterpreterState_Head). This way my program could just look this up
> > from the dynsym section instead of scanning a dump of the bss section
> > in memory to find a possible candidate.
>
> Hmm, it looks like in 3.7+, _PyRuntime is marked PyAPI_DATA, which I
> think should make it exported from dynsym?
>
> https://github.com/python/cpython/blob/4b430e5f6954ef4b248e95bfb4087635dcdefc6d/Include/internal/pystate.h#L206
>
> And PyInterpreterState_Head is just _PyRuntime.interpreters.head. So
> maybe this is already done...
>
> -n
>
> --
> Nathaniel J. Smith -- https://vorpus.org



-- 
"Egli è scritto in lingua matematica, e i caratteri son triangoli,
cerchi, ed altre figure
geometriche, senza i quali mezzi è impossibile a intenderne umanamente parola;
senza questi è un aggirarsi vanamente per un oscuro laberinto."

-- G. Galilei, Il saggiatore.


More information about the Python-Dev mailing list