Stefan, do you really need to emulate call stack with positions?
Could the __note__ string with generated Cython part of exception traceback
solve your needs (https://www.python.org/dev/peps/pep-0678/) ?

On Wed, Feb 9, 2022 at 7:46 PM Pablo Galindo Salgado <pablog...@gmail.com>
wrote:

> I can only say that currently, I am not confident to expose such an API,
> at least for co_positions, as the internal implementation is very likely to
> heavily change and we want to have the possibility of changing it between
> patch versions if required (to address bugs and other things like that).
>
> On Wed, 9 Feb 2022 at 17:38, Stefan Behnel <stefan...@behnel.de> wrote:
>
>> Pablo Galindo Salgado schrieb am 09.02.22 um 17:40:
>> >> Should there be a getter/setter for co_positions?
>> >
>> > We consider the representation of co_postions private
>>
>> Yes, and that's the issue.
>>
>>
>> > so we don't want (for now) to ad
>> > getters/setters. If you want to get the position of a instruction, you
>> can
>> > use PyCode_Addr2Location
>>
>> What Cython needs is the other direction. How can we provide the current
>> source position range for a given piece of code to an exception?
>>
>> As it stands, the way to do this is to copy the implementation details of
>> CPython into Cython in order to let it expose the specific data
>> structures
>> that CPython uses for its internal representation of code positions.
>>
>> I would prefer using an API instead that allows exposing this mapping
>> directly to CPython's traceback handling, rather than having to emulate
>> byte code positions. While that would probably be quite doable, it's far
>> from a nice interface for something that is not based on byte code.
>>
>> And that's not just a Cython issue. The same applies to Domain Specific
>> Languages or other programming languages that integrate with Python and
>> want to show users code positions for their source code.
>>
>> Stefan
>>
>> _______________________________________________
>> Python-Dev mailing list -- python-dev@python.org
>> To unsubscribe send an email to python-dev-le...@python.org
>> https://mail.python.org/mailman3/lists/python-dev.python.org/
>> Message archived at
>> https://mail.python.org/archives/list/python-dev@python.org/message/VQSWX6MFKIA3RYPSX7O6RTVC422LTJH4/
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/P7SMK5ZGFAHZMLUKW4WZNNX47CONXIQS/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
Thanks,
Andrew Svetlov
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/3RVEOQSOJRWVWEVXHM6NDW6WH7DPBGLF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to