Re: Re: problems with trackback

Eric Gaumer <gaumerel-rO34MGDSYikxZu/[email protected]>
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <[email protected]>
Eric Gaumer wrote:
>
> Anybody know where I could get a list of magic numbers for each python
> release? I would assume it has to be in the python source code somewhere.
>

I found these values in import.c

       Python 1.5:   20121
       Python 1.5.1: 20121
       Python 1.5.2: 20121
       Python 2.0:   50823
       Python 2.0.1: 50823
       Python 2.1:   60202
       Python 2.1.1: 60202
       Python 2.1.2: 60202
       Python 2.2:   60717
       Python 2.3a0: 62011
       Python 2.3a0: 62021
       Python 2.3a0: 62011
       Python 2.4a0: 62041
       Python 2.4a3: 62051
       Python 2.4b1: 62061

This is a list of magic numbers for each major release. So
2.3a0 (62011) would show up as:

0xF2 3B 0D 0A

The OD OA is a carriage return line feed pair which is what actually
causes the bad magic error. If the file is read with an incorrect mode,
it will throw a bad magic error and prevent the file from being loaded.

All the numbers in the above list are base ten representations of the
first two bytes. The second two are always a \r\n pair (it's hard to
believe we still use carriage returns in modern computer systems). Keep
endianess in mind when you look at this.

Python byte code seems to be little-endian even on big-endian machines.
I am on a Mac G4 running Linux and this actually pans out here. I also
found this for the Python C API:

long PyImport_GetMagicNumber()
    Return the magic number for Python bytecode files (a.k.a. .pyc and .pyo files).
    The magic number should be present in the first four bytes of the bytecode file,
    in little-endian byte order.

Sorry for rambling on such off topic nonsense.

	-Eric

--
"Education is what remains after one has forgotten everything he learned in school."
	- Albert Einstein
signature.asc (application/pgp-signature, 256 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCWVY1ZWL8hfFdQekRAgzWAJ48iZN2+ySKXEB5jdXIkRbsxMPNXgCguLBZ
XVKOvlfgtoKq+z3VU8BC65E=
=HOcD
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.