[File] [PATCH] python: Include the actual magic number in output

Michał Górny mgorny at gentoo.org
Sun Jun 16 14:42:17 UTC 2024


While we don't want to get all detailed on magic changes over alpha/beta
versions, it is sometimes useful.  In particular, when these changes
over beta versions and you want to know whether a particular file was
built with 3.13.0b1 or 3.13.0b2.
---
 magic/Magdir/python | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/magic/Magdir/python b/magic/Magdir/python
index af126948..b40a4ba8 100644
--- a/magic/Magdir/python
+++ b/magic/Magdir/python
@@ -191,6 +191,7 @@
 
 # magic 3392+ implements PEP 552: Deterministic pycs
 0	name		pyc-pep552
+>0	uleshort	x	(magic: %04d),
 # the flag field determines how .pyc validity is checked
 >4	ulelong&1	0		timestamp-based,
 >>8	uledate		x		.py timestamp: %s UTC,
@@ -208,28 +209,28 @@
 >>1		ubyte		0x0d		Byte-compiled Python module for
 !:mime application/x-bytecode.python
 # now look at the magic number to determine the version
->>>0		uleshort	<3400		CPython 3.7,
+>>>0		uleshort	<3400		CPython 3.7
 >>>0		default		x
->>>>0		uleshort	<3420		CPython 3.8,
+>>>>0		uleshort	<3420		CPython 3.8
 >>>>0		default		x
->>>>>0		uleshort	<3430		CPython 3.9,
+>>>>>0		uleshort	<3430		CPython 3.9
 >>>>>0		default		x
->>>>>>0		uleshort	<3450		CPython 3.10,
+>>>>>>0		uleshort	<3450		CPython 3.10
 >>>>>>0		default		x
->>>>>>>0	uleshort	<3500		CPython 3.11,
+>>>>>>>0	uleshort	<3500		CPython 3.11
 >>>>>>>0	default		x
->>>>>>>>0	uleshort	<3550		CPython 3.12,
+>>>>>>>>0	uleshort	<3550		CPython 3.12
 >>>>>>>>0	default		x
->>>>>>>>>0	uleshort	<3600		CPython 3.13,
->>>>>>>>>0	default		x		CPython 3.14 or newer,
+>>>>>>>>>0	uleshort	<3600		CPython 3.13
+>>>>>>>>>0	default		x		CPython 3.14 or newer
 >>>0		use		pyc-pep552
->>0		uleshort	240		Byte-compiled Python module for PyPy3.7,
+>>0		uleshort	240		Byte-compiled Python module for PyPy3.7
 !:mime application/x-bytecode.python
 >>>0		use		pyc-pep552
->>0		uleshort	256		Byte-compiled Python module for PyPy3.8,
+>>0		uleshort	256		Byte-compiled Python module for PyPy3.8
 !:mime application/x-bytecode.python
 >>>0		use		pyc-pep552
->>0		uleshort	336		Byte-compiled Python module for PyPy3.9,
+>>0		uleshort	336		Byte-compiled Python module for PyPy3.9
 !:mime application/x-bytecode.python
 >>>0		use		pyc-pep552
 
-- 
2.45.2



More information about the File mailing list