Sounds good. Thanks! On Wed, Jul 21, 2021 at 5:19 AM Nick Coghlan <ncogh...@gmail.com> wrote:
> On Mon, 19 Jul 2021 at 21:32, Petr Viktorin <encu...@gmail.com> wrote: > > The proposal assumes that in the future, ``PyLocals_Get``, and thus > > ``locals()``, will never gain another kind of return value, however > > unlikely that is. > > AFAICS, code that uses this will usually check for a single special case > > and fall back (or error) for the other(s), so I think it'd be reasonable > > to make this an "enum" with two values. e.g.: > > > > int PyLocals_GetReturnBehavior(); # better name? > > #define PyLocals_DIRECT_REFERENCE 0 > > #define PyLocals_SHALLOW_COPY 1 > > After looking at PyUnicode_Kind, PySendResult, and other already > public enums for inspiration, my proposed spelling is as follows: > > ==================== > typedef enum { > PyLocals_UNDEFINED = -1; > PyLocals_DIRECT_REFERENCE = 0, > PyLocals_SHALLOW_COPY = 1 > } PyLocals_Kind; > > PyLocals_Kind PyLocals_GetKind(void); > PyLocals_Kind PyFrame_GetLocalsKind(PyFrameObject *); > ==================== > > The PyLocals_UNDEFINED case comes from PyLocals_GetKind() needing an > error value to return when the query API is called with no active > thread state. > > I've updated the draft reference implementation to use this API, and > added the associated PEP changes to the review PR at > https://github.com/python/peps/pull/2038/files > > Cheers, > Nick. > > -- > Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia > _______________________________________________ > 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/QLPJWPVNDZ3ODMS275VDW4M2UW6PUW5N/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ 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/5KHSHQJA6V5RQUCSOM24MT4QQ7HVNTII/ Code of Conduct: http://python.org/psf/codeofconduct/