[issue25083] Python can sometimes create incorrect .pyc files

tzickel report at bugs.python.org
Tue Sep 15 16:56:00 CEST 2015


tzickel added the comment:

As for the "example" .pyc just create an empty 0 byte .py file and compile it, that is the same .pyc that is created in my system (instead in my case the .py is not empty).

Just so people don't have to trace the code like I did, here is the traceback of the primary issue. Remember that my hypothesis is that fopen returns an FILE stream, that returns EOF on the first get because of an I/O error, not because the file is empty:

--> GETC is called, and gets EOF on the first try, and thus Py_UniversalNewlineFgets returns NULL
  * frame #0: 0x0000000109fe4c44 Python`Py_UniversalNewlineFgets
    frame #1: 0x0000000109fc972c Python`decoding_fgets + 321
    frame #2: 0x0000000109fc9262 Python`tok_nextc + 918
    frame #3: 0x0000000109fc830e Python`PyTokenizer_Get + 171
    frame #4: 0x0000000109fc5853 Python`parsetok + 128
    frame #5: 0x000000010a066748 Python`PyParser_ASTFromFile + 109
-> Now load_source_module has an empty AST which will get compiled to an empty code module
-> this code is optmized so we don't see the parse_source_module call
here, but write_compiled_module will be called afterwards with the empty
AST tree instead of aborting...
    frame #6: 0x000000010a05e3b5 Python`load_source_module + 671
    frame #7: 0x000000010a05f003 Python`import_submodule + 270
    frame #8: 0x000000010a05ebc6 Python`load_next + 284
    frame #9: 0x000000010a05cb5d Python`PyImport_ImportModuleLevel + 453
    frame #10: 0x000000010a042641 Python`builtin___import__ + 135
....

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25083>
_______________________________________


More information about the Python-bugs-list mailing list