[Python-Dev] Is there a reference manual for Python bytecode?

Brett Cannon brett at python.org
Sun Dec 27 19:51:29 EST 2015


You can look at https://docs.python.org/devguide/compiler.html to see if
you missed something.

As for the _frozen_importlib problem, that typically manifests itself when
you have invalid bytecode (that module is frozen bytecode that gets
compiled into the interpreter and is the first bit of Python code that gets
run).

On Sun, 27 Dec 2015, 16:41 Guido van Rossum <gvanrossum at gmail.com> wrote:

> Can you show the diffs you have so far? Somebody's got to look at your
> code.
>
> --Guido (mobile)
> On Dec 27, 2015 16:51, "Erik" <python at lucidity.plus.com> wrote:
>
>> Thanks for your help so far (I'm experimenting with the peephole
>> optimizer - hence my question before as I was trying to work out how to
>> know what the small integer hard-coded offsets should be when looking ahead
>> in the bytecode).
>>
>>
>> I've successfully added a new opcode (generated by the optimizer and
>> understood by the interpreter loop) but when adding a second I unexpectedly
>> got the following error. I'm not doing anything different to what I did
>> with the first opcode as far as I can tell (I have a TARGET(FOO) in ceval.c
>> and have obviously defined the new opcode's value in opcode.h).
>>
>>
>> """
>> ./python -E -S -m sysconfig --generate-posix-vars ;\
>>         if test $? -ne 0 ; then \
>>                 echo "generate-posix-vars failed" ; \
>>                 rm -f ./pybuilddir.txt ; \
>>                 exit 1 ; \
>>         fi
>> XXX lineno: 241, opcode: 1
>> Fatal Python error: Py_Initialize: can't import _frozen_importlib
>> Traceback (most recent call last):
>>   File "<frozen importlib._bootstrap>", line 698, in <module>
>>   File "<frozen importlib._bootstrap>", line 751, in BuiltinImporter
>>   File "<frozen importlib._bootstrap>", line 241, in _requires_builtin
>> SystemError: unknown opcode
>> Aborted (core dumped)
>> generate-posix-vars failed
>> make: *** [pybuilddir.txt] Error 1
>> """
>>
>> If I #ifdef out the code in peephole.c which generates my new (2nd)
>> opcode, then the error does not occur. I tried a "make clean" first, but
>> that didn't help (I realise that does not necessarily rule out a makefile
>> dependency issue).
>>
>> Does anyone know if this is a well-known symptom of forgetting to add
>> something somewhere when adding a new opcode, or do I need to track it down
>> some more myself? I did not have this problem when introducing my first new
>> opcode.
>>
>> Thanks, E.
>> _______________________________________________
>> Python-Dev mailing list
>> Python-Dev at python.org
>> https://mail.python.org/mailman/listinfo/python-dev
>>
> Unsubscribe:
>> https://mail.python.org/mailman/options/python-dev/guido%40python.org
>>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/brett%40python.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20151228/b3921db4/attachment.html>


More information about the Python-Dev mailing list