OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


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