Title: RustPython 3.13 uses CPython 3.12 magic number 3531 · Issue #6555 · RustPython/RustPython · GitHub
Open Graph Title: RustPython 3.13 uses CPython 3.12 magic number 3531 · Issue #6555 · RustPython/RustPython
X Title: RustPython 3.13 uses CPython 3.12 magic number 3531 · Issue #6555 · RustPython/RustPython
Description: Feature RustPython as of Dec 26, 2025 uses CPython magic number 3531 when it should not. $ cargo run -- -V Python 3.13.0alpha (heads/main:27ab62de4, Dec 26 2025, 11:16:09) [RustPython 0.4.0 with rustc 1.90.0 (1159e78c4 2025-09-14)] $ car...
Open Graph Description: Feature RustPython as of Dec 26, 2025 uses CPython magic number 3531 when it should not. $ cargo run -- -V Python 3.13.0alpha (heads/main:27ab62de4, Dec 26 2025, 11:16:09) [RustPython 0.4.0 with ru...
X Description: Feature RustPython as of Dec 26, 2025 uses CPython magic number 3531 when it should not. $ cargo run -- -V Python 3.13.0alpha (heads/main:27ab62de4, Dec 26 2025, 11:16:09) [RustPython 0.4.0 with ru...
Opengraph URL: https://github.com/RustPython/RustPython/issues/6555
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"RustPython 3.13 uses CPython 3.12 magic number 3531","articleBody":"## Feature\n\nRustPython as of Dec 26, 2025 uses CPython magic number 3531 when it should not. \n\n```\n$ cargo run -- -V\n\nPython 3.13.0alpha (heads/main:27ab62de4, Dec 26 2025, 11:16:09) [RustPython 0.4.0 with rustc 1.90.0 (1159e78c4 2025-09-14)]\n\n$ cargo run -- -\n\n\u003e\u003e\u003e\u003e\u003e from importlib.util import MAGIC_NUMBER\n\u003e\u003e\u003e\u003e\u003e MAGIC_NUMBER\nb'\\xcb\\r\\r\\n'\n\u003e\u003e\u003e\u003e\u003e import struct\n\u003e\u003e\u003e\u003e\u003e struct.unpack(\"\u003cHcc\", b'\\xcb\\r\\r\\n')[0]\n3531\n```\n\nThis is also reflected in the magic number written in RustPython's bytecode file: \n\n```\n\u003e\u003e\u003e\u003e\u003e import py_compile\n\u003e\u003e\u003e\u003e\u003e py_compile.compile(\"hello.py\", \"hello.pyc\")\n'hello.pyc'\n```\n\n```\n00000000: cb0d 0d0a 0000 0000 3900 5069 1700 0000 ........9.Pi....\n00000010: 6305 0000 0041 003c 0011 014d 0050 0105 c....A.\u003c...M.P..\n00000020: 0000 0001 0000 0000 0000 0001 0000 0006 ................\n00000030: 0000 0001 0000 0006 0000 0001 0000 0006 ................\n00000040: 0000 0001 0000 0006 0000 0001 0000 0000 ................\n00000050: 0000 0000 0000 0000 0008 0000 0068 656c .............hel\n00000060: 6c6f 2e70 7901 0000 0002 0000 0008 0000 lo.py...........\n00000070: 003c 6d6f 6475 6c65 3e08 0000 003c 6d6f .\u003cmodule\u003e....\u003cmo\n00000080: 6475 6c65 3e00 0000 0002 0000 0075 0d00 dule\u003e........u..\n00000090: 0000 4865 6c6c 6f2c 2057 6f72 6c64 214e ..Hello, World!N\n000000a0: 0100 0000 0500 0000 7072 696e 7400 0000 ........print...\n000000b0: 0000 0000 0000 0000 0004 0000 0080 0083 ................\n000000c0: 6000 0000 00 \n```\n\nThe magic number at the beginning of a file is not just a Python convention, but a POSIX file system convention:\n\n```\n$ file hello.pyc\nhello.pyc: Byte-compiled Python module for CPython 3.12 or newer, timestamp-based, .py timestamp: Sat Dec 27 15:50:17 2025 UTC, .py size: 23 bytes\n```\n\nThis is wrong. This file does not run on CPython 3.12; it is neither CPython nor 3.12.\n\nI came across this in extending the cross-version Python interpreter [xdis](https://pypi.org/project/xdis/) to handle RustPython bytecode.\n\n\n## Python Documentation or reference to CPython source code\n\nFrom Python's [PEP 3147](https://peps.python.org/pep-3147/#background) describing Magic numbers:\n\n\u003e The magic number changes whenever Python changes the byte code format, e.g. by adding new byte codes to its virtual machine. This ensures that pyc files built for previous versions of the VM won’t cause problems.\n\nThis implies that if RustPython's 3.13 bytecode format is different from CPython's 3.12 bytecode format, it should not use the same magic number value.\n","author":{"url":"https://github.com/rocky","@type":"Person","name":"rocky"},"datePublished":"2025-12-27T16:10:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/6555/RustPython/issues/6555"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b4ea7315-22a3-4f06-ce89-bcdc6907ed53 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8E24:21279A:CFA9B1:10C1315:696B2924 |
| html-safe-nonce | 5c9bced5ccdd48bf3236e0e94af7939b2aace694b22d57012584a6bb92356769 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTI0OjIxMjc5QTpDRkE5QjE6MTBDMTMxNTo2OTZCMjkyNCIsInZpc2l0b3JfaWQiOiI4NzgxOTc4OTc5NzU3OTI2NjkyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | acfceb8140848a57dabb07c3cf133e746343c71ef2d8069e8613d033b2ec8c67 |
| hovercard-subject-tag | issue:3764885480 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/RustPython/RustPython/6555/issue_layout |
| twitter:image | https://opengraph.githubassets.com/caa8c6e6ac815f4a5494eb2545e3496d96a4b3a3b7f90f6e5d66dd33eb54b376/RustPython/RustPython/issues/6555 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/caa8c6e6ac815f4a5494eb2545e3496d96a4b3a3b7f90f6e5d66dd33eb54b376/RustPython/RustPython/issues/6555 |
| og:image:alt | Feature RustPython as of Dec 26, 2025 uses CPython magic number 3531 when it should not. $ cargo run -- -V Python 3.13.0alpha (heads/main:27ab62de4, Dec 26 2025, 11:16:09) [RustPython 0.4.0 with ru... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rocky |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width