18 Jun 2017
Our team has recently found a corrupted PYC (compiled Python) file on windows.
I've found the issue because it complained that certain obvious methods didn't exist; it was soo improbable that I needed to check the PYC file. The decompiled PYC file contains only one line of code:
I guess the problem is destined to happen when multiple processes try to use the same file, and, thus, create pyc files at the same time. Especially, when windows' file locking mechanism is a bit off (e.g. can't move file while a file is written). I'm too lazy to figure out the exact root cause.
Also, I couldn't believe the process of pyc creation is not rock-solid.
uncompyle6 decompiles an empty python to a file contains
(ENV) [tanin0] ~ 09:50:10 $ rm -f test.py test.pyc (ENV) [tanin0] ~ 09:50:49 $ touch test.py (ENV) [tanin0] ~ 09:50:51 $ python -m compileall test.py Compiling test.py ... (ENV) [tanin0] ~ 09:50:58 $ uncompyle6 test.pyc # uncompyle6 version 2.10.1 # Python bytecode 2.7 (62211) # Decompiled from: Python 2.7.6 (default, Oct 26 2016, 20:30:19) # [GCC 4.8.4] # Embedded file name: test.py # Compiled at: 2017-06-19 09:50:51 pass # okay decompiling test.pyc