#17 Irreproducible pyc files
Opened 3 months ago by zbyszek. Modified 3 months ago

In kitty-0.35.1-3.fc41:

$ diffoscope {a,b}/usr/lib64/kitty/kitty/rc/__pycache__/send_text.cpython-313.pyc
--- a/usr/lib64/kitty/kitty/rc/__pycache__/send_text.cpython-313.pyc
+++ b/usr/lib64/kitty/kitty/rc/__pycache__/send_text.cpython-313.pyc
│┄ Format-specific differences are supported for Python .pyc files but no file-specific differences were detected; falling back to a binary diff. file(1) reports: Byte-compiled Python module for CPython 3.12 or newer, hash-based, check-source flag unset, hash: 0x4c6cd41c74b94
│┄ Could not decompile bytecode: tuple index out of range
@@ -59,15 +59,15 @@
 000003a0: 0372 1900 0000 5a03 7365 7472 1a00 0000  .r....Z.setr....
 000003b0: 2902 da04 7365 6c66 7219 0000 0073 0200  )...selfr....s..
 000003c0: 0000 2020 da15 6b69 7474 792f 7263 2f73  ..  ..kitty/rc/s
 000003d0: 656e 645f 7465 7874 2e70 79da 085f 5f69  end_text.py..__i
 000003e0: 6e69 745f 5f5a 1053 6573 7369 6f6e 2e5f  nit__Z.Session._
 000003f0: 5f69 6e69 745f 5f24 0000 0073 1000 0000  _init__$...s....
 00000400: 8000 d812 148c 07dc 1a1d 9b25 8804 8d0f  ...........%....
-00000410: f300 0000 0029 0272 1900 0000 721a 0000  .....).r....r...
+00000410: f300 0000 0029 0272 1a00 0000 7219 0000  .....).r....r...
 00000420: 004e 290a da08 5f5f 6e61 6d65 5f5f da0a  .N)...__name__..
 00000430: 5f5f 6d6f 6475 6c65 5f5f da0c 5f5f 7175  __module__..__qu
 00000440: 616c 6e61 6d65 5f5f da0f 5f5f 6669 7273  alname__..__firs
 00000450: 746c 696e 656e 6f5f 5fda 0373 7472 da0f  tlineno__..str..
 00000460: 5f5f 616e 6e6f 7461 7469 6f6e 735f 5f72  __annotations__r
 00000470: 0500 0000 5a03 696e 7472 1e00 0000 da15  ....Z.intr......
 00000480: 5f5f 7374 6174 6963 5f61 7474 7269 6275  __static_attribu

Both marshalparser and add-det agree that the files has had any unused flag refs removed. So it's something else.


$ curl https://zbyszek.fedorapeople.org/marshalparser-a-b.diff            
--- /dev/fd/63  2024-06-17 10:01:27.280973967 +0000
+++ /dev/fd/62  2024-06-17 10:01:27.280973967 +0000
@@ -132,13 +132,13 @@
         n=1045/0x415 byte=(b'29', b')', 0b101001) TYPE_SMALL_TUPLE 
           Small tuple size: 2
           n=1047/0x417 byte=(b'72', b'r', 0b1110010) TYPE_REF 
-          result=REF to 25: Flag_ref(byte=836, type='TYPE_SHORT_ASCII_INTERNED', content=b'id', usages=3), type=<class 'str'>
-          n=1052/0x41c byte=(b'72', b'r', 0b1110010) TYPE_REF 
           result=REF to 26: Flag_ref(byte=840, type='TYPE_SHORT_ASCII_INTERNED', content=b'window_ids', usages=2), type=<class 'str'>
-        result=("REF to 25: Flag_ref(byte=836, type='TYPE_SHORT_ASCII_INTERNED', content=b'id', usages=3)", "REF to 26: Flag_ref(byte=840, type='TYPE_SHORT_ASCII_INTERNED', content=b'window_ids', usages=2)"), type=<class 'tuple'>
+          n=1052/0x41c byte=(b'72', b'r', 0b1110010) TYPE_REF 
+          result=REF to 25: Flag_ref(byte=836, type='TYPE_SHORT_ASCII_INTERNED', content=b'id', usages=3), type=<class 'str'>
+        result=("REF to 26: Flag_ref(byte=840, type='TYPE_SHORT_ASCII_INTERNED', content=b'window_ids', usages=2)", "REF to 25: Flag_ref(byte=836, type='TYPE_SHORT_ASCII_INTERNED', content=b'id', usages=3)"), type=<class 'tuple'>
         n=1057/0x421 byte=(b'4e', b'N', 0b1001110) TYPE_NONE 
         result=None, type=<class 'NoneType'>
...

It looks like it's this code snippets that causes the non-reproducibility:

class Session:
    id: str
    window_ids: Set[int]

    def __init__(self, id: str):
        self.id = id
        self.window_ids = set()

The references to the strings "id" and "window_ids" are the ones that are swapped in one tuple(ref, ref). Maybe the order of class variables is not consistent? Not sure what that tuple is even used for, it's one of the "consts" of the "code" object that represents the Session class.

Log in to comment on this ticket.

Metadata