A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-February/012593.html below:

[Python-Dev] Identifying magic prefix on Python files?

[Python-Dev] Identifying magic prefix on Python files?Fredrik Lundh fredrik@effbot.org
Mon, 5 Feb 2001 07:35:02 +0100
tim wrote:
> Then you have /F's post, which purports to give a "fully backward
> compatible" scheme, despite changing what probably appears <wink> to be
> almost everyting.

unlike earlier proposals, it doesn't break py_compile:

    MAGIC = imp.get_magic()

    fc = open(cfile, 'wb')
    fc.write('\0\0\0\0')
    wr_long(fc, timestamp)
    marshal.dump(codeobject, fc)
    fc.flush()
    fc.seek(0, 0)
    fc.write(MAGIC)
    fc.close()

and it doesn't break imputil:

    f = open(file, 'rb')
    if f.read(4) == imp.get_magic():
        t = struct.unpack('<I', f.read(4))[0]
        if t == t_py:
            code = marshal.load(f)

and it doesn't break any user code that does similar things
(squeeze, pythonworks, and a dozen other tools I've written;
applications using local copies of imputils, etc)

Cheers /F




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4