cx_Freeze opens a compiled bytecode file, and scans for the magic number, '\xd1\xf2\r\n', but universal newline mode turns this into '\xd1\xf2\n', thus misidentifying the bytecode as Python source, which is then passed to compile, which crashes. 在"/usr/lib/pymodules/python2.6/cx_Freeze/finder.py"中的58行左右,添加: module = self._AddModule(name) module.file = path module.parent = parent + # TOTAL HACK WORKAROUND BY PETER + if fp.name.endswith(".pyc"): + print "Peter's horrible hack is activiating, forcing", fp.name, "into binary mode, and as compiled Python." + type = imp.PY_COMPILED + # Next, switch out of universal newline mode in this crazy case. + fp.close() + fp = open(fp.name, "rb") + # END TOTAL HACK if type == imp.PY_SOURCE: module.code = compile(fp.read() + "\n", path, "exec") elif type == imp.PY_COMPILED: |
|