Title: `sys.audit(0)` aborts due to an assertion in debug build · Issue #126018 · python/cpython · GitHub
Open Graph Title: `sys.audit(0)` aborts due to an assertion in debug build · Issue #126018 · python/cpython
X Title: `sys.audit(0)` aborts due to an assertion in debug build · Issue #126018 · python/cpython
Description: Crash report What happened? There is an assert in sysmodule.c that makes the interpreter abort when calling sys.audit with a non-string value in debug builds: cpython/Python/sysmodule.c Line 522 in f6cc7c8 assert(PyUnicode_Check(args[0])...
Open Graph Description: Crash report What happened? There is an assert in sysmodule.c that makes the interpreter abort when calling sys.audit with a non-string value in debug builds: cpython/Python/sysmodule.c Line 522 in...
X Description: Crash report What happened? There is an assert in sysmodule.c that makes the interpreter abort when calling sys.audit with a non-string value in debug builds: cpython/Python/sysmodule.c Line 522 in...
Opengraph URL: https://github.com/python/cpython/issues/126018
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`sys.audit(0)` aborts due to an assertion in debug build","articleBody":"# Crash report\n\n### What happened?\n\nThere is an assert in `sysmodule.c` that makes the interpreter abort when calling `sys.audit` with a non-string value in debug builds:\nhttps://github.com/python/cpython/blob/f6cc7c8bd01d8468af70a65e550abef3854d0754/Python/sysmodule.c#L522\n\n```python\nPython 3.14.0a1+ (heads/main:c5b99f5c2c, Oct 26 2024, 12:35:53) [GCC 13.2.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e import sys\n\u003e\u003e\u003e sys.audit(9)\npython: ./Python/sysmodule.c:522: sys_audit: Assertion `PyUnicode_Check(args[0])' failed.\nAborted (core dumped)\n```\n\nThis assert seems completely unnecessary, as the code that runs the hooks (which only triggers if there is some hook registered) will raise an exception if the first argument to `sys.audit` isn't a string:\n\n```python\nPython 3.14.0a1+ (heads/remove_sysaudit_assert:ba8ac4d398, Oct 26 2024, 19:45:11) [GCC 11.4.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e import sys\n\u003e\u003e\u003e sys.addaudithook(lambda *args: None)\n\u003e\u003e\u003e sys.audit(9)\nTraceback (most recent call last):\n File \"\u003cpython-input-2\u003e\", line 1, in \u003cmodule\u003e\n sys.audit(9)\n ~~~~~~~~~^^^\nTypeError: expected str for argument 'event', not int\n```\n\nI'll submit a trivial PR removing this assert.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux, Windows\n\n### Output from running 'python -VV' on the command line:\n\nPython 3.14.0a1+ (heads/main:c5b99f5c2c, Oct 26 2024, 12:35:53) [GCC 13.2.0]\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-126020\n* gh-126042\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/devdanzin","@type":"Person","name":"devdanzin"},"datePublished":"2024-10-26T22:49:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/126018/cpython/issues/126018"}
| 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:1a964ca6-4ec4-911b-656c-e7b0991a228a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 806E:8D11F:1B551:2673A:696A6074 |
| html-safe-nonce | c35f4e4c739aa8357c13d54cbdd72aa043dba498f8636746c46669079320e8d8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDZFOjhEMTFGOjFCNTUxOjI2NzNBOjY5NkE2MDc0IiwidmlzaXRvcl9pZCI6Ijc3NjEyMDQwNDk2NjE4MTI4NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 737f59c4b78a6c178f8896097ee83a70845fde1dae304c5709860929b338a205 |
| hovercard-subject-tag | issue:2616192408 |
| 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/126018/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b7e59060f2efc1643ebea0999f19a21a382df405e5e0938ce0bb5701fd68aada/python/cpython/issues/126018 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b7e59060f2efc1643ebea0999f19a21a382df405e5e0938ce0bb5701fd68aada/python/cpython/issues/126018 |
| og:image:alt | Crash report What happened? There is an assert in sysmodule.c that makes the interpreter abort when calling sys.audit with a non-string value in debug builds: cpython/Python/sysmodule.c Line 522 in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | devdanzin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9b7735a184970dd9333b2cbe036c8f3c0a9108c64aaa93827c5a64fc70993392 |
| 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 | 87cbd411c2982752221b5751d583a515b23bf5fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width