Title: python variables called _m lead to unreproducible pyc installations · Issue #92132 · python/cpython · GitHub
Open Graph Title: python variables called _m lead to unreproducible pyc installations · Issue #92132 · python/cpython
X Title: python variables called _m lead to unreproducible pyc installations · Issue #92132 · python/cpython
Description: Hi, in Debian we backported the changes from #27926 to cpython 3.10 and indeed most pyc files that we generate when installing python packages are now bit-by-bit reproducible. There is only a single pyc file that still sometimes leads to...
Open Graph Description: Hi, in Debian we backported the changes from #27926 to cpython 3.10 and indeed most pyc files that we generate when installing python packages are now bit-by-bit reproducible. There is only a singl...
X Description: Hi, in Debian we backported the changes from #27926 to cpython 3.10 and indeed most pyc files that we generate when installing python packages are now bit-by-bit reproducible. There is only a singl...
Opengraph URL: https://github.com/python/cpython/issues/92132
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"python variables called _m lead to unreproducible pyc installations","articleBody":"Hi,\r\n\r\nin Debian we backported the changes from #27926 to cpython 3.10 and indeed most pyc files that we generate when installing python packages are now bit-by-bit reproducible. There is only a single pyc file that still *sometimes* leads to a different pyc file after installation: ` /usr/lib/python3.10/json/__pycache__/decoder.cpython-310.pyc`. I tracked down the reason to its use of the variable name `_m` and filed this as [Debian bug 1010368](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1010368). More specifically, that pyc file will have one content in 1/3 cases and another in 2/3 of the cases. The diff between the pyc files is:\r\n\r\n```diff\r\n@@ -1,8 +1,8 @@\r\n 00000000: 6f0d 0d0a 0300 0000 5371 fe33 17b6 dd59 o.......Sq.3...Y\r\n 00000010: e300 0000 0000 0000 0000 0000 0000 0000 ................\r\n 00000020: 0001 0000 0040 0000 0073 0800 0000 6500 .....@...s....e.\r\n-00000030: 0100 6400 5300 2901 4e29 01da 025f 6da9 ..d.S.).N)..._m.\r\n-00000040: 0072 0200 0000 7202 0000 00fa 0f2f 746d .r....r....../tm\r\n+00000030: 0100 6400 5300 2901 4e29 015a 025f 6da9 ..d.S.).N).Z._m.\r\n+00000040: 0072 0100 0000 7201 0000 00fa 0f2f 746d .r....r....../tm\r\n 00000050: 702f 6465 636f 6465 722e 7079 da08 3c6d p/decoder.py..\u003cm\r\n 00000060: 6f64 756c 653e 0100 0000 7302 0000 0008 odule\u003e....s.....\r\n 00000070: 00\r\n```\r\nI can make this problem trigger on a different variable name than `_m` via the following patch:\r\n\r\n```diff\r\n--- a/Lib/types.py\r\n+++ b/Lib/types.py\r\n@@ -37,8 +37,8 @@ _ag = _ag()\r\n AsyncGeneratorType = type(_ag)\r\n \r\n class _C:\r\n- def _m(self): pass\r\n-MethodType = type(_C()._m)\r\n+ def _b(self): pass\r\n+MethodType = type(_C()._b)\r\n \r\n BuiltinFunctionType = type(len)\r\n BuiltinMethodType = type([].append) # Same as BuiltinFunctionType\r\n```\r\n\r\nWith that patch, python files containing the variable name `_b` are now sometimes unreproducible.\r\n\r\nI don't seem to be the first who stumbled across the `_m` variable: https://github.com/python/cpython/issues/78903#issuecomment-1093799639\r\n\r\nIn the Debian bug I referenced above, Chris Lamb states, that there is no semantic difference between the different pyc files and Keith Amling points out, that the difference is `FLAG_REF` being added or not.\r\n\r\nSince pyc files containing the variable `_m` are only sometimes unreproducible on new python installations but stable on the same installation, this might as well be a python packaging bug in Debian or maybe we need to backport more than just #27926 to 3.10 to make pyc files stable across different installations. I thus wanted to ask you for any input or advice you can give on this issue.\r\n\r\nThanks!","author":{"url":"https://github.com/josch","@type":"Person","name":"josch"},"datePublished":"2022-05-02T07:45:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/92132/cpython/issues/92132"}
| 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:627b6846-bd2f-ba68-22f4-ac86f7898e1c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E6F4:1E4FEF:2F60FFF:3DBE38E:696B8099 |
| html-safe-nonce | cd3c8fb2fd96ff92b58cb1bc26a32a0503ebb4d97f11ffc3185daaaa37698dc8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNkY0OjFFNEZFRjoyRjYwRkZGOjNEQkUzOEU6Njk2QjgwOTkiLCJ2aXNpdG9yX2lkIjoiMjY3NjE0NTU0NzgyNjEzNTE5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 174d1cf4d0ef71721912e37b49b3c548096fa8ea93f1ab1f64a9cba8c810e652 |
| hovercard-subject-tag | issue:1222587245 |
| 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/python/cpython/92132/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3c851f309a3ba7806c5e6cc055b61b0c2e69b09a5ce00cbe13da6109e2c2270c/python/cpython/issues/92132 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3c851f309a3ba7806c5e6cc055b61b0c2e69b09a5ce00cbe13da6109e2c2270c/python/cpython/issues/92132 |
| og:image:alt | Hi, in Debian we backported the changes from #27926 to cpython 3.10 and indeed most pyc files that we generate when installing python packages are now bit-by-bit reproducible. There is only a singl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | josch |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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