[pypy-dev] pypy specific code flags DONT_IMPLY_DEDENT and SOURCE_IS_UTF8

Rocky Bernstein rb at dustyfeet.com
Mon Dec 16 05:57:19 EST 2019


I did a little test, and for this program:

# from 3.7 test_asyncgen.py
def test_async_gen_iteration_01(self):
    async def gen():
        await awaitable()
        a = yield 123

the 3.6 ASYNC_GENERATOR flag  is added in the code object created for
"gen()" as 3.6 does. So I infer that flag 0x200  in a code object doesn't
imply the PYPY_DONT_IMPLY_DEDENT property. Does that mean that in 3.6
PYPY_DON'T_IMPLY_DEDENT flag will *never *appear in a code object? Or just
for 3.6 and above or for all Pypy versions?

I don't want to try guessing what the principle being used is looking at
all versions of Pypy across all the pypy-specific flags listed
in pypy/interpreter/astcompiler/consts.py if there is a principle being
followed and someone can just tell me what it is or point to a document
that describes what's up here.


On Mon, Dec 16, 2019 at 5:33 AM Armin Rigo <armin.rigo at gmail.com> wrote:

> Hi,
>
> On Mon, 16 Dec 2019 at 11:24, Rocky Bernstein <rb at dustyfeet.com> wrote:
> > I have a cross-version Python bytecode disassembler xdis (
> https://pypi.org/project/xdis/) and I notice that flags 0x0100 and 0x0200
> (DONT_IMPLY_DEDENT and SOURCE_IS_UTF8 respectively) conflict in Pypy 3.6
> with Python 3.6's  ITERABLE_COROUTINE and ASYNC_GENERATOR.
>
> Looking in the CPython 3.6 source code, I see that
> PyCF_DONT_IMPLY_DEDENT = 0x0200 as well there, even though
> ``inspect.CO_ASYNC_GENERATOR`` is also 0x0200.  The same with
> PyCF_SOURCE_IS_UTF8 = 0x0100 and ``inspect.CO_ITERABLE_COROUTINE``.
> So the conflict you're talking about seems to exist in CPython 3.6
> too.
>
> Can you give us a concrete example of code where CPython 3.6 differs
> from PyPy 3.6?


CPython 3.6 bytecode differs from PyPy 3.6 bytecode and so far as I know it
CPython bytecode version x.y differs from Pypy  version x.y Otherwise I
wouldn't have to go through the extra effort to try to add code to make
Pypy disassembly and decompilation possible in a cross-version way. I have
for example that there are opcodes FORMAT_VALUE, BUILD_STRING and
JUMP_IF_NOT_DEBUG for example in Pypy3.6 that are not in CPython (among I
think other opcodes).

But again I'd prefer not to guess this kind of thing if it is documented
somewhere or someone who knows this already can just let me know.




>
> A bientôt,
>
> Armin.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20191216/b794a2a4/attachment.html>


More information about the pypy-dev mailing list